From 18594e5caf3dda013e6f6fb9cfe558d7153e383d Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sat, 11 Jan 2020 14:17:06 +0100 Subject: token: rewrite documentation for `LookupIdent`. --- users/fcuny/exp/monkey/pkg/token/token.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'users/fcuny/exp/monkey') 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 -- cgit 1.4.1