Skip to content

Commit

Permalink
unary operation negate parsing done
Browse files Browse the repository at this point in the history
  • Loading branch information
nulluser committed Jun 8, 2024
1 parent d0a6a43 commit 1c4b426
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/frontend/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::process;
use crate::frontend::ast::{BinaryOp, Program, Property};

use super::{
ast::{Expr, Literal, Stmt},
ast::{Expr, Literal, Stmt, UnaryOp},
lexer::{tokenize, Keyword, Operator, Symbol, Token},
};

Expand Down Expand Up @@ -368,6 +368,10 @@ impl Parser {
Token::Identifier(name) => Expr::Identifier(name.to_string()) as Expr,
Token::IntegerLiteral(integer) => Expr::Literal(Literal::Integer(integer)) as Expr,
Token::FloatLiteral(float) => Expr::Literal(Literal::Float(float)) as Expr,
Token::Operator(Operator::Not) => {
let expr = self.parse_call_member_expr();
Expr::UnaryOp(UnaryOp::Negate, Box::new(expr))
}
// Token::StringLiteral(_) => todo!(),
// Token::Operator(_) => todo!(),
Token::Symbol(Symbol::LeftParen) => {
Expand Down

0 comments on commit 1c4b426

Please sign in to comment.