Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@717 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
henjo committed Feb 5, 2002
1 parent b26f324 commit 51b24d3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
12 changes: 8 additions & 4 deletions modelica_parser/src/modelica_lexer.g
Expand Up @@ -9,10 +9,11 @@ options {
class modelica_lexer extends Lexer;

options {
k=2;
charVocabulary = '\3'..'\377';
exportVocab = modelica;
testLiterals = false;
k=2;
charVocabulary = '\3'..'\377';
exportVocab = modelica;
testLiterals = false;
defaultErrorHandler = false;
}

tokens {
Expand Down Expand Up @@ -68,6 +69,9 @@ tokens {
WHEN = "when" ;
WHILE = "while" ;
WITHIN = "within" ;

// SUM = "sum" ;
// ARRAY = "array";
}


Expand Down
52 changes: 45 additions & 7 deletions modelica_parser/src/modelica_parser.g
Expand Up @@ -13,6 +13,7 @@ class modelica_parser extends Parser;

options {
importVocab = modelica;
defaultErrorHandler = false;
k = 2;
buildAST = true;
}
Expand All @@ -31,6 +32,7 @@ tokens {
EQUATION_STATEMENT;
EXPRESSION_LIST;
EXTERNAL_FUNCTION_CALL;
FOR_INDICES ;
FUNCTION_CALL ;
FUNCTION_ARGUMENTS;
QUALIFIED;
Expand Down Expand Up @@ -437,14 +439,28 @@ assert_clause :
*/

expression :
( simple_expression
| if_expression
( if_expression
| simple_expression
)
;

if_expression :
IF^ expression THEN! expression ELSE! expression
;
;



for_indices :
for_index (COMMA! for_index)*
{
#for_indices=#([FOR_INDICES,"FOR_INDICES"],#for_indices);
}
;

for_index:
(IDENT (COMMA^ IDENT)* IN^ expression)
;


simple_expression ! :
l1:logical_expression
Expand Down Expand Up @@ -517,6 +533,11 @@ factor :
primary ( POWER^ primary )?
;






primary :
( UNSIGNED_INTEGER
| UNSIGNED_REAL
Expand All @@ -528,10 +549,13 @@ primary :
| LBRACK^ expression_list (SEMICOLON! expression_list)* RBRACK!
| LBRACE^ expression_list RBRACE!
)
;
;




component_reference__function_call ! :
cr:component_reference ( fc:function_call )?
cr:component_reference ( fc:function_call )?
{
if (#fc != null)
{
Expand Down Expand Up @@ -575,11 +599,23 @@ function_call :
;

function_arguments :
// ( for_or_expression_list
( expression_list
| named_arguments
)?
;

//for_or_expression_list
// :
// e:expression
// ( COMMA! expression_list2
// {
// #for_or_expression_list=#([EXPRESSION_LIST,"EXPRESSION_LIST"],#for_or_expression_list);
// }
// | FOR^ for_indices
// )?
// ;

named_arguments :
named_argument ( COMMA! named_argument )*
;
Expand All @@ -589,12 +625,14 @@ named_argument :
;

expression_list :
expression ( COMMA! expression )*
expression_list2
{
#expression_list=#([EXPRESSION_LIST,"EXPRESSION_LIST"],#expression_list);
}
;

expression_list2 :
expression ( COMMA! expression )*
;
array_subscripts :
LBRACK^ subscript ( COMMA! subscript )* RBRACK!
;
Expand Down

0 comments on commit 51b24d3

Please sign in to comment.