Skip to content

Commit

Permalink
Fixed IF in equations
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@301 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x97davka committed Jul 1, 1998
1 parent 14440f2 commit 9d80729
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
5 changes: 4 additions & 1 deletion modeq/absyn.rml
Expand Up @@ -67,7 +67,10 @@ module Absyn:
* Modification option

datatype Equation = EQ_EXPR of Exp (* more later? *)
| EQ_COND (* FIXME *)
| EQ_IF of Exp
* Equation list (* true branch *)
* (Exp * Equation list) list (* elseif branches *)
* Equation list (* else branch *)
| EQ_EQUALS of Exp * Exp
| EQ_CONNECT of ComponentRef * ComponentRef
| EQ_FOR of Ident * Exp * Equation list
Expand Down
28 changes: 22 additions & 6 deletions modeq/ast/modgram.g
Expand Up @@ -530,14 +530,30 @@ algorithm :
;

conditional_equation_e :
i:IF^ expression THEN!
el:equation_list
( ELSEIF! expression THEN!
el1:equation_list )*
<< void *tbranch, *ebranch, *fbranch;
AST *elseif = NULL; >>
IF^ c:expression THEN!
el:equation_list << tbranch = sibling_list(#el); >>

( ei:equation_elseif
<< if (elseif == NULL) elseif = #ei; >> )*

/* Collect the elseif branches */
<< if (elseif == NULL)
ebranch = mk_nil();
else
ebranch = sibling_list(elseif); >>

{ ELSE!
el2:equation_list }
el2:equation_list << fbranch = sibling_list(#el2); >> }
END! IF!
<< unimpl("conditional_equation_e"); >>
<< #0->rml = Absyn__EQ_5fIF(#c->rml,tbranch,ebranch,fbranch); >>
;

equation_elseif :
ELSEIF^ c:expression THEN!
el:equation_list
<< #0->rml = mk_box2(0,#c->rml,sibling_list(#el)); >>
;

conditional_equation_a :
Expand Down

0 comments on commit 9d80729

Please sign in to comment.