tiny.python.syntax
Defined in tiny.python.
The second stage of the package reads the token list and builds the program's syntax tree: a list of statements, whose expressions are trees of operators and operands.
API (6)
Actions
Public operations.
parse: Builds the syntax tree of a program from its source text and the tokens made from that text.
Types and contracts
Public types and contracts.
Expression: One expression, as a tagged union with one tag per kind of expression.Program: The syntax tree of one program: its top-level statements and the arena that holds every node.Statement: One statement of the subset, as a tagged union with one tag per kind of statement.
Namespaces
Public namespaces.
ast: A Python program in the package's subset parses into a syntax tree.parser: The parser reads the token list of a Python program and builds its syntax tree: a list of statements whose expressions are trees of operators and operands.
Source
Source: lib/python/src/root.zig:89
zig
pub const syntax = @import("syntax/root.zig");Source: lib/python/src/syntax/root.zig
zig
//! The second stage of the package reads the token list and builds the program's syntax tree: a//! list of statements, whose expressions are trees of operators and operands. The compiler needs//! the program's structure with precedence and block nesting already settled, so it can emit//! instructions in one walk over the tree.//!//! One file, `ast`, defines the tree's types. The other file, `parser`, builds the tree through one//! function, `parse`. The namespace re-exports `Program`, `Statement` and `Expression` from `ast`,//! and `parse` from `parser`. The package's `execute` calls `parse` right after `tokenize`. The//! compiler walks the `Program` that `parse` returns.pub const ast = @import("ast.zig");pub const parser = @import("parser.zig");pub const Program = ast.Program;pub const Statement = ast.Statement;pub const Expression = ast.Expression;pub const parse = parser.parse;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |