aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-06-06 02:55:05 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-06-06 02:55:05 +0200
commit847a37b725afd04d38b7357ca548dd1145e688a3 (patch)
treed2e3bec325e75018f04bd5f376cd4b915a457e93
parentbe19d4bca3e12fa8a46a35fa300a8a46f6fd202c (diff)
...
-rw-r--r--lexer.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/lexer.go b/lexer.go
index 0c6f982..974831c 100644
--- a/lexer.go
+++ b/lexer.go
@@ -15,12 +15,6 @@ const (
char
)
-var typemap = map[int]int{
- number: NUMBER,
- word: WORD,
- char: eof,
-}
-
type item struct {
typ int
val string
@@ -49,14 +43,15 @@ func (y *yyLex) Lex(lval *yySymType) int {
y.Error(err.Error())
}
lval.fval = n
- return typemap[item.typ]
+ return NUMBER
case word:
lval.sval = item.val
- return typemap[item.typ]
+ return WORD
case char:
return int(item.val[0])
+ default:
+ return eof
}
- return eof
}
func lex(input string) *yyLex {