| 465 | } |
| 466 | |
| 467 | func (dec *Decoder) tokenError(c byte) (Token, error) { |
| 468 | var context string |
| 469 | switch dec.tokenState { |
| 470 | case tokenTopValue: |
| 471 | context = " looking for beginning of value" |
| 472 | case tokenArrayStart, tokenArrayValue, tokenObjectValue: |
| 473 | context = " looking for beginning of value" |
| 474 | case tokenArrayComma: |
| 475 | context = " after array element" |
| 476 | case tokenObjectKey: |
| 477 | context = " looking for beginning of object key string" |
| 478 | case tokenObjectColon: |
| 479 | context = " after object key" |
| 480 | case tokenObjectComma: |
| 481 | context = " after object key:value pair" |
| 482 | } |
| 483 | return nil, &SyntaxError{"invalid character " + quoteChar(c) + context, dec.offset()} |
| 484 | } |
| 485 | |
| 486 | // More reports whether there is another element in the |
| 487 | // current array or object being parsed. |