pub trait ExpressionParser {
// Required methods
fn current_token(&self) -> &Token;
fn advance(&mut self);
fn peek(&self) -> Option<&Token>;
fn is_at_end(&self) -> bool;
fn consume(&mut self, expected: Token) -> Result<(), String>;
fn parse_identifier(&mut self) -> Result<String, String>;
}
Expand description
Trait for expression parsers This allows us to modularize expression parsing while maintaining consistency
Required Methods§
Sourcefn current_token(&self) -> &Token
fn current_token(&self) -> &Token
Get the current token
Sourcefn consume(&mut self, expected: Token) -> Result<(), String>
fn consume(&mut self, expected: Token) -> Result<(), String>
Consume a specific token or return error
Sourcefn parse_identifier(&mut self) -> Result<String, String>
fn parse_identifier(&mut self) -> Result<String, String>
Parse an identifier and return its name