Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var KeywordTokens = map[string]token.TokenType{ "let": token.LET, "if": token.IF, "else": token.ELSE, "while": token.WHILE, "for": token.FOR, "break": token.BREAK, "continue": token.CONTINUE, "function": token.FUNCTION, "return": token.RETURN, "const": token.CONST, "import": token.IMPORT, "export": token.EXPORT, "try": token.TRY, "catch": token.CATCH, "throw": token.THROW, "switch": token.SWITCH, "case": token.CASE, "default": token.DEFAULT, "in": token.IN, "do": token.DO, "print": token.PRINT, "true": token.TRUE, "false": token.FALSE, "null": token.NULL, "typeof": token.TYPEOF, "match": token.MATCH, "async": token.ASYNC, "await": token.AWAIT, "init": token.INIT, "new": token.NEW, "type": token.IDENT, "lazy": token.IDENT, "yield": token.YIELD, "macro": token.MACRO, "for_await": token.FOR_AWAIT, "select": token.SELECT, "spawn": token.SPAWN, "abstract": token.ABSTRACT, "extends": token.EXTENDS, "super": token.SUPER, }
KeywordTokens maps keyword strings to their token types.
Functions ¶
func LookupIdent ¶
LookupIdent checks if the given identifier is a keyword and returns the corresponding token type. Returns token.IDENT for non-keywords.
Types ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer performs lexical analysis on the input string, producing a stream of tokens.
func (*Lexer) RestoreState ¶
func (l *Lexer) RestoreState(s LexerState)
RestoreState rewinds the lexer to a previously saved state.
func (*Lexer) SaveState ¶
func (l *Lexer) SaveState() LexerState
SaveState returns a snapshot of the lexer's current position.
Click to show internal directories.
Click to hide internal directories.