diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-03 23:03:06 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-03 23:03:06 -0700 |
commit | 86d682017d9c83959a27a68d875e55bc41f1ea6f (patch) | |
tree | 627908e0e27b5b21bd6715b675ab9f66b3e8da2c | |
parent | 4d460fc53ea054a2d5df89c6243f567ffb58b871 (diff) |
fixup! Invent "barriers" instead of nesting parsers
-rw-r--r-- | reencode.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/reencode.go b/reencode.go index eae80db..b135fb8 100644 --- a/reencode.go +++ b/reencode.go @@ -99,13 +99,14 @@ type ReEncoder struct { inputPos int64 // state: .handleRune - lastNonSpace internal.RuneType - wasNumber bool - curIndent int - uhex [4]byte // "\uABCD"-encoded characters in strings - fracZeros int64 - expZero bool - specu *speculation + lastNonSpace internal.RuneType + lastNonSpaceNonEOF internal.RuneType + wasNumber bool + curIndent int + uhex [4]byte // "\uABCD"-encoded characters in strings + fracZeros int64 + expZero bool + specu *speculation // state: .pushBarrier and .popBarrier stackInputPos []int64 @@ -295,6 +296,7 @@ func (enc *ReEncoder) popWriteBarrier() { enc.par.PopBarrier() enc.inputPos += enc.stackInputPos[len(enc.stackInputPos)-1] enc.stackInputPos = enc.stackInputPos[:len(enc.stackInputPos)-1] + enc.lastNonSpace = enc.lastNonSpaceNonEOF } // internal //////////////////////////////////////////////////////////////////// @@ -532,6 +534,9 @@ func (enc *ReEncoder) handleRuneMain(c rune, t internal.RuneType) error { if t != internal.RuneTypeSpace { enc.lastNonSpace = t + if t != internal.RuneTypeEOF { + enc.lastNonSpaceNonEOF = t + } } return err } |