aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'modelica-parser-lalrpop/src/ast.rs')
-rw-r--r--modelica-parser-lalrpop/src/ast.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/modelica-parser-lalrpop/src/ast.rs b/modelica-parser-lalrpop/src/ast.rs
index 3b31072..addb90f 100644
--- a/modelica-parser-lalrpop/src/ast.rs
+++ b/modelica-parser-lalrpop/src/ast.rs
@@ -85,6 +85,7 @@ pub struct ComponentClause {
#[derive(Clone, PartialEq)]
pub struct ComponentDeclaration {
pub name: String,
+ pub dimensions: Option<Vec<i64>>,
pub value: Option<Expr>,
pub quantity: Option<String>,
pub units: Option<String>,
@@ -118,11 +119,13 @@ pub struct SimpleEquation {
pub enum Expr {
Integer(i64),
Float(f64),
+ Boolean(bool),
Ident(String),
Der(Box<Expr>),
Sign(Box<Expr>),
MathUnaryExpr(MathUnaryFunc, Box<Expr>),
BinExpr(BinOperator, Box<Expr>, Box<Expr>),
+ Array(Vec<Expr>),
}
#[derive(Copy, Clone, PartialEq)]
@@ -234,13 +237,20 @@ impl Expr {
pub fn identifiers(&self) -> Vec<String> {
use self::Expr::*;
match *self {
- Integer(_) | Float(_) => vec![],
+ Integer(_) | Float(_) | Boolean(_) => vec![],
Ident(ref s) => vec![s.clone()],
Der(ref e) | Sign(ref e) => e.identifiers(),
MathUnaryExpr(_, ref e) => e.identifiers(),
BinExpr(_, ref e1, ref e2) => {
union_strings(&e1.identifiers(), &e2.identifiers())
},
+ Array(ref el) => {
+ let mut all: Vec<String> = vec![];
+ for e in el {
+ all.append(&mut e.identifiers());
+ }
+ all
+ }
}
}
@@ -331,11 +341,20 @@ impl Debug for Expr {
match *self {
Integer(e) => write!(fmt, "{}", e),
Float(e) => write!(fmt, "{}", e),
+ Boolean(e) => write!(fmt, "{}", e),
Ident(ref e) => write!(fmt, "{}", e),
Der(ref e) => write!(fmt, "der({:?})", e),
Sign(ref e) => write!(fmt, "sign({:?})", e),
MathUnaryExpr(func, ref e) => write!(fmt, "{:?}({:?})", func, e),
BinExpr(op, ref l, ref r) => write!(fmt, "({:?} {:?} {:?})", l, op, r),
+ Array(ref el) => {
+ try!(write!(fmt, "["));
+ for e in el {
+ // XXX: not last comma
+ try!(write!(fmt, "{:?},", e));
+ }
+ write!(fmt, "]")
+ },
}
}
}