diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-18 13:17:45 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-18 13:17:45 -0800 |
commit | 105db26ee52763474f014f86655c4ebc3830f63c (patch) | |
tree | d44d149737b8a3e2abeaab68ca4c5c59875074a2 | |
parent | c9db85ca1446ecd82cce4ac72a6b07ed92f9b209 (diff) | |
download | modelthing-105db26ee52763474f014f86655c4ebc3830f63c.tar.gz modelthing-105db26ee52763474f014f86655c4ebc3830f63c.zip |
higher-level modelica parsing AST structs
-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, |