Crate ra_ap_syntax
source ·Expand description
Syntax Tree library used throughout the rust-analyzer.
Properties:
- easy and fast incremental re-parsing
- graceful handling of errors
- full-fidelity representation (any text can be precisely represented as a syntax tree)
For more information, see the RFC. Current implementation is inspired by the Swift one.
The most interesting modules here are syntax_node (which defines concrete
syntax tree) and ast (which defines abstract syntax tree on top of the
CST). The actual parser live in a separate parser crate, though the
lexer lives in this crate.
See api_walkthrough test in this file for a quick API tour!
Re-exports§
- pub use crate::ast::AstNode;
- pub use crate::ast::AstToken;
- pub use crate::ast::SourceFile;
Modules§
- Collection of assorted algorithms for syntax trees.
- Abstract Syntax Tree, layered on top of untypedSyntaxNodes
- Things which exist to solve practical issues, but which shouldn’t exist.
- Primitive tree editor, ed for trees.
- Utilities for validating string and char literals and turning them into values they represent.
- A set of utils methods to reuse on other abstraction levels
Macros§
- Formats arguments to aSmolStr, potentially without allocating.
- Matches aSyntaxNodeagainst anasttype.
Structs§
- LikeSyntaxNodePtr, but remembers the type of node.
- Internal node in the immutable tree. It has other nodes and tokens as children.
- Parseis the result of the parsing: a syntax tree and a collection of errors.
- ASmolStris a string type that has the following properties:
- Represents the result of unsuccessful tokenization, parsing or tree validation.
- A range in text, represented as a pair ofTextSize.
- A measure of text length. Also, equivalently, an index into text.
Enums§
- The kind of syntax node, e.g.IDENT,USE_KW, orSTRUCT.
- There might be zero, one or two leaves at a given offset.
- WalkEventdescribes tree walking process.
Type Aliases§
- A “pointer” to aSyntaxNode, via location in the source code.