diff options
Diffstat (limited to 'src/taiga.lalrpop')
-rw-r--r-- | src/taiga.lalrpop | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/taiga.lalrpop b/src/taiga.lalrpop index 6aedf42..68238eb 100644 --- a/src/taiga.lalrpop +++ b/src/taiga.lalrpop @@ -8,10 +8,24 @@ pub Program: ast::Program = { }; Expression: Box<ast::WithLocation<ast::Expression>> = { - <e1:Expression> "=" <e2:ExpressionCmp> => Box::new(e1.join_map(*e2, |v1, v2| { + <e1:Expression> "&&" <e2:ExpressionEq> => Box::new(e1.join_map(*e2, |v1, v2| { + ast::Expression::BinOp(ast::BinOp::And, Box::new(v1), Box::new(v2)) + })), + <e1:Expression> "||" <e2:ExpressionEq> => Box::new(e1.join_map(*e2, |v1, v2| { + ast::Expression::BinOp(ast::BinOp::Or, Box::new(v1), Box::new(v2)) + })), + <l: @L> "!" <e: ExpressionEq> <r: @R> => Box::new(WithLocation::new( + ast::Expression::UnaryOp(ast::UnaryOp::Not, e), + l, r + )), + <ExpressionEq> => <>, +}; + +ExpressionEq: Box<ast::WithLocation<ast::Expression>> = { + <e1:ExpressionEq> "=" <e2:ExpressionCmp> => Box::new(e1.join_map(*e2, |v1, v2| { ast::Expression::BinOp(ast::BinOp::Eq, Box::new(v1), Box::new(v2)) })), - <e1:Expression> "!=" <e2:ExpressionCmp> => Box::new(e1.join_map(*e2, |v1, v2| { + <e1:ExpressionEq> "!=" <e2:ExpressionCmp> => Box::new(e1.join_map(*e2, |v1, v2| { ast::Expression::BinOp(ast::BinOp::Neq, Box::new(v1), Box::new(v2)) })), <ExpressionCmp> => <>, |