pub struct TreeSitterParser { /* private fields */ }Expand description
A reusable Tree-sitter parser and direct typed-CST lowerer.
Implementations§
Source§impl TreeSitterParser
impl TreeSitterParser
Sourcepub fn new() -> Result<Self, ParseError>
pub fn new() -> Result<Self, ParseError>
Creates a parser loaded with the bundled Macaulay2 grammar.
§Errors
Returns ParseError::Language if Tree-sitter rejects the bundled
language definition.
Sourcepub fn parse_recovering(
&mut self,
source: &str,
) -> Result<Recovered<SourceFile, LexError>, ParseError>
pub fn parse_recovering( &mut self, source: &str, ) -> Result<Recovered<SourceFile, LexError>, ParseError>
Parses incomplete source while retaining syntax inside unclosed groups.
The parsing view is completed only for Tree-sitter; reconstructed nodes retain the original source spans and zero-width missing closers.
§Errors
Returns ParseError when source has a non-recoverable lexical or
grammatical failure, parsing is cancelled, or lowering fails.
Trait Implementations§
Source§impl Parser for TreeSitterParser
impl Parser for TreeSitterParser
Source§type Error = ParseError
type Error = ParseError
The backend-specific parse failure.
Source§fn parse_stream(
&mut self,
tokens: TokenStream,
) -> Result<SourceFile, Self::Error>
fn parse_stream( &mut self, tokens: TokenStream, ) -> Result<SourceFile, Self::Error>
Parses
tokens into one typed syntax target. Read moreAuto Trait Implementations§
impl Freeze for TreeSitterParser
impl RefUnwindSafe for TreeSitterParser
impl Send for TreeSitterParser
impl Sync for TreeSitterParser
impl Unpin for TreeSitterParser
impl UnsafeUnpin for TreeSitterParser
impl UnwindSafe for TreeSitterParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more