aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-01-08 19:17:45 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-01-08 19:17:45 +0100
commitd89886f5a4ccfe4fa4857f97b2973dc6218463f8 (patch)
treec92b4dc4ed1f7af6b6fa416753b458a5db9295a2
parent9cc95a0ecb08d7695d235b5c865cfa0ccf9e9aae (diff)
Simplify
-rw-r--r--lexer.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/lexer.go b/lexer.go
index 8336947..2364515 100644
--- a/lexer.go
+++ b/lexer.go
@@ -96,21 +96,16 @@ func (y *yyLex) run() {
switch c := y.next(); {
case unicode.IsDigit(c):
y.lexNumber()
- y.emit(digit)
case unicode.IsUpper(c):
y.emit(upper)
case unicode.IsLower(c):
y.emit(lower)
case unicode.IsSpace(c):
y.ignore()
- case c == '\'':
- if y.lexQuoted() {
- y.emit(quoted)
- } else {
- y.emit(int(c))
- }
case c == eof:
return
+ case c == '\'':
+ y.lexQuoted()
default:
y.emit(char)
}
@@ -126,15 +121,17 @@ func (y *yyLex) lexNumber() {
y.acceptRune('-')
y.acceptDigits()
}
+ y.emit(digit)
}
-func (y *yyLex) lexQuoted() bool {
+func (y *yyLex) lexQuoted() {
if n := strings.IndexRune(y.input[y.pos:], '\''); n >= 0 {
y.pos += n
y.next()
- return true
+ y.emit(quoted)
+ } else {
+ y.emit(char)
}
- return false
}
func (y *yyLex) emit(t int) {