aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/src
diff options
context:
space:
mode:
Diffstat (limited to 'modelica-parser-lalrpop/src')
-rw-r--r--modelica-parser-lalrpop/src/ast.rs3
-rw-r--r--modelica-parser-lalrpop/src/parser.lalrpop3
2 files changed, 5 insertions, 1 deletions
diff --git a/modelica-parser-lalrpop/src/ast.rs b/modelica-parser-lalrpop/src/ast.rs
index f1e7d93..317944b 100644
--- a/modelica-parser-lalrpop/src/ast.rs
+++ b/modelica-parser-lalrpop/src/ast.rs
@@ -103,6 +103,7 @@ pub enum MathUnaryFunc {
pub enum BinOperator {
Multiply,
Divide,
+ Exponentiate,
Add,
Subtract,
}
@@ -313,6 +314,8 @@ impl Debug for BinOperator {
match *self {
Multiply => write!(fmt, "*"),
Divide => write!(fmt, "/"),
+ // TODO: this doesn't really work here
+ Exponentiate => write!(fmt, "^"),
Add => write!(fmt, "+"),
Subtract => write!(fmt, "-"),
}
diff --git a/modelica-parser-lalrpop/src/parser.lalrpop b/modelica-parser-lalrpop/src/parser.lalrpop
index cb59a82..2d2469c 100644
--- a/modelica-parser-lalrpop/src/parser.lalrpop
+++ b/modelica-parser-lalrpop/src/parser.lalrpop
@@ -161,7 +161,8 @@ factor: Expr = {
<lhs:factor> "/" <rhs:term> =>
Expr::BinExpr(BinOperator::Divide, Box::new(lhs), Box::new(rhs)),
<lhs:factor> "^" <rhs:term> =>
- Expr::BinExpr(BinOperator::Divide, Box::new(lhs), Box::new(rhs)),
+ Expr::BinExpr(BinOperator::Exponentiate, Box::new(lhs), Box::new(rhs)),
+ // TODO: this could be a "negate" unary op?
"-" <t:term> =>
Expr::BinExpr(BinOperator::Multiply, Box::new(Expr::Integer(-1)), Box::new(t)),
term,