Skip to content

Commit

Permalink
For iterators (reduction expressions 3.4.3.1) and array constructors …
Browse files Browse the repository at this point in the history
…with

iterators (3.4.4.1)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1145 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
levsa committed Apr 20, 2004
1 parent f7731dd commit 749bc9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
15 changes: 10 additions & 5 deletions modelica_parser/src/modelica_parser.g
Expand Up @@ -47,6 +47,7 @@ tokens {
EXPRESSION_LIST;
EXTERNAL_FUNCTION_CALL;
FOR_INDICES ;
FOR_ITERATOR ;
FUNCTION_CALL ;
INITIAL_FUNCTION_CALL ;
FUNCTION_ARGUMENTS;
Expand Down Expand Up @@ -701,7 +702,7 @@ primary :
| component_reference__function_call
| LPAR^ expression_list RPAR!
| LBRACK^ expression_list (SEMICOLON! expression_list)* RBRACK!
| LBRACE^ expression_list RBRACE!
| LBRACE^ for_or_expression_list RBRACE!
| END
)
;
Expand Down Expand Up @@ -765,13 +766,17 @@ for_or_expression_list
(
e:expression
( COMMA! for_or_expression_list2
{
#for_or_expression_list =
#([EXPRESSION_LIST,"EXPRESSION_LIST"], #for_or_expression_list);
}
| FOR^ for_indices
{
#for_or_expression_list =
#([FOR_ITERATOR,"FOR_ITERATOR"], #for_or_expression_list);
}
)?
)
{
#for_or_expression_list = #([EXPRESSION_LIST,"EXPRESSION_LIST"],#for_or_expression_list);
}

)
;

Expand Down
36 changes: 28 additions & 8 deletions modeq/absyn_builder/walker.g
Expand Up @@ -1523,7 +1523,9 @@ primary returns [void* ast]
{
ast = Absyn__MATRIX(make_rml_list_from_stack(el_stack));
}
| #(LBRACE ast = expression_list) { ast = Absyn__ARRAY(ast); }
| #(LBRACE ( (ast = expression_list) { ast = Absyn__ARRAY(ast); }
| (ast = for_iterator)
) RBRACE)
| END { ast = Absyn__END; }
)
;
Expand Down Expand Up @@ -1600,7 +1602,8 @@ component_reference returns [void* ast]

function_call returns [void* ast]
:
#(FUNCTION_ARGUMENTS ast = function_arguments);
#(FUNCTION_ARGUMENTS ast = function_arguments)
;

function_arguments returns [void* ast]
{
Expand All @@ -1609,12 +1612,15 @@ function_arguments returns [void* ast]
void* namel=0;
}
:
(elist=expression_list)? (namel = named_arguments)?
{
if (!namel) namel = mk_nil();
if (!elist) elist = mk_nil();
ast = Absyn__FUNCTIONARGS(elist,namel);
}
(
(elist=expression_list)? (namel = named_arguments)?
{
if (!namel) namel = mk_nil();
if (!elist) elist = mk_nil();
ast = Absyn__FUNCTIONARGS(elist,namel);
}
| #(FOR_ITERATOR ast = for_iterator)
)
;

named_arguments returns [void* ast]
Expand All @@ -1640,6 +1646,20 @@ named_argument returns [void* ast]
}
;

for_iterator returns [void *ast]
{
void* expr;
void* iter;
void* id;
}
:
#(FOR expr = expression #(IN i:IDENT iter=expression))
{
id = to_rml_str(i);
ast = Absyn__FOR_5fITER_5fFARG(expr,id,iter);
}
;

expression_list returns [void* ast]
{
l_stack el_stack;
Expand Down

0 comments on commit 749bc9a

Please sign in to comment.