Crate ast

Source
Expand description

§Abstract Syntax Tree

The AST is a syntactical representation of a program. It is the output of the parser.

This AST doesn’t have any semantic information. For example, it doesn’t know the different types of binary operations (arithmetic, logical, etc.). It just sees <OPERAND> <OPERATOR> <OPERAND>.

We try to presserve all the syntactic information of the program (semicolons, parenthesis, etc.), and we don’t make up things that aren’t there.

For example, see ItemKind::Function. Its return type is an Option, beacuse this program is syntactically correct:

fn foo() { }

but this one is also correct:

fn foo() -> int { ... }

So the AST doesn’t infer anything. It’s job is to represent the input program as faithfully as possible. That’s why the return type is optional, beacuse it can be ommited.

Later, we’ll lower this AST to a HIR Tree, which will desugar some things, like return types. It’ll also remove parenthesis, since their only job is to explicit the precedence of operations, and they become useless after building the AST.

Re-exports§

pub use expr::Expression;
pub use stmt::Statement;
pub use visitor::Visitor;
pub use item::*;

Modules§

expr
Expressions
item
stmt
Statements
types
visitor

Structs§

Block
Parenthesized
Path
Symbol
Identifies an interned string.