Lexer
The lexer converts raw source code into tokens.
This process is called lexical analysis.
For:
let x = 10the input characters are grouped into:
LETIDENTIFIER("x")EQUALNUMBER(10)Lexer responsibilities
Section titled “Lexer responsibilities”Keywords
Section titled “Keywords”let const fn if else for while return true false null and or notOperators
Section titled “Operators”+ - * / % = == != > >= < <=Delimiters
Section titled “Delimiters”( ) { } [ ] , . :Strings
Section titled “Strings”"Hello"'Tanmoy'Numbers
Section titled “Numbers”12342.5Comments
Section titled “Comments”// This is a commentIdentifiers
Section titled “Identifiers”nameagemy_variableTokens preserve source information such as the token type, lexeme, literal value, line, and column.