diff options
Diffstat (limited to 'users/fcuny/exp/monkey/pkg/token')
-rw-r--r-- | users/fcuny/exp/monkey/pkg/token/token.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/users/fcuny/exp/monkey/pkg/token/token.go b/users/fcuny/exp/monkey/pkg/token/token.go index bc9e563..6937595 100644 --- a/users/fcuny/exp/monkey/pkg/token/token.go +++ b/users/fcuny/exp/monkey/pkg/token/token.go @@ -44,9 +44,10 @@ var keywords = map[string]TokenType{ "let": LET, } -// LookupIdent returns the token type for a given identifier. If the identifier -// is one of our keyword, we return the corresponding value, otherwise we return -// the given identifier. +// LookupIdent returns the token type for a given identifier. +// First we check if the identifier is a keyword. If it is, we return they +// keyword TokenType constant. If it isn't, we return the token.IDENT which is +// the TokenType for all user-defined identifiers. func LookupIdent(ident string) TokenType { if tok, ok := keywords[ident]; ok { return tok |