xgo/token/keywords.go

19 lines
295 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
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
}