diff options
author | franck cuny <franck@fcuny.net> | 2020-01-11 14:17:06 +0100 |
---|---|---|
committer | franck cuny <franck@fcuny.net> | 2020-01-11 14:17:40 +0100 |
commit | 18594e5caf3dda013e6f6fb9cfe558d7153e383d (patch) | |
tree | 5420d5e1c6ad4196c32221f2354c356fae5f23c1 /users/fcuny/exp/monkey | |
parent | lexer: delete redundant test. (diff) | |
download | world-18594e5caf3dda013e6f6fb9cfe558d7153e383d.tar.gz |
token: rewrite documentation for `LookupIdent`.
Diffstat (limited to '')
-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 |