diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-18 21:57:39 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-18 22:45:39 -0700 |
commit | edfc7aa91b542978ce28eb109b99a257650b62b4 (patch) | |
tree | 3bc300355b7843a2c2ba3a0ec5db4346cdc87965 /internal | |
parent | cf75ff06887d7bbb5bbbd682587b9d3f5e474670 (diff) |
decode_scan, jsonparse: Rework the behavior to make a bit more sense
- decode_scan: Don't have .Reset() re-play an erroring rune
- decode_Scan: Have RuneTypeEOF always be zero-width
- jsonparse: Don't replace syntax errors with RuneTypeEOF if there's no barrier
Diffstat (limited to 'internal')
-rw-r--r-- | internal/jsonparse/parse.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/jsonparse/parse.go b/internal/jsonparse/parse.go index d867cbc..06efc8c 100644 --- a/internal/jsonparse/parse.go +++ b/internal/jsonparse/parse.go @@ -545,7 +545,11 @@ func (par *Parser) HandleRune(c rune) (RuneType, error) { case 0x0020, 0x000A, 0x000D, 0x0009: return RuneTypeSpace, nil default: - return RuneTypeEOF, nil + if len(par.barriers) > 0 { + return RuneTypeEOF, nil + } else { + return RuneTypeError, fmt.Errorf("invalid character %q after top-level value", c) + } } } switch par.stack[len(par.stack)-1] { |