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.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/modelica-parser-lalrpop/src/ast.rs b/modelica-parser-lalrpop/src/ast.rs
index addb90f..e367b10 100644
--- a/modelica-parser-lalrpop/src/ast.rs
+++ b/modelica-parser-lalrpop/src/ast.rs
@@ -7,7 +7,7 @@ use std::collections::HashMap;
// A valid .mo file will be a sequence of these
#[derive(Clone, PartialEq)]
pub enum ModelicaCode {
- Class, // unimpl
+ Class, // unimpl; generic
Model(ModelicaModel),
Record, // unimpl
Block(ModelicaBlock),
@@ -39,8 +39,8 @@ pub struct ModelicaBlock {
pub name: String,
pub description: Option<String>,
pub component_clauses: Vec<ComponentClause>,
- pub public_component_clauses: Option<Vec<ComponentClause>>,
- pub protected_component_clauses: Option<Vec<ComponentClause>>,
+ pub public_component_clauses: Vec<ComponentClause>,
+ pub protected_component_clauses: Vec<ComponentClause>,
pub equations: Vec<SimpleEquation>,
pub connections: Vec<Connection>,
pub extends: Vec<String>,
@@ -88,7 +88,7 @@ pub struct ComponentDeclaration {
pub dimensions: Option<Vec<i64>>,
pub value: Option<Expr>,
pub quantity: Option<String>,
- pub units: Option<String>,
+ pub mods: HashMap<String, Expr>,
pub description: Option<String>,
}
@@ -99,7 +99,7 @@ pub struct Component {
pub specifier: String,
pub name: String,
pub value: Option<Expr>,
- pub units: Option<String>,
+ pub mods: HashMap<String, Expr>,
pub description: Option<String>,
}
@@ -120,6 +120,7 @@ pub enum Expr {
Integer(i64),
Float(f64),
Boolean(bool),
+ StringLiteral(String),
Ident(String),
Der(Box<Expr>),
Sign(Box<Expr>),
@@ -172,7 +173,7 @@ impl ModelicaModel {
specifier: clause.specifier.clone(),
name: dec.name.clone(),
value: dec.value.clone(),
- units: dec.units.clone(),
+ mods: dec.mods.clone(),
description: dec.description.clone(),
}))
}
@@ -237,7 +238,7 @@ impl Expr {
pub fn identifiers(&self) -> Vec<String> {
use self::Expr::*;
match *self {
- Integer(_) | Float(_) | Boolean(_) => vec![],
+ Integer(_) | Float(_) | Boolean(_) | StringLiteral(_) => vec![],
Ident(ref s) => vec![s.clone()],
Der(ref e) | Sign(ref e) => e.identifiers(),
MathUnaryExpr(_, ref e) => e.identifiers(),
@@ -342,6 +343,7 @@ impl Debug for Expr {
Integer(e) => write!(fmt, "{}", e),
Float(e) => write!(fmt, "{}", e),
Boolean(e) => write!(fmt, "{}", e),
+ StringLiteral(ref e) => write!(fmt, "\"{}\"", e),
Ident(ref e) => write!(fmt, "{}", e),
Der(ref e) => write!(fmt, "der({:?})", e),
Sign(ref e) => write!(fmt, "sign({:?})", e),