Skip to content

Commit

Permalink
Parser: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest1338 committed Jan 21, 2025
1 parent 0aef493 commit 771242c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ impl<'a> Parser<'a> {
_ => unreachable!(),
};
self.iter.next(); // Consume operator

let right = self.parse_primary()?;

left = Expr::BinExpr(Box::new(BinExpr {
lhs: left,
kind: operator,
Expand Down Expand Up @@ -413,10 +415,12 @@ impl<'a> Parser<'a> {
/// Parses a complete program into an AST
pub fn parse(&mut self) -> Result<Ast, String> {
let mut ast = Vec::new();
while let Some(_token) = self.iter.peek() {

while self.iter.peek().is_some() {
let expr = self.parse_expr()?;
ast.push(expr);
}

Ok(ast)
}
}

0 comments on commit 771242c

Please sign in to comment.