Skip to content

Commit

Permalink
Fix unary op parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed Oct 2, 2024
1 parent e3fd2a0 commit c17060e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/gui/src/expression_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ fn eval_expr(lexer: &mut LexerWrapper, min_binding_power: usize) -> Result<f64,
}
Ok(res)
}
Some(Token::Number(value)) => Ok(value),
Some(Token::Number(value)) => {
lexer.advance()?;
Ok(value)
}
Some(Token::Plus) => {
lexer.advance()?;
let inner_value = eval_expr(lexer, prefix_binding_power(&Token::Plus))?;
Expand All @@ -136,8 +139,6 @@ fn eval_expr(lexer: &mut LexerWrapper, min_binding_power: usize) -> Result<f64,
_ => Err(ParseError::new("Invalid left-hand side")),
}?;

lexer.advance()?;

loop {
let op = match lexer.cur {
Some(token) => match token {
Expand Down

0 comments on commit c17060e

Please sign in to comment.