Skip to content

Commit 0c96272

Browse files
author
x98petro
committed
Modifed the grammar to accept multiple return values from functions.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@478 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent ef83130 commit 0c96272

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

modeq/ast/modgram.g

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ argument :
424424

425425
element_modification : << bool is_final=false; >>
426426
{ FINAL << is_final=true; >> }
427-
cr:component_reference /* name_path /* Not in spec */
427+
cr:single_component_reference /* name_path /* Not in spec */
428428
sp:modification
429429
<<
430430
Attrib a = $[MODIFICATION,"---"];
@@ -517,7 +517,7 @@ equation : << bool is_assign = false; AST *top; >>
517517
;
518518

519519
algorithm :
520-
( cr:component_reference
520+
( cr:single_component_reference
521521
( ASSIGN^ e:expression
522522
<< #0->rml = Absyn__ALG_5fASSIGN(#cr->rml, #e->rml); >>
523523
| function_call << unimpl("algorithm function_call"); >> )
@@ -752,14 +752,16 @@ primary : << bool is_matrix; >>
752752
| f:FALS/*E*/ << #f->rml = Absyn__BOOL(RML_FALSE); >>
753753
| t:TRU/*E*/ << #t->rml = Absyn__BOOL(RML_TRUE); >>
754754
/* | (name_path_function_arguments)? */
755-
| i:component_reference
755+
/* | i:single_component_reference
756756
{ fc:function_call }
757757
<< if(#fc)
758758
#0->rml = Absyn__CALL(#i->rml,#fc->rml);
759759
else
760760
#0->rml = Absyn__CREF(#i->rml);
761761
>>
762-
| s:STRING << #s->rml = Absyn__STRING(mk_scon($s.u.stringval)); >>
762+
*/
763+
| component_references
764+
| s:STRING << #s->rml = Absyn__STRING(mk_scon($s.u.stringval)); >>
763765
| par:LPAR^
764766
e:expression RPAR!
765767
<< #par->rml = #e->rml; >>
@@ -776,6 +778,15 @@ primary : << bool is_matrix; >>
776778
RBRACK!
777779
;
778780

781+
component_references:
782+
single_component_reference { function_or_multiple_references }
783+
;
784+
785+
function_or_multiple_references:
786+
function_call
787+
| "," single_component_reference { "," single_component_reference }
788+
;
789+
779790
/* name_path_function_arguments ! : << Attrib a = $[FUNCALL,"---"]; >> */
780791
/* n:name_path f:function_arguments */
781792
/* << */
@@ -802,10 +813,10 @@ name_path : << bool qualified = false; >>
802813
/* name_path b:LBRACK^ subscript_list RBRACK! */
803814
/* ; */
804815

805-
component_reference : << void *tail = NULL;>>
816+
single_component_reference : << void *tail = NULL;>>
806817
i:IDENT^ { a:array_subscripts }
807818
<< #i->rml = mk_scon($i.u.stringval); >>
808-
{ dot:DOT^ c:component_reference << tail = #c->rml; >> }
819+
{ dot:DOT^ c:single_component_reference << tail = #c->rml; >> }
809820
<< if(tail)
810821
#0->rml = Absyn__CREF_5fQUAL(#i->rml, #a?#a->rml:mk_nil(), tail);
811822
else

modeq/history.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
30 nov 1998
3+
The grammar now accepts multiple return values. The semantics does not complain although it should! (The semantics expects only one return value )
4+
5+
26 nov 1998
6+
Started with adding multiple return values for functions to the grammar.
7+

modeq/main.rml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ with "rtopts.rml"
2727

2828
relation translate_file : string list => () =
2929

30-
rule Parser.parse f => p &
30+
rule print "Parsing\n" &
31+
Parser.parse f => p &
32+
print "elaborating\n" &
3133
SCode.elaborate(p) => p' &
34+
print "instantiating\n" &
3235
Inst.instantiate(p') => d &
3336
DAE.dump d
3437
----------

0 commit comments

Comments
 (0)