Expand description
A generic library for lossless syntax trees.
See examples/s_expressions.rs for a tutorial.
Re-exports§
pub use crate::syntax::chain_trivia_pieces;pub use crate::syntax::trim_leading_trivia_pieces;pub use crate::syntax::trim_trailing_trivia_pieces;pub use crate::syntax::ChainTriviaPiecesIterator;pub use crate::syntax::Language;pub use crate::syntax::SendNode;pub use crate::syntax::SyntaxElement;pub use crate::syntax::SyntaxElementChildren;pub use crate::syntax::SyntaxKind;pub use crate::syntax::SyntaxList;pub use crate::syntax::SyntaxNode;pub use crate::syntax::SyntaxNodeChildren;pub use crate::syntax::SyntaxNodeOptionExt;pub use crate::syntax::SyntaxRewriter;pub use crate::syntax::SyntaxSlot;pub use crate::syntax::SyntaxSlots;pub use crate::syntax::SyntaxToken;pub use crate::syntax::SyntaxTriviaPiece;pub use crate::syntax::SyntaxTriviaPieceComments;pub use crate::syntax::TriviaPiece;pub use crate::syntax::TriviaPieceKind;pub use crate::syntax::VisitNodeSignal;
Modules§
- cursor
- Implementation of the cursors – API for convenient access to syntax trees.
- raw_
language - Provides a sample language implementation that is useful in API explanation or tests
- support
- syntax
Macros§
- declare_
node_ union - Declares a custom union AstNode type with an ungram-like syntax
- match_
ast - Matches a
SyntaxNodeagainst anasttype. - static_
assert
Structs§
- AstNode
List Iterator - AstSeparated
Element - AstSeparated
List Elements Iterator - AstSeparated
List Nodes Iterator - AstSeparator
Iterator - Batch
Mutation - Checkpoint
- A checkpoint for maybe wrapping a node. See
GreenNodeBuilder::checkpointfor details. - Node
Cache - Interner for GreenTokens and GreenNodes
- Parsed
Children - The parsed children of a node, not accounting for any missing children (required or optional)
- Parsed
Children Into Iterator - Parsed
Children Iterator - RawNode
Slots - Description of the slots of a node in combination with ParsedChildren. It stores for each slot if the node is present in ParsedChildren or not, allowing to generate a node with the right number of empty slots.
- RawSyntax
Kind - RawSyntaxKind is a type tag for each token or node.
- RawSyntax
Node - New-type wrapper around a
GreenNode. - RawSyntax
Node Ref - New-type wrapper to a reference of a
GreenNode. - RawSyntax
Token - New-type wrapper around a
GreenToken. Allows third-party crates to access limited information on not yet fully constructed nodes. - RawSyntax
Token Ref - New-type wrapper to a reference of a
GreenToken - Syntax
Kind Set - Represents a set of SyntaxKind as a bitfield, with each bit representing whether the corresponding RawSyntaxKind value is contained in the set
- Syntax
Node Text - Text
Range - A range in text, represented as a pair of
TextSize. - Text
Size - A measure of text length. Also, equivalently, an index into text.
- Token
Text - Reference to the text of a SyntaxToken without having to worry about the lifetime of
&str. - Tree
Builder - A builder for a syntax tree.
Enums§
- Direction
- File
Source Error - Errors around the construct of the source type
- Node
OrToken - Syntax
Error - Token
AtOffset - There might be zero, one or two leaves at a given offset.
- Walk
Event WalkEventdescribes tree walking process.
Traits§
- AstNode
- The main trait to go from untyped
SyntaxNodeto a typed ast. The conversion itself has zero runtime cost: ast and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself. - AstNode
Ext - AstNode
List - List of homogenous nodes
- AstNode
List Ext - AstNode
Slot Map - An AstNode that supports dynamic ordering of the fields it contains uses a
slot_mapto map the declared order of fields to the concrete order as parsed from the source content. Implementing this trait lets consumers - AstSeparated
List - List of nodes where every two nodes are separated by a token.
For example, the elements of an array where every two elements are separated by a comma token.
The list expects that the underlying syntax node has a slot for every node and separator
even if they are missing from the source code. For example, a list for
a bwhere the,separator is missing contains the slotsNode(a), Empty, Node(b). This also applies for missing nodes: the list for, b,must have the slotsEmpty, Token(,), Node(b), Token(,). - AstSeparated
List Ext - Batch
Mutation Ext - Syntax
Factory - Factory for creating syntax nodes of a particular kind.
- Syntax
Node Cast - TextLen
- Primitives with a textual length that can be passed to
TextSize::of.
Functions§
Type Aliases§
- RawSyntax
Element - RawSyntax
Element Ref - Syntax
Result - Specific result used when navigating nodes using AST APIs