xgo/token/keywords.go
2019-01-08 23:17:42 -08:00

18 lines
295 B
Go

package token
var keywords map[string]Token
func init() {
keywords = make(map[string]Token)
for i := _keywordBeg + 1; i < _keywordEnd; i++ {
keywords[tokens[i]] = i
}
}
func Lookup(ident string) Token {
if tok, isKeyword := keywords[ident]; isKeyword {
return tok
}
return Ident
}