[−][src]Crate ra_ap_syntax
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::algo::InsertPosition; |
pub use crate::ast::AstNode; |
pub use crate::ast::AstToken; |
Modules
algo | FIXME: write short doc here |
ast | Abstract Syntax Tree, layered on top of untyped |
display | This module contains utilities for turning SyntaxNodes and HIR types into types that may be used to render in a UI. |
Macros
T | |
match_ast | Matches a |
Structs
AstPtr | Like |
GreenNode | Internal node in the immutable tree. It has other nodes and tokens as children. |
Parse |
|
SmolStr | A |
SourceFile | |
SyntaxError | Represents the result of unsuccessful tokenization, parsing or tree validation. |
SyntaxNodePtr | A pointer to a syntax node inside a file. It can be used to remember a specific node across reparses of the same file. |
SyntaxText | |
SyntaxTreeBuilder | |
TextRange | A range in text, represented as a pair of |
TextSize | A measure of text length. Also, equivalently, an index into text. |
Token | A token of Rust source. |
Enums
Direction | |
NodeOrToken | |
SyntaxKind | The kind of syntax node, e.g. |
TokenAtOffset | There might be zero, one or two leaves at a given offset. |
WalkEvent |
|
Functions
lex_single_syntax_kind | Returns |
lex_single_valid_syntax_kind | The same as |
tokenize | Break a string up into its component tokens. Beware that it checks for shebang first and its length contributes to resulting tokens offsets. |
Type Definitions
SyntaxElement | |
SyntaxElementChildren | |
SyntaxNode | |
SyntaxNodeChildren | |
SyntaxToken |