18 lines
295 B
Go
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
|
|
}
|