From 105db26ee52763474f014f86655c4ebc3830f63c Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 18 Dec 2016 13:17:45 -0800 Subject: higher-level modelica parsing AST structs --- modelica-parser-lalrpop/src/ast.rs | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) 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, + pub children: Vec, +} + +#[derive(Clone, PartialEq)] +pub struct ModelicaType { + pub name: String, + pub description: Option, + pub component: ComponentDeclaration, +} + +#[derive(Clone, PartialEq)] +pub struct ModelicaBlock { + pub name: String, + pub description: Option, + pub component_clauses: Vec, + pub public_component_clauses: Option>, + pub protected_component_clauses: Option>, + pub equations: Vec, + pub connections: Vec, + pub extends: Vec, +} + +#[derive(Clone, PartialEq)] +pub struct ModelicaConnector { + pub name: String, + pub description: Option, + pub component_clauses: Vec, +} + #[derive(Clone, PartialEq)] pub struct ModelicaModel { pub name: String, -- cgit v1.2.3