diff options
-rw-r--r-- | modelica-parser-lalrpop/src/ast.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modelica-parser-lalrpop/src/ast.rs b/modelica-parser-lalrpop/src/ast.rs index 9a9f02d..2c55782 100644 --- a/modelica-parser-lalrpop/src/ast.rs +++ b/modelica-parser-lalrpop/src/ast.rs @@ -3,6 +3,56 @@ use std::clone::Clone; use std::fmt::{Debug, Formatter, Error}; use std::collections::HashMap; +// This represents a block of Modelica code. +// A valid .mo file will be a sequence of these +#[derive(Clone, PartialEq)] +pub enum ModelicaCode { + Class, // unimpl + Model(ModelicaModel), + Record, // unimpl + Block(ModelicaBlock), + Connector(ModelicaConnector), + Type(ModelicaType), + Package(ModelicaPackage), + Function, // unimpl +} + +// A package is basically a namespace; they can be nested and contain any other +// code chunks (models, etc). +// They are optional; models don't need to live in a package to be valid. +#[derive(Clone, PartialEq)] +pub struct ModelicaPackage { + pub name: String, + pub description: Option<String>, + pub children: Vec<ModelicaCode>, +} + +#[derive(Clone, PartialEq)] +pub struct ModelicaType { + pub name: String, + pub description: Option<String>, + pub component: ComponentDeclaration, +} + +#[derive(Clone, PartialEq)] +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 equations: Vec<SimpleEquation>, + pub connections: Vec<Connection>, + pub extends: Vec<String>, +} + +#[derive(Clone, PartialEq)] +pub struct ModelicaConnector { + pub name: String, + pub description: Option<String>, + pub component_clauses: Vec<ComponentClause>, +} + #[derive(Clone, PartialEq)] pub struct ModelicaModel { pub name: String, |