pub struct ParsedFile { /* private fields */ }Expand description
An owned typed CST together with the original input.
ParsedFile::from_source selects the Tree-sitter adapter, while
ParsedFile::from_source_native selects the direct precedence parser. After
parsing, callers may mutate Self::cst_mut or use Self::edit, then
project the resulting tree through Self::token_stream or
Self::to_source.
The original string is retained as an immutable snapshot for diagnostics.
Current emission is normalized by Lex; it will become lossless as
trivia ownership is completed in the typed graph.
Implementations§
Source§impl ParsedFile
impl ParsedFile
Sourcepub fn from_source(source: impl Into<String>) -> Result<Self, ParseError>
pub fn from_source(source: impl Into<String>) -> Result<Self, ParseError>
Parses source with the Tree-sitter adapter.
§Errors
Returns ParseError when Tree-sitter rejects the source or typed
reconstruction fails.
Sourcepub fn from_source_native(
source: impl Into<String>,
) -> Result<Self, NativeParseError>
pub fn from_source_native( source: impl Into<String>, ) -> Result<Self, NativeParseError>
Parses source with the native precedence parser.
§Errors
Returns NativeParseError when lexing or native parsing fails.
Sourcepub fn original_source(&self) -> &str
pub fn original_source(&self) -> &str
Returns the input snapshot exactly as supplied to the parser.
Sourcepub fn cst(&self) -> &SourceFile
pub fn cst(&self) -> &SourceFile
Borrows the generated typed CST root.
Sourcepub fn cst_mut(&mut self) -> &mut SourceFile
pub fn cst_mut(&mut self) -> &mut SourceFile
Mutably borrows the generated typed CST root.
Sourcepub fn edit(self, edit: impl FnOnce(&mut SourceFile)) -> Self
pub fn edit(self, edit: impl FnOnce(&mut SourceFile)) -> Self
Applies an edit and returns the file for further method chaining.
Sourcepub fn into_cst(self) -> SourceFile
pub fn into_cst(self) -> SourceFile
Consumes the facade and returns its generated typed CST.
Sourcepub fn token_stream(&self) -> TokenStream
pub fn token_stream(&self) -> TokenStream
Flattens the current CST into one token stream.
Sourcepub fn pretty_tokens(&self) -> String
pub fn pretty_tokens(&self) -> String
Formats the current raw token representation as a recursively flattened table with explicit group boundaries.
Sourcepub fn pretty_cst(&self) -> String
pub fn pretty_cst(&self) -> String
Formats the complete generated typed CST as a Unicode tree.
Sourcepub fn pretty_report(&self) -> PrettyReport<'_>
pub fn pretty_report(&self) -> PrettyReport<'_>
Builds a combined source, flat-token, and typed-CST inspection report.
Sourcepub fn print_pretty(&self) -> Result<()>
pub fn print_pretty(&self) -> Result<()>
Prints the combined report to standard output, enabling ANSI styling only when standard output is an interactive terminal.
§Errors
Returns an I/O error when standard output cannot be written.
Trait Implementations§
Source§impl AsMut<SourceFile> for ParsedFile
impl AsMut<SourceFile> for ParsedFile
Source§fn as_mut(&mut self) -> &mut SourceFile
fn as_mut(&mut self) -> &mut SourceFile
Source§impl AsRef<SourceFile> for ParsedFile
impl AsRef<SourceFile> for ParsedFile
Source§fn as_ref(&self) -> &SourceFile
fn as_ref(&self) -> &SourceFile
Source§impl Debug for ParsedFile
impl Debug for ParsedFile
Source§impl Display for ParsedFile
impl Display for ParsedFile
Source§impl Lex for ParsedFile
impl Lex for ParsedFile
Source§fn to_tokens(&self, output: &mut TokenStream)
fn to_tokens(&self, output: &mut TokenStream)
output.