diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:06:12 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:06:12 -0700 |
commit | 480ccfd05a13ac36516c536a71203280a31b4d28 (patch) | |
tree | 4ae21bf95c9f3b4cce97a0a0473fe622fdb393eb /decode_scan.go | |
parent | 87013d526ea1b0647ef6e08758fe587cee11d854 (diff) | |
parent | 47549aa3d10808c063d45dcaa598887dadde59c5 (diff) |
Merge branch 'lukeshu/fixup'
Diffstat (limited to 'decode_scan.go')
-rw-r--r-- | decode_scan.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/decode_scan.go b/decode_scan.go index e233caf..7a52975 100644 --- a/decode_scan.go +++ b/decode_scan.go @@ -7,7 +7,7 @@ package lowmemjson import ( "io" - "git.lukeshu.com/go/lowmemjson/internal" + "git.lukeshu.com/go/lowmemjson/internal/jsonparse" ) type runeTypeScanner struct { @@ -16,7 +16,7 @@ type runeTypeScanner struct { inner io.RuneScanner // initialized by constructor - parser internal.Parser // initialized by constructor + parser jsonparse.Parser // initialized by constructor offset int64 initialized bool @@ -24,13 +24,13 @@ type runeTypeScanner struct { rRune rune rSize int - rType internal.RuneType + rType jsonparse.RuneType rErr error } func (sc *runeTypeScanner) Reset() { sc.parser.Reset() - if sc.repeat || (sc.rType == internal.RuneTypeEOF && sc.rSize > 0) { + if sc.repeat || (sc.rType == jsonparse.RuneTypeEOF && sc.rSize > 0) { sc.repeat = false // re-figure the rType and rErr var err error @@ -45,6 +45,8 @@ func (sc *runeTypeScanner) Reset() { } // tell it to use that rType and rErr _ = sc.UnreadRune() // we set it up to always succeed + } else { + sc.initialized = false } } @@ -55,9 +57,9 @@ func (sc *runeTypeScanner) Reset() { // end of both value and file: (_, 0, RuneTypeEOF, nil) // end of file in middle of value: (_, 0, RuneTypeError, &DecodeSyntaxError{Offset: offset: Err: io.ErrUnexepctedEOF}) // end of file at start of value: (_, 0, RuneTypeError, &DecodeSyntaxError{Offset: offset: Err: io.EOF}) -func (sc *runeTypeScanner) ReadRuneType() (rune, int, internal.RuneType, error) { +func (sc *runeTypeScanner) ReadRuneType() (rune, int, jsonparse.RuneType, error) { switch { - case sc.initialized && (sc.rType == internal.RuneTypeError || sc.rType == internal.RuneTypeEOF): + case sc.initialized && (sc.rType == jsonparse.RuneTypeError || sc.rType == jsonparse.RuneTypeEOF): // do nothing case sc.repeat: _, _, _ = sc.inner.ReadRune() @@ -78,7 +80,7 @@ func (sc *runeTypeScanner) ReadRuneType() (rune, int, internal.RuneType, error) } else { sc.rErr = nil } - if sc.rType == internal.RuneTypeSpace { + if sc.rType == jsonparse.RuneTypeSpace { goto again } case io.EOF: @@ -131,7 +133,7 @@ func (sc *runeTypeScanner) PushReadBarrier() { func (sc *runeTypeScanner) PopReadBarrier() { sc.parser.PopBarrier() - if sc.repeat || (sc.rType == internal.RuneTypeEOF && sc.rSize > 0) { + if sc.repeat || (sc.rType == jsonparse.RuneTypeEOF && sc.rSize > 0) { // re-figure the rType and rErr var err error sc.rType, err = sc.parser.HandleRune(sc.rRune) @@ -145,7 +147,7 @@ func (sc *runeTypeScanner) PopReadBarrier() { } // tell it to use that rType and rErr _ = sc.UnreadRune() // we set it up to always succeed - } else if sc.rType == internal.RuneTypeEOF { + } else if sc.rType == jsonparse.RuneTypeEOF { // re-figure the rType and rErr var err error sc.rType, err = sc.parser.HandleEOF() |