diff options
Diffstat (limited to 'src/modelica_ast.rs')
-rw-r--r-- | src/modelica_ast.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/modelica_ast.rs b/src/modelica_ast.rs index 425993f..ceca11d 100644 --- a/src/modelica_ast.rs +++ b/src/modelica_ast.rs @@ -3,7 +3,7 @@ use std::fmt::{Debug, Formatter, Error}; pub struct Model { pub name: String, - pub variables: Vec<Component>, + pub components: Vec<Component>, pub equations: Vec<SimpleEquation>, pub connections: Vec<Connection>, pub extends: Vec<String>, @@ -63,16 +63,16 @@ impl Debug for Model { for e in self.extends.iter() { try!(write!(fmt, " extends {};\n", e)); } - for v in self.variables.iter() { + for v in self.components.iter() { try!(write!(fmt, " {:?};\n", v)); } try!(write!(fmt, "equation\n")); - for e in self.equations.iter() { - try!(write!(fmt, " {:?};\n", e)); - } for c in self.connections.iter() { try!(write!(fmt, " {:?};\n", c)); } + for e in self.equations.iter() { + try!(write!(fmt, " {:?};\n", e)); + } write!(fmt, "end {};\n", self.name) } } @@ -80,7 +80,7 @@ impl Debug for Model { impl Debug for ComponentPrefix { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { use self::ComponentPrefix::*; - write!(fmt, "{:?}", + write!(fmt, "{}", match *self { Flow => "flow", Stream => "stream", @@ -95,8 +95,12 @@ impl Debug for ComponentPrefix { impl Debug for Component { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { - write!(fmt, "{:?}{}", - self.prefix.unwrap(), + write!(fmt, "{}{} {}", + match self.prefix { + Some(p) => format!("{:?} ", p), + None => "".to_string(), + }, + self.specifier, self.name, ) } @@ -104,7 +108,7 @@ impl Debug for Component { impl Debug for Connection { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { - write!(fmt, "connect({:?}, {:?});", self.a, self.b) + write!(fmt, "connect({}, {})", self.a, self.b) } } |