lex.go: separate '.' from identifier
This commit is contained in:
parent
7abebdbfd6
commit
ea40290f43
@ -362,18 +362,11 @@ func lexInsideAction(l *Lexer) stateFn {
|
|||||||
// special look-ahead for ".field" so we don't break l.backup().
|
// special look-ahead for ".field" so we don't break l.backup().
|
||||||
r = l.peek()
|
r = l.peek()
|
||||||
if r < '0' || '9' < r {
|
if r < '0' || '9' < r {
|
||||||
l.emit(ItemChar)
|
l.emit(ItemDot)
|
||||||
return lexInsideAction
|
return lexInsideAction
|
||||||
}
|
}
|
||||||
fallthrough // '.' can start a number.
|
fallthrough // '.' can start a number.
|
||||||
case r == '+' || r == '-' || ('0' <= r && r <= '9'):
|
case '0' <= r && r <= '9':
|
||||||
if r == '+' || r == '-' {
|
|
||||||
r := l.peek()
|
|
||||||
if (r < '0' || '9' < r) && r != '.' {
|
|
||||||
return lexOperator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
l.backup()
|
l.backup()
|
||||||
return lexNumber
|
return lexNumber
|
||||||
case isOperator(r):
|
case isOperator(r):
|
||||||
@ -439,7 +432,7 @@ func lexIdentifier(l *Lexer) stateFn {
|
|||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
switch r := l.next(); {
|
switch r := l.next(); {
|
||||||
case isAlphaNumeric(r) || r == '.':
|
case isAlphaNumeric(r):
|
||||||
// absorb.
|
// absorb.
|
||||||
default:
|
default:
|
||||||
l.backup()
|
l.backup()
|
||||||
|
Loading…
Reference in New Issue
Block a user