Skip to content

Commit

Permalink
starting indomain implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Feb 10, 2016
1 parent 9090acd commit 6defd95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -463,6 +463,7 @@ uniontype Equation "Information on one (kind) of equation, different constructor
record EQ_EQUALS
Exp leftSide "leftSide" ;
Exp rightSide "rightSide Connect stmt" ;
Option<ComponentRef> domain "domain for PDEs" ;
end EQ_EQUALS;

record EQ_CONNECT
Expand Down
2 changes: 2 additions & 0 deletions Parser/BaseModelica_Lexer.g
Expand Up @@ -154,6 +154,7 @@ END_PARFOR;
// ---------
FIELD;
INDOMAIN;
// ---------
// Operators
Expand Down Expand Up @@ -298,6 +299,7 @@ CONSTRAINT : 'constraint' { if (!optimica_enabled()) $type = IDENT; };
FIELD : 'field';
NONFIELD : 'nonfield';
INDOMAIN : 'indomain';
/*------------------------------------------------------------------
* LEXER RULES
Expand Down
10 changes: 7 additions & 3 deletions Parser/Modelica.g
Expand Up @@ -896,12 +896,16 @@ assign_clause_a returns [void* ast]
;

equality_or_noretcall_equation returns [void* ast]
@init { ass = 0; e1 = 0; ass = 0; e2.ast = 0; } :
@init { ass = 0; e1 = 0; ass = 0; e2.ast = 0; dom = 0;} :
e1=simple_expression
( (EQUALS | ass=ASSIGN) e2=expression[metamodelica_enabled()]
( (EQUALS | ass=ASSIGN) e2=expression[metamodelica_enabled()] (INDOMAIN dom=component_reference)
{
modelicaParserAssert(ass==0,"Equations can not contain assignments (':='), use equality ('=') instead", equality_or_noretcall_equation, $ass->line, $ass->charPosition+1, $ass->line, $ass->charPosition+2);
$ast = Absyn__EQ_5fEQUALS(e1,e2.ast);
if (dom = 0) {
$ast = Absyn__EQ_5fEQUALS(e1,e2.ast,mmc_mk_none());
} else {
$ast = Absyn__EQ_5fEQUALS(e1,e2.ast,mmc_mk_some(dom));
}
}
| {LA(1) != EQUALS && LA(1) != ASSIGN}? /* It has to be a CALL */
{
Expand Down

0 comments on commit 6defd95

Please sign in to comment.