about summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@fcuny.net>2020-01-11 14:17:06 +0100
committerfranck cuny <franck@fcuny.net>2020-01-11 14:17:40 +0100
commit18594e5caf3dda013e6f6fb9cfe558d7153e383d (patch)
tree5420d5e1c6ad4196c32221f2354c356fae5f23c1
parentlexer: delete redundant test. (diff)
downloadworld-18594e5caf3dda013e6f6fb9cfe558d7153e383d.tar.gz
token: rewrite documentation for `LookupIdent`.
-rw-r--r--users/fcuny/exp/monkey/pkg/token/token.go7
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