Skip to content

Commit

Permalink
Added support for quoting using the Code keyword.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1006 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Sep 25, 2003
1 parent 78eb02b commit 323b44a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions modelica_parser/src/modelica_lexer.g
Expand Up @@ -22,6 +22,7 @@ tokens {
ANNOTATION = "annotation" ;
BLOCK = "block" ;
BOUNDARY = "boundary" ;
CODE = "Code" ;
CLASS = "class" ;
CONNECT = "connect" ;
CONNECTOR = "connector" ;
Expand Down
60 changes: 60 additions & 0 deletions modelica_parser/src/modelica_parser.g
Expand Up @@ -23,6 +23,13 @@ tokens {
ARGUMENT_LIST;
CLASS_DEFINITION ;
CLASS_MODIFICATION;
CODE_EXPRESSION;
CODE_MODIFICATION;
CODE_ELEMENT;
CODE_EQUATION;
CODE_INITIALEQUATION;
CODE_ALGORITHM;
CODE_INITIALALGORITHM;
COMMENT;
DECLARATION ;
DEFINITION ;
Expand Down Expand Up @@ -488,6 +495,7 @@ connector_ref_2 :
expression :
( if_expression
| simple_expression
| code_expression
)
;

Expand Down Expand Up @@ -534,6 +542,58 @@ simple_expression ! :
}
}
;
/* Code quotation mechanism */
code_expression ! :
CODE LPAR ((expression RPAR)=> e:expression | m:modification | el:element
| eq:code_equation_clause | ieq:code_initial_equation_clause
| alg:code_algorithm_clause | ialg:code_initial_algorithm_clause
) RPAR
{
if (#e) {
#code_expression = #([CODE_EXPRESSION, "CODE_EXPRESSION"],#e);
} else if (#m) {
#code_expression = #([CODE_MODIFICATION, "CODE_MODIFICATION"],#m);
} else if (#el) {
#code_expression = #([CODE_ELEMENT, "CODE_ELEMENT"],#el);
} else if (#eq) {
#code_expression = #([CODE_EQUATION, "CODE_EQUATION"],#eq);
} else if (#ieq) {
#code_expression = #([CODE_INITIALEQUATION, "CODE_EQUATION"],#ieq);
} else if (#alg) {
#code_expression = #([CODE_ALGORITHM, "CODE_ALGORITHM"],#alg);
} else if (#ialg) {
#code_expression = #([CODE_INITIALALGORITHM, "CODE_ALGORITHM"],#ialg);
}
}
;

code_equation_clause :
( EQUATION^ (equation SEMICOLON! | annotation SEMICOLON! )* )
;

code_initial_equation_clause :
{ LA(2)==EQUATION}?
INITIAL! ec:code_equation_clause
{
#code_initial_equation_clause = #([INITIAL_EQUATION,"INTIAL_EQUATION"], ec);
}
;

code_algorithm_clause :
ALGORITHM^ (algorithm SEMICOLON! | annotation SEMICOLON!)*
;
code_initial_algorithm_clause :
{ LA(2) == ALGORITHM }?
INITIAL! ALGORITHM^
(algorithm SEMICOLON!
|annotation SEMICOLON!
)*
{
#code_initial_algorithm_clause = #([INITIAL_ALGORITHM,"INTIAL_ALGORITHM"], #code_initial_algorithm_clause);
}
;

/* End Code quotation mechanism */

logical_expression :
logical_term ( OR^ logical_term )*
Expand Down

0 comments on commit 323b44a

Please sign in to comment.