mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Fixed lexer changes made in #3434
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -1009,17 +1009,12 @@ func lexConvenientNumber(lx *lexer) stateFn {
|
|||||||
case r == 'b' || r == 'B' || r == 'i' || r == 'I':
|
case r == 'b' || r == 'B' || r == 'i' || r == 'I':
|
||||||
return lexConvenientNumber
|
return lexConvenientNumber
|
||||||
}
|
}
|
||||||
if isNL(r) || r == eof || r == mapEnd || r == optValTerm || r == mapValTerm || isWhitespace(r) || unicode.IsDigit(r) {
|
|
||||||
lx.backup()
|
lx.backup()
|
||||||
|
if isNL(r) || r == eof || r == mapEnd || r == optValTerm || r == mapValTerm || isWhitespace(r) || unicode.IsDigit(r) {
|
||||||
lx.emit(itemInteger)
|
lx.emit(itemInteger)
|
||||||
return lx.pop()
|
return lx.pop()
|
||||||
}
|
}
|
||||||
// This is not a number, so we have to backup to the start and consider
|
// This is not a number, so treat it as a string.
|
||||||
// this to be a string
|
|
||||||
pos, start := lx.pos, lx.start
|
|
||||||
for i := pos; i > start; i-- {
|
|
||||||
lx.backup()
|
|
||||||
}
|
|
||||||
lx.stringStateFn = lexString
|
lx.stringStateFn = lexString
|
||||||
return lexString
|
return lexString
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,6 +330,16 @@ func TestConvenientIntegerValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
lx = lex("foo = 3Mbs,")
|
lx = lex("foo = 3Mbs,")
|
||||||
expect(t, lx, expectedItems)
|
expect(t, lx, expectedItems)
|
||||||
|
|
||||||
|
expectedItems = []item{
|
||||||
|
{itemKey, "foo", 1, 0},
|
||||||
|
{itemInteger, "4Gb", 1, 6},
|
||||||
|
{itemKey, "bar", 1, 11},
|
||||||
|
{itemString, "5Gø", 1, 17},
|
||||||
|
{itemEOF, "", 1, 0},
|
||||||
|
}
|
||||||
|
lx = lex("foo = 4Gb, bar = 5Gø")
|
||||||
|
expect(t, lx, expectedItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimpleKeyFloatValues(t *testing.T) {
|
func TestSimpleKeyFloatValues(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user