diff options
Diffstat (limited to 'src/modelica_ast.rs')
-rw-r--r-- | src/modelica_ast.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/modelica_ast.rs b/src/modelica_ast.rs index ceca11d..68eafaf 100644 --- a/src/modelica_ast.rs +++ b/src/modelica_ast.rs @@ -1,7 +1,8 @@ use std::fmt::{Debug, Formatter, Error}; -pub struct Model { +#[derive(PartialEq)] +pub struct ModelicaModel { pub name: String, pub components: Vec<Component>, pub equations: Vec<SimpleEquation>, @@ -9,7 +10,7 @@ pub struct Model { pub extends: Vec<String>, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq)] pub enum ComponentPrefix { // incomplete: eg, can be parameter and input Flow, @@ -21,23 +22,26 @@ pub enum ComponentPrefix { Constant, } +#[derive(PartialEq)] pub struct Component { pub prefix: Option<ComponentPrefix>, pub specifier: String, pub name: String, } -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct Connection { pub a: String, pub b: String, } +#[derive(PartialEq)] pub struct SimpleEquation { pub lhs: Expr, pub rhs: Expr, } +#[derive(PartialEq)] pub enum Expr { Integer(i64), Float(f64), @@ -47,7 +51,7 @@ pub enum Expr { BinExpr(BinOperator, Box<Expr>, Box<Expr>), } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq)] pub enum BinOperator { Multiply, Divide, @@ -57,7 +61,7 @@ pub enum BinOperator { //// Debug Implementations -impl Debug for Model { +impl Debug for ModelicaModel { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { try!(write!(fmt, "model {}\n", self.name)); for e in self.extends.iter() { |