Skip to content

Commit

Permalink
Fixed bug in external functions (parsing and absyn)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@877 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Nov 6, 2002
1 parent 810cbb8 commit ea291cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modeq/absyn.rml
Expand Up @@ -284,7 +284,7 @@ module Absyn:

(* ExternalDecl *)
datatype ExternalDecl = EXTERNALDECL of
Ident * (* The name of the external function *)
Ident option * (* The name of the external function *)
string option * (* Lanugage of the external function *)
ComponentRef option * (* ouput parameter as return value*)
Exp list (* only positional arguments, i.e. expression list*)
Expand Down
24 changes: 17 additions & 7 deletions modeq/absyn_builder/walker.g
Expand Up @@ -243,11 +243,12 @@ composition returns [void* ast]
el_stack.push(el);
}
)*
( EXTERNAL
( el = external_function_call )?
( EXTERNAL
( el = external_function_call)
( ann = annotation)?
{
el_stack.push(el);
el_stack.push(el);

}
)?
{
Expand Down Expand Up @@ -289,27 +290,36 @@ external_function_call returns [void* ast]
void* temp2=0;
void* temp3=0;
void *lang;
ast = 0;
}
:
(s:STRING)?
#(EXTERNAL_FUNCTION_CALL
(#(EXTERNAL_FUNCTION_CALL
(
(i:IDENT (temp = expression_list)?)
{
if (s != NULL) { lang = mk_some(to_rml_str(s)); }
else { lang = mk_none(); }
if (!temp) { temp = mk_nil(); }
ast = Absyn__EXTERNAL(Absyn__EXTERNALDECL(to_rml_str(i),lang,mk_none(),temp));
ast = Absyn__EXTERNAL(Absyn__EXTERNALDECL(mk_some(to_rml_str(i)),lang,mk_none(),temp));
}
| #(e:EQUALS temp2 = component_reference i2:IDENT ( temp3 = expression_list)?)
{
if (s != NULL) { lang = mk_some(to_rml_str(s)); }
else { lang = mk_none(); }
if (!temp2) { temp2 = mk_nil(); }
ast = Absyn__EXTERNAL(Absyn__EXTERNALDECL(to_rml_str(i2),lang,mk_some(temp2),temp3));
ast = Absyn__EXTERNAL(Absyn__EXTERNALDECL(mk_some(to_rml_str(i2)),lang,mk_some(temp2),temp3));
}
)
)
))?
{
if (!ast) {
if (s != NULL) { lang = mk_some(to_rml_str(s)); }
else { lang = mk_none(); }
ast = Absyn__EXTERNAL(Absyn__EXTERNALDECL(mk_none(),lang,mk_none(),mk_nil()));
}
}

;

element_list returns [void* ast]
Expand Down
7 changes: 5 additions & 2 deletions modeq/dump.rml
Expand Up @@ -360,16 +360,19 @@ relation unparse_class_part_str: Absyn.ClassPart => string =
string_append(langstr," ") => s1 &
Util.string_append_list(["\nexternal ",langstr," ", outputstr, "=",ident,"(",expstr,");\n"]) => str
--------------------------------------
unparse_class_part_str(Absyn.EXTERNAL(Absyn.EXTERNALDECL(ident,lang,SOME(output),expl)))
unparse_class_part_str(Absyn.EXTERNAL(Absyn.EXTERNALDECL(SOME(ident),lang,SOME(output),expl)))
=> str

rule get_option_str(lang,identity) => langstr &
print_list_str(expl,print_exp_str,",") => expstr &
string_append(langstr," ") => s1 &
Util.string_append_list(["\nexternal ", langstr," ",ident,"(",expstr,");\n"]) => str
--------------------------------------
unparse_class_part_str(Absyn.EXTERNAL(Absyn.EXTERNALDECL(ident,lang,NONE,expl)))
unparse_class_part_str(Absyn.EXTERNAL(Absyn.EXTERNALDECL(SOME(ident),lang,NONE,expl)))
=> str

axiom unparse_class_part_str(Absyn.EXTERNAL(Absyn.EXTERNALDECL(NONE,_,NONE,_)))
=> "\n external;\n"
end

(**)
Expand Down

0 comments on commit ea291cb

Please sign in to comment.