Skip to content

Commit 2580189

Browse files
author
x97davka
committed
IF statements
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@303 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0860e7e commit 2580189

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

modeq/dump.rml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ relation print_equation: Absyn.Equation => () =
271271
-------------------------------------------
272272
print_equation(Absyn.EQ_EXPR(e))
273273

274+
rule print "IF (" & print_exp(e) & print ") THEN " &
275+
print_list(tb, print_equation, ";") &
276+
print_list(eb, print_elseif, " ") &
277+
print " ELSE " & print_list(fb, print_equation, ";")
278+
----------------------------------------------------
279+
print_equation(Absyn.EQ_IF(e,tb,eb,fb))
280+
274281
rule print "EQ_EQUALS(" & print_exp(e1) & print "," &
275282
print_exp(e2) & print ")"
276283
-------------------------------------------
@@ -292,6 +299,17 @@ relation print_equation: Absyn.Equation => () =
292299

293300
end
294301

302+
(**)
303+
304+
relation print_elseif : (Absyn.Exp * Absyn.Equation list) => () =
305+
306+
rule print " ELSEIF " & print_exp e & print " THEN " &
307+
print_list(el, print_equation, ";")
308+
-----------------------------------
309+
print_elseif((e,el))
310+
311+
end
312+
295313
(** - Algorithm clauses *)
296314

297315
relation print_algorithm: Absyn.Algorithm => () =
@@ -412,9 +430,9 @@ relation print_exp: Absyn.Exp => () =
412430
-----------------------------------------------------------------
413431
print_exp(Absyn.RELATION(e1, op, e2))
414432

415-
rule print "IF " & print_exp(c) &
416-
print " THEN " & print_exp(t) &
417-
print " ELSE " & print_exp(f)
433+
rule print "if " & print_exp(c) &
434+
print " then " & print_exp(t) &
435+
print " else " & print_exp(f)
418436
----------------------------
419437
print_exp(Absyn.IFEXP(c,t,f))
420438

modeq/env.rml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ module Env:
1717
with "classinf.rml"
1818
with "exp.rml"
1919

20+
type Binding = Types.Binding
21+
2022
datatype FrameVar = FRAMEVAR of SCode.Ident
2123
* Absyn.VarAttr
2224
* Types.Type
2325
* Binding
2426

25-
datatype Binding = UNBOUND
26-
| EQBOUND of Exp.Exp
27-
| VALBOUND of Values.Value
28-
2927
datatype Frame = FRAME of (SCode.Ident*FrameVar) list
3028
* (SCode.Ident*SCode.Class) list
3129

0 commit comments

Comments
 (0)