Added operator (=>) in Pervasives module
Operator (=>) for implication added in Pervasives module. "a => b" is translated into "not a or b" at code generation.
This commit is contained in:
parent
5e277fcc8a
commit
69b8cc5a18
3 changed files with 7 additions and 1 deletions
|
@ -310,7 +310,9 @@ and cop_of_op_aux op_name cexps = match op_name with
|
|||
| "+" | "-" | "*" | "/"
|
||||
| "*." | "/." | "+." | "-." | "%" | "<<<" | ">>>" | "&&&" | "|||"
|
||||
| "<" | ">" | "<=" | ">=" | "<=." | "<." | ">=." | ">."), [el;er] ->
|
||||
Cbop (copname op, el, er)
|
||||
Cbop (copname op, el, er)
|
||||
| "=>", [el;er] ->
|
||||
Cbop ("||", (Cuop("!",el)), er)
|
||||
| _ -> Cfun_call(op, cexps)
|
||||
end
|
||||
| { qual = Module "Iostream"; name = "printf" } ->
|
||||
|
|
|
@ -168,6 +168,9 @@ and op ff (f, e_l) =
|
|||
| "~-" | "~-." ->
|
||||
let e = Misc.assert_1 e_l in
|
||||
fprintf ff "-%a" exp e
|
||||
| "=>" ->
|
||||
let e1,e2 = Misc.assert_2 e_l in
|
||||
fprintf ff "(@[!%a or %a@])" exp e1 exp e2
|
||||
| "assert" ->
|
||||
let e = Misc.assert_1 e_l in
|
||||
fprintf ff "assert(%a)" exp e
|
||||
|
|
|
@ -64,6 +64,7 @@ external val fun (|||)(int;int) returns (int)
|
|||
external val fun (~-.)(float) returns (float)
|
||||
external val fun do_stuff(int) returns (int)
|
||||
external val fun between(int;int) returns (int)
|
||||
external val fun (=>)(bool;bool) returns (bool)
|
||||
|
||||
external val fun exit(bool) returns ()
|
||||
external val fun assert(bool) returns ()
|
||||
|
|
Loading…
Reference in a new issue