From 957c2f75ceccfab3d8a8e546961db5f053876689 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 26 Dec 2016 00:03:07 -0800 Subject: radically simplify scope of parsing Parsing arbitrary files, packages, blocks, connectors, etc caused the compilation time for this parser to explode exponentially, and resulted in huge parser.rs and executable files. This commit rips out all those features. --- modelica-parser-lalrpop/src/parser.lalrpop | 86 +----------------------------- 1 file changed, 1 insertion(+), 85 deletions(-) (limited to 'modelica-parser-lalrpop/src/parser.lalrpop') diff --git a/modelica-parser-lalrpop/src/parser.lalrpop b/modelica-parser-lalrpop/src/parser.lalrpop index 442baca..94795c6 100644 --- a/modelica-parser-lalrpop/src/parser.lalrpop +++ b/modelica-parser-lalrpop/src/parser.lalrpop @@ -1,7 +1,6 @@ use std::str::FromStr; use std::collections::HashMap; -use ast::{ModelicaCode, ModelicaPackage, ModelicaBlock, ModelicaConnector, - ModelicaType, ModelicaModel, ComponentDeclaration, ModelicaRecord, +use ast::{ModelicaModel, ComponentDeclaration, ComponentClause, ComponentPrefix, Connection, SimpleEquation, Expr, BinOperator, MathUnaryFunc, collapse_components}; @@ -40,87 +39,10 @@ pub boolean: bool = { // Grammar -pub file: Vec = { - within_clause? => chunks, -}; - -pub modelica_code: ModelicaCode = { - model => ModelicaCode::Model(<>), - // TODO: class - record => ModelicaCode::Record(<>), - block => ModelicaCode::Block(<>), - connector => ModelicaCode::Connector(<>), - type_declaration => ModelicaCode::Type(<>), - package => ModelicaCode::Package(<>), - // TODO: function -}; - -pub package: ModelicaPackage = { - "package" - extends_clause* - - "end" identifier ";" => - ModelicaPackage { - name:n, - description:desc, - children:children, - }, -}; - -pub connector: ModelicaConnector = { - "connector" - - "end" identifier ";" => - ModelicaConnector { - name:n, - description:desc, - components: { collapse_components(&cpc) } }, -}; - -pub record: ModelicaRecord = { - "record" - - "end" identifier ";" => - ModelicaRecord { - name:n, - description:desc, - components: { collapse_components(&cpc) } }, -}; - -type_declaration: ModelicaType = { - "type" - "=" ";" => - ModelicaType { - name:n, - description:desc, - component:cpd, }, -}; - -pub block: ModelicaBlock = { - "block" - extends_clause* - - )?> - )?> - "equation" - - - "end" identifier ";" => - ModelicaBlock { - name:n, - description:desc, - components: { collapse_components(&cpc) }, - public_components: { collapse_components(&public.unwrap_or(vec![])) }, - protected_components: { collapse_components(&protected.unwrap_or(vec![])) }, - connections:cc, - equations:se }, -}; - pub model: ModelicaModel = { "partial"? "model" extends_clause* - connector* "equation" @@ -268,11 +190,5 @@ term: Expr = { "log" "(" ")" => Expr::MathUnaryExpr(MathUnaryFunc::Log, Box::new(e)), "log10" "(" ")" => Expr::MathUnaryExpr(MathUnaryFunc::Log10, Box::new(e)), "(" ")" => e, - // Obviously a hack here, only supporting up to 4 elements in an array - "[" "]" => Expr::Array(vec![e]), - "[" ";" "]" => Expr::Array(vec![e1, e2]), - "[" "," "]" => Expr::Array(vec![e1, e2]), - "[" "," "," "]" => Expr::Array(vec![e1, e2, e3]), - "[" "," "," "," "]" => Expr::Array(vec![e1, e2, e3, e4]), }; -- cgit v1.2.3