pub struct Parser<'src> { /* private fields */ }Implementations§
Source§impl<'src> Parser<'src>
impl<'src> Parser<'src>
pub fn new(source: &'src str) -> Self
pub fn with_name(source: &'src str, name: &str) -> Self
pub fn into_source_metadata(self) -> SourceMetadata
Sourcepub fn parse_single_expr(&mut self) -> Result<Expr, ParseError>
pub fn parse_single_expr(&mut self) -> Result<Expr, ParseError>
Parse a single expression from the source string.
Expects the entire input to be consumed; returns an error if there are trailing tokens after the expression.
§Errors
Returns a ParseError if the source is not a valid expression
or if there are unexpected trailing tokens.
Sourcepub fn parse_standalone_unit_expr(&mut self) -> Result<UnitExpr, ParseError>
pub fn parse_standalone_unit_expr(&mut self) -> Result<UnitExpr, ParseError>
Parse a standalone unit expression (e.g., m/s^2, kg * m / s^2).
Expects the entire input to be consumed; returns an error if there are trailing tokens after the unit expression.
§Errors
Returns a ParseError if the source is not a valid unit expression.
Sourcepub fn parse_standalone_dim_expr(&mut self) -> Result<DimExpr, ParseError>
pub fn parse_standalone_dim_expr(&mut self) -> Result<DimExpr, ParseError>
Parse a standalone dimension expression (e.g., Length / Time).
Expects the entire input to be consumed; returns an error if there are trailing tokens after the dimension expression.
§Errors
Returns a ParseError if the source is not a valid dimension expression.
Sourcepub fn parse_file(&mut self) -> Result<File, ParseError>
pub fn parse_file(&mut self) -> Result<File, ParseError>
Parse the full source file into a File AST node.
§Errors
Returns a ParseError if the source contains invalid syntax.