diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-20 12:47:10 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-20 12:47:10 -0700 |
commit | f5ca3478c68e47ae20fd12748c1552fdf81f75f9 (patch) | |
tree | b3d3f889ed25084fe33ed9e01554d6ca51104bb5 /internal/jsonparse | |
parent | d240d0b06c7b5711f583d961eddfc37d07d4546e (diff) | |
parent | 49ee8be679add0bd3cf08a2669331b3be7a835f8 (diff) |
Merge branch 'lukeshu/fixes'
Diffstat (limited to 'internal/jsonparse')
-rw-r--r-- | internal/jsonparse/parse.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/jsonparse/parse.go b/internal/jsonparse/parse.go index 1c35533..6432d75 100644 --- a/internal/jsonparse/parse.go +++ b/internal/jsonparse/parse.go @@ -525,6 +525,21 @@ func (par *Parser) HandleEOF() (RuneType, error) { } } +// IsAtBarrier returns whether a read-barrier has been reached and the +// next HandleRune call would definitely return RuneTypeEOF. +func (par *Parser) IsAtBarrier() bool { + return par.initialized && + // HandleRune wouldn't return early with an error. + !par.closed && + par.err == nil && + // The current (sub-)parser has reached its end, and + len(par.stack) == 0 && + // there is a barrier, and + len(par.barriers) > 0 && + // that barrier would definitely return RuneTypeEOF. + !par.barriers[len(par.barriers)-1].allowWS +} + // HandleRune feeds a Unicode rune to the Parser. // // An error is returned if and only if the RuneType is RuneTypeError. |