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.
Structs§
- AstNodeList Iterator 
- AstSeparatedElement 
- AstSeparatedList Elements Iterator 
- AstSeparatedList Nodes Iterator 
- AstSeparatorIterator 
- BatchMutation 
- Checkpoint
- A checkpoint for maybe wrapping a node. See GreenNodeBuilder::checkpointfor details.
- NodeCache 
- Interner for GreenTokens and GreenNodes
- ParsedChildren 
- The parsed children of a node, not accounting for any missing children (required or optional)
- ParsedChildren Into Iterator 
- ParsedChildren Iterator 
- RawNodeSlots 
- 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.
- RawSyntaxKind 
- RawSyntaxKind is a type tag for each token or node.
- RawSyntaxNode 
- New-type wrapper around a GreenNode.
- RawSyntaxNode Ref 
- New-type wrapper to a reference of a GreenNode.
- RawSyntaxToken 
- New-type wrapper around a GreenToken. Allows third-party crates to access limited information on not yet fully constructed nodes.
- RawSyntaxToken Ref 
- New-type wrapper to a reference of a GreenToken
- SyntaxKind Set 
- Represents a set of SyntaxKind as a bitfield, with each bit representing whether the corresponding RawSyntaxKind value is contained in the set
- SyntaxNode Text 
- TextRange 
- A range in text, represented as a pair of TextSize.
- TextSize 
- A measure of text length. Also, equivalently, an index into text.
- TokenText 
- Reference to the text of a SyntaxToken without having to worry about the lifetime of &str.
- TreeBuilder 
- A builder for a syntax tree.
Enums§
- Direction
- FileSource Error 
- Errors around the construct of the source type
- NodeOrToken 
- SyntaxError 
- TokenAtOffset 
- There might be zero, one or two leaves at a given offset.
- WalkEvent 
- 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.
- AstNodeExt 
- AstNodeList 
- List of homogenous nodes
- AstNodeList Ext 
- AstNodeSlot 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
- AstSeparatedList 
- 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(,).
- AstSeparatedList Ext 
- BatchMutation Ext 
- SyntaxFactory 
- Factory for creating syntax nodes of a particular kind.
- SyntaxNode Cast 
- TextLen
- Primitives with a textual length that can be passed to TextSize::of.
Functions§
Type Aliases§
- RawSyntaxElement 
- RawSyntaxElement Ref 
- SyntaxResult 
- Specific result used when navigating nodes using AST APIs