fix finish number error

This commit is contained in:
Tnze
2021-05-25 22:03:14 +08:00
parent c44af2bf34
commit 1f7d07b279
3 changed files with 5 additions and 8 deletions

View File

@ -22,7 +22,7 @@ func (e *Encoder) WriteSNBT(snbt string) error {
panic(phasePanicMsg) panic(phasePanicMsg)
case scanBeginLiteral: case scanBeginLiteral:
return writeLiteral(e, &d)
case scanBeginCompound: case scanBeginCompound:
panic("not implemented") panic("not implemented")

View File

@ -86,7 +86,7 @@ func (s *scanner) popParseState() {
s.parseState = s.parseState[:n] s.parseState = s.parseState[:n]
if n == 0 { if n == 0 {
s.step = s.stateEndTop s.step = s.stateEndTop
//s.endTop = true s.endTop = true
} else { } else {
s.step = s.stateEndValue s.step = s.stateEndValue
} }
@ -324,10 +324,6 @@ func (s *scanner) stateNumDot0(c byte) int {
} }
func (s *scanner) stateEndNumValue(c byte) int { func (s *scanner) stateEndNumValue(c byte) int {
if isSpace(c) {
s.step = s.stateEndValue
return scanSkipSpace
}
switch c { switch c {
case 'b', 'B': // TAG_Byte case 'b', 'B': // TAG_Byte
s.step = s.stateEndValue s.step = s.stateEndValue

View File

@ -6,12 +6,13 @@ import (
) )
func TestSNBT_checkScanCode(t *testing.T) { func TestSNBT_checkScanCode(t *testing.T) {
t.SkipNow() //t.SkipNow()
var s scanner var s scanner
s.reset() s.reset()
for _, c := range []byte(`{ "a b\"c": {}, def: 12345}`) { for _, c := range []byte(`1234`) {
t.Logf("[%c] - %d", c, s.step(c)) t.Logf("[%c] - %d", c, s.step(c))
} }
t.Logf("[%c] - %d", ' ', s.eof())
} }
func TestSNBT_number(t *testing.T) { func TestSNBT_number(t *testing.T) {