lib/python/src/syntax/root.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 //! The second stage of the package reads the token list and builds the program's syntax tree: a
 2 //! list of statements, whose expressions are trees of operators and operands. The compiler needs
 3 //! the program's structure with precedence and block nesting already settled, so it can emit
 4 //! instructions in one walk over the tree.
 5 //!
 6 //! One file, `ast`, defines the tree's types. The other file, `parser`, builds the tree through one
 7 //! function, `parse`. The namespace re-exports `Program`, `Statement` and `Expression` from `ast`,
 8 //! and `parse` from `parser`. The package's `execute` calls `parse` right after `tokenize`. The
 9 //! compiler walks the `Program` that `parse` returns.
10 pub const ast = @import("ast.zig");
11 pub const parser = @import("parser.zig");
12 
13 pub const Program = ast.Program;
14 pub const Statement = ast.Statement;
15 pub const Expression = ast.Expression;
16 pub const parse = parser.parse;