diff options
Diffstat (limited to 'src/modelica_parser.lalrpop')
-rw-r--r-- | src/modelica_parser.lalrpop | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/modelica_parser.lalrpop b/src/modelica_parser.lalrpop index 1b7861b..6a1ceaf 100644 --- a/src/modelica_parser.lalrpop +++ b/src/modelica_parser.lalrpop @@ -33,11 +33,17 @@ pub model: ModelicaModel = { ModelicaModel { name:n, components: cd, connections: cc, equations: se, extends: vec![] }, }; +value_declaration: Expr = { + "=" <value:expr> => value +}; + +units_declaration: String = { + "(" "unit" "=" <units:string_literal> ")" => units +}; + component_declaration: Component = { - <prefix:component_prefix?> <specifier:identifier> <name:identifier> string_literal? ";" => - Component { prefix:prefix, specifier:specifier, name:name}, - <prefix:component_prefix?> <specifier:identifier> <name:identifier> "=" <value:expr> string_literal? ";" => - Component { prefix:prefix, specifier:specifier, name:name}, + <prefix:component_prefix?> <specifier:identifier> <name:identifier> <units:units_declaration?> <value:value_declaration?> <desc:string_literal?> ";" => + Component { prefix:prefix, specifier:specifier, name:name, description:desc, value:value, units:units }, }; component_prefix: ComponentPrefix = { |