Fixed lexer changes made in #3434

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-09-03 20:02:25 -06:00
parent 1a9b3c49c0
commit 6ebbb4a41a
2 changed files with 12 additions and 7 deletions

View File

@@ -1009,17 +1009,12 @@ func lexConvenientNumber(lx *lexer) stateFn {
case r == 'b' || r == 'B' || r == 'i' || r == 'I':
return lexConvenientNumber
}
lx.backup()
if isNL(r) || r == eof || r == mapEnd || r == optValTerm || r == mapValTerm || isWhitespace(r) || unicode.IsDigit(r) {
lx.backup()
lx.emit(itemInteger)
return lx.pop()
}
// This is not a number, so we have to backup to the start and consider
// this to be a string
pos, start := lx.pos, lx.start
for i := pos; i > start; i-- {
lx.backup()
}
// This is not a number, so treat it as a string.
lx.stringStateFn = lexString
return lexString
}