Writing an Interpreter: Implementation
Join the DZone community and get the full member experience.
Join For Free
Part 1 can be found here.
Lexer
The Lexer serves as the most basic element. Its primary function involves iterating through the characters present in the source code. It may combine certain characters to create a single token and subsequently generate a token object with its associated type. This object is then added to the resulting list.
More in-depth information regarding the implementation can be found here.
Parser
The parser is the most complex component of an interpreter. Before we delve into it, let’s understand the difference between an expression and a statement: