util.mli 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (* Generate a fresh variable from a given prefix, e.g. "counter" -> "counter$1" *)
  2. val fresh_var : string -> string
  3. (* Generate an Ast.loc tuple from Lexing data structures *)
  4. val loc_from_lexpos : Lexing.position -> Lexing.position -> Ast.loc
  5. (* Default transformation traversal for AST nodes *)
  6. val transform_children : (Ast.node -> Ast.node) -> Ast.node -> Ast.node
  7. (* Transform all nodes in a list *)
  8. val transform_all : (Ast.node -> Ast.node) -> Ast.node list -> Ast.node list
  9. (*val visit_children : (Ast.node -> unit) -> Ast.node -> unit*)
  10. (* Extract location from node *)
  11. val locof : Ast.node -> Ast.loc
  12. (* Print file location to stderr *)
  13. val prerr_loc : Ast.loc -> unit
  14. (* Print file location to stderr *)
  15. val prerr_loc_msg : Ast.loc -> string -> int -> unit
  16. (* Flatten Block nodes into the given array of nodes *)
  17. val flatten_blocks : Ast.node list -> Ast.node list
  18. (* Get function / expression type *)
  19. val ctypeof : Ast.node -> Ast.ctype
  20. (* Extract the node list from a Block node *)
  21. val block_body : Ast.node -> Ast.node list
  22. (* Get the size of a list by traversing it recurcively *)
  23. val list_size : 'a list -> int
  24. (* Get the basic type of a ctype, removing array dimensions *)
  25. val base_type : Ast.ctype -> Ast.ctype
  26. (* Get the number of dimensions from an Array type *)
  27. val array_depth : Ast.ctype -> int