Skip to content

Commit

Permalink
Added relations and logical expressions
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@68 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x97davka committed Dec 9, 1997
1 parent baecbcb commit 1b95bd5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
51 changes: 50 additions & 1 deletion modeq/dump.rml
Expand Up @@ -59,13 +59,32 @@ relation binop_symbol: Exp.BinOp => string =
axiom binop_symbol(Exp.SUB) => " - "
axiom binop_symbol(Exp.MUL) => "*"
axiom binop_symbol(Exp.DIV) => "/"
axiom binop_symbol(Exp.POW) => "^"
end

relation unaryop_symbol: Exp.UnaryOp => string =
axiom unaryop_symbol(Exp.UMINUS) => "-"
axiom unaryop_symbol(Exp.UPLUS) => "+"
end

relation lbinop_symbol: Exp.LBinOp => string =
axiom lbinop_symbol(Exp.AND) => " AND "
axiom lbinop_symbol(Exp.OR) => " OR "
end

relation lunaryop_symbol: Exp.LUnaryOp => string =
axiom lunaryop_symbol(Exp.NOT) => "NOT "
end

relation relop_symbol: Exp.RelOp => string =
axiom relop_symbol(Exp.LESS) => " < "
axiom relop_symbol(Exp.LESSEQ) => " <= "
axiom relop_symbol(Exp.GREATER) => " > "
axiom relop_symbol(Exp.GREATEREQ) => " >= "
axiom relop_symbol(Exp.EQUAL) => " == "
axiom relop_symbol(Exp.NEQUAL) => " <> "
end

relation path_string: Exp.Path => string =

axiom path_string(Exp.IDENT(s)) => s
Expand All @@ -92,6 +111,14 @@ relation dump_exp: Exp.Exp => () =
--
dump_exp(Exp.STRING(s))

rule print "FALSE"
-------------
dump_exp(Exp.BOOL(false))

rule print "TRUE"
-------------
dump_exp(Exp.BOOL(true))

rule binop_symbol(op) => sym &
dump_exp e1 & print sym & dump_exp e2
----------------------------
Expand All @@ -102,18 +129,40 @@ relation dump_exp: Exp.Exp => () =
----------------------------
dump_exp(Exp.UNARY(op, e))

rule lbinop_symbol(op) => sym &
dump_exp e1 & print sym & dump_exp e2
----------------------------
dump_exp(Exp.LBINARY(e1, op, e2))

rule lunaryop_symbol(op) => sym &
print sym & dump_exp e
----------------------------
dump_exp(Exp.LUNARY(op, e))

rule relop_symbol(op) => sym &
dump_exp(e1) & print sym & dump_exp(e2)
---------------------------------------
dump_exp(Exp.RELATION(e1, op, e2))

rule print "IF " & dump_exp(c) &
print " THEN " & dump_exp(t) &
print " ELSE " & dump_exp(f)
----------------------------
dump_exp(Exp.IFEXP(c,t,f))

rule path_string(fcn) => fs &
print fs & print "(" & dump_list(args,dump_exp,",") & print ")"
---------------------------------------------
dump_exp(Exp.CALL(fcn, args))

(*
rule print "EQUATION " &
dump_exp lhs &
print " = " &
dump_exp rhs
------------------------
dump_exp(Exp.EQU(lhs, rhs))

*)
rule print "TIME"
------------------
dump_exp(Exp.TIME)
Expand Down
14 changes: 12 additions & 2 deletions modeq/exp.rml
Expand Up @@ -9,8 +9,11 @@ type Ident = string
datatype Path = QUALIFIED of string * Path
| IDENT of Ident

datatype BinOp = ADD | SUB | MUL | DIV
datatype BinOp = ADD | SUB | MUL | DIV | POW
datatype UnaryOp = UMINUS | UPLUS
datatype LBinOp = AND | OR
datatype LUnaryOp = NOT
datatype RelOp = LESS | LESSEQ | GREATER | GREATEREQ | EQUAL | NEQUAL

datatype Exp = NUMBER of real
| PATH of Path
Expand All @@ -20,8 +23,15 @@ datatype Exp = NUMBER of real
| BINARY of Exp * BinOp * Exp
| UNARY of UnaryOp * Exp

| LBINARY of Exp * LBinOp * Exp
| LUNARY of LUnaryOp * Exp

| RELATION of Exp * RelOp * Exp

| IFEXP of Exp * Exp * Exp

| CALL of Path * Exp list (* Function call *)
| EQU of Exp * Exp (* Equation *)
(* | EQU of Exp * Exp ( * Equation *)
| TIME

end

0 comments on commit 1b95bd5

Please sign in to comment.