pub struct ImmutableSyntaxTree<N: Node> { /* private fields */ }Expand description
A canonical implementation of the SyntaxTree trait.
Parses a syntax grammar only and does not provides any reparse capabilities.
Use this interface when you need to build a syntax tree from already existing stream of tokens or a part of it.
Implementations§
Source§impl<N: Node> ImmutableSyntaxTree<N>
impl<N: Node> ImmutableSyntaxTree<N>
Sourcepub fn parse<'code>(
token_cursor: impl TokenCursor<'code, Token = <N as Node>::Token>,
) -> Self
pub fn parse<'code>( token_cursor: impl TokenCursor<'code, Token = <N as Node>::Token>, ) -> Self
An ImmutableSyntaxTree constructor.
The token_cursor parameter of type TokenCursor provides access
to the token stream that needs to be parsed.
You can get this cursor from a TokenBuffer, TokenStream, or any compilation unit type (e.g., Document).
See SourceCode::cursor function for details.
Sourcepub fn parse_with_observer<'code>(
token_cursor: impl TokenCursor<'code, Token = <N as Node>::Token>,
observer: &mut impl Observer<Node = N>,
) -> Self
pub fn parse_with_observer<'code>( token_cursor: impl TokenCursor<'code, Token = <N as Node>::Token>, observer: &mut impl Observer<Node = N>, ) -> Self
An extended constructor, where the additional parameter
observer specifies an Observer object into which the syntax parser
will report parsing steps.
One use case of the observer is to debug your parser. In particular, the DebugObserver prints each parsing step performed by the syntax parser to the stdout.