-
Erwan Jahier authored
and PredefEvalClock.
Erwan Jahier authoredand PredefEvalClock.
predef.ml 3.95 KiB
(** Time-stamp: <modified the 03/06/2008 (at 14:21) by Erwan Jahier> *)
(* XXX shoud not type int, real, and bool be handled there ? *)
type op =
(* zero-ary *)
| TRUE_n
| FALSE_n
| RCONST_n of Ident.t (* we don't want to touch reals! *)
| ICONST_n of Ident.t (* so we don't touch int either...*)
(* unary *)
| NOT_n
| REAL2INT_n
| INT2REAL_n
(* binary *)
| AND_n
| OR_n
| XOR_n
| IMPL_n
| EQ_n
| NEQ_n
| LT_n
| LTE_n
| GT_n
| GTE_n
| DIV_n
| MOD_n
(* ternary *)
| IF_n
(* n-ary *)
| NOR_n
| DIESE_n
(* overloaded operator *)
| UMINUS_n
| MINUS_n
| PLUS_n
| SLASH_n
| TIMES_n
(* un-overloaded operator *)
| IUMINUS_n
| IMINUS_n
| IPLUS_n
| ISLASH_n
| ITIMES_n
| RUMINUS_n
| RMINUS_n
| RPLUS_n
| RSLASH_n
| RTIMES_n
(* Array iterator *)
| Map
| Fill
| Red
| FillRed
| BoolRed
let op2string = function
| TRUE_n -> "true"
| FALSE_n -> "false"
| ICONST_n id -> Ident.to_string id
| RCONST_n id -> Ident.to_string id
| NOT_n -> "not"
| REAL2INT_n -> "real2int"
| INT2REAL_n -> "int2real"
| AND_n -> "and"
| OR_n -> "or"
| XOR_n -> "xor"
| IMPL_n -> "=>"
| EQ_n -> "="
| NEQ_n -> "<>"
| LT_n -> "<"
| LTE_n -> "<="
| GT_n -> ">"
| GTE_n -> ">="
| DIV_n -> "div"
| MOD_n -> "mod"
| IF_n -> "if"
| NOR_n -> "nor"
| DIESE_n -> "#"
| UMINUS_n -> "-"
| MINUS_n -> "-"
| PLUS_n -> "+"
| SLASH_n -> "/"
| TIMES_n -> "*"
| IUMINUS_n -> "-"
| IMINUS_n -> "-"
| IPLUS_n -> "+"
| ISLASH_n -> "/"
| ITIMES_n -> "*"
| RUMINUS_n -> "-"
| RMINUS_n -> "-"
| RPLUS_n -> "+"
| RSLASH_n -> "/"
| RTIMES_n -> "*"
| Map -> "map"
| Fill -> "fill"
| Red -> "red"
| FillRed -> "fillred"
| BoolRed -> "boolred"
let is_infix = function
| AND_n | OR_n | XOR_n | IMPL_n | EQ_n | NEQ_n | LT_n | LTE_n | GT_n | GTE_n | DIV_n
| MOD_n | IF_n | MINUS_n | PLUS_n | SLASH_n | TIMES_n | IMINUS_n | IPLUS_n
| ISLASH_n | ITIMES_n | RMINUS_n | RPLUS_n | RSLASH_n | RTIMES_n
-> true
| _ -> false
(*********************************************************************************)
let (string_to_op : string -> op) =
function
(* zero-ary *)
| "true" -> TRUE_n
| "false" -> FALSE_n
(* unary *)
| "not" -> NOT_n
| "real2int" -> REAL2INT_n
| "int2real" -> INT2REAL_n
(* binary *)
| "and" -> AND_n
| "or" -> OR_n
| "xor" -> XOR_n
| "impl" -> IMPL_n
| "eq" -> EQ_n
| "neq" -> NEQ_n
| "lt" -> LT_n
| "lte" -> LTE_n
| "gt" -> GT_n
| "gte" -> GTE_n
| "div" -> DIV_n
| "mod" -> MOD_n
(* ternary *)
| "if" -> IF_n
(* n-ary *)
| "nor" -> NOR_n
| "#" -> DIESE_n
| "diese" -> DIESE_n
(* overloaded operator *)
| "uminus" -> UMINUS_n
| "minus" -> MINUS_n
| "plus" -> PLUS_n
| "slash" -> SLASH_n
| "times" -> TIMES_n
(* un-overloaded operator *)
| "iuminus" -> IUMINUS_n
| "iminus" -> IMINUS_n
| "iplus" -> IPLUS_n
| "islash" -> ISLASH_n
| "itimes" -> ITIMES_n
| "ruminus" -> RUMINUS_n
| "rminus" -> RMINUS_n
| "rplus" -> RPLUS_n
| "rslash" -> RSLASH_n
| "rtimes" -> RTIMES_n
(* array iterator *)
| "map" -> Map
| "fill" -> Fill
| "red" -> Red
| "fillred" -> FillRed
| "boolred" -> BoolRed
| _ -> raise Not_found
(** An evaluator returns a list because Lustre calls returns tuples.
SE: migth raise some check error!
*)
type 'a evaluator = 'a list list -> 'a list
(*********************************************************************************)
(* Automatically generate the latex documentation associated to predefined
entities *)
(* let (gen_tex_doc : string -> unit) = *)
(* fun file -> *)
(* let oc = open_out file in *)
(* let p = output_string oc in *)
(* p " Lustre V6 predefined operators \n\n"; *)
(* List.iter (fun (n,def) -> p ("\t" ^ n ^ "\n")) list; *)
(* close_out oc *)
(*********************************************************************************)