aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/src/parser.lalrpop
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-12-18 14:15:18 -0800
committerbnewbold <bnewbold@robocracy.org>2016-12-18 14:15:18 -0800
commitfc0e67f5d7d092e5b37d103d2d106733228ddf89 (patch)
tree044479c27e226b0aae6db0c4507c738aa9d0bf59 /modelica-parser-lalrpop/src/parser.lalrpop
parent643b7ef94bdf507def6cb92575c1af73ba5d691f (diff)
downloadmodelthing-fc0e67f5d7d092e5b37d103d2d106733228ddf89.tar.gz
modelthing-fc0e67f5d7d092e5b37d103d2d106733228ddf89.zip
parser: booleans and arrays
Diffstat (limited to 'modelica-parser-lalrpop/src/parser.lalrpop')
-rw-r--r--modelica-parser-lalrpop/src/parser.lalrpop6
1 files changed, 6 insertions, 0 deletions
diff --git a/modelica-parser-lalrpop/src/parser.lalrpop b/modelica-parser-lalrpop/src/parser.lalrpop
index a2c5d44..36aa07d 100644
--- a/modelica-parser-lalrpop/src/parser.lalrpop
+++ b/modelica-parser-lalrpop/src/parser.lalrpop
@@ -102,6 +102,7 @@ factor: Expr = {
term: Expr = {
integer => Expr::Integer(<>),
+ boolean => Expr::Boolean(<>),
float => Expr::Float(<>),
identifier => Expr::Ident(<>),
"der" "(" <e:expr> ")" => Expr::Der(Box::new(e)),
@@ -120,5 +121,10 @@ term: Expr = {
"log" "(" <e:expr> ")" => Expr::MathUnaryExpr(MathUnaryFunc::Log, Box::new(e)),
"log10" "(" <e:expr> ")" => Expr::MathUnaryExpr(MathUnaryFunc::Log10, Box::new(e)),
"(" <e:expr> ")" => e,
+ // Obviously a hack here, only supporting up to 4 elements in an array
+ "[" <e:expr> "]" => Expr::Array(vec![e]),
+ "[" <e1:expr> "," <e2:expr> "]" => Expr::Array(vec![e1, e2]),
+ "[" <e1:expr> "," <e2:expr> "," <e3:expr> "]" => Expr::Array(vec![e1, e2, e3]),
+ "[" <e1:expr> "," <e2:expr> "," <e3:expr> "," <e4:expr> "]" => Expr::Array(vec![e1, e2, e3, e4]),
};