Creating a Compiler for Compost using Rust, Part 2: Syntactic Analysis
In the previous post, I described how I implemented lexical analysis for Compost. The next phase in compilation is syntactic analysis, which turns the string of tokens into an ‘abstract syntax tree’. It also throws meaningful errors when wrong syntax is used. The Abstract Syntax Tree An abstract syntax tree (AST) represents the code at the level of statements and expressions. Every type of statement and expression has its own data structure, which can contain other statements or expressions, forming a tree of data structures....