Permalink
Browse files

[enhance] compiler, parser: Added utils for tail_coerce

  • Loading branch information...
1 parent 12625d2 commit cf1818e3904a5166f73bbc2144a7ef8e14d1e0ff @OpaOnWindowsNow OpaOnWindowsNow committed with BourgerieQuentin Feb 15, 2012
Showing with 8 additions and 1 deletion.
  1. +5 −0 opalang/classic_syntax/parser_utils.ml
  2. +3 −1 opalang/classic_syntax/parser_utils.mli
@@ -910,6 +910,7 @@ let list_nil label = coerce_name_expr (record [("nil",void label)]) Opacapi.Type
let list_nil_no_coerce label = (record [("nil",void label)])
let list_nil_pat label = coerce_name_pat (record_pat [("nil",void_pat label)]) Opacapi.Types.list
let list_cons e1 e2 = coerce_name_expr (record [("hd",e1);("tl",e2)]) Opacapi.Types.list
+let list_cons_tail_coerce e1 e2 = (record [("hd",e1);("tl",coerce_name_expr e2 Opacapi.Types.list)])
let list_cons_no_coerce e1 e2 = (record [("hd",e1);("tl",e2)])
let list_cons_pat e1 e2 = coerce_name_pat (record_pat [("hd",e1);("tl",e2)]) Opacapi.Types.list
let list_pat_of_pat_list ?tl l label : string pat =
@@ -921,6 +922,10 @@ let list_expr_of_expr_list ?tl l label =
let list_expr_of_expr_list_no_coerce ?tl l label =
let tl = match tl with None -> list_nil_no_coerce label | Some tl -> tl in
List.fold_right list_cons_no_coerce l tl
+let list_expr_of_expr_list_tail_coerce ?tl l label =
+ let tl = match tl with None -> list_nil label | Some tl -> tl in
+ List.fold_right list_cons_tail_coerce l tl
+
let list_expr_of_expr_list_unsafe l =
assert (l <> []);
let pos = union_annot_list l in list_expr_of_expr_list l pos
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of OPA.
@@ -246,6 +246,8 @@ val list_expr_of_expr_list :
?tl:(string,'a) expr -> (string, [> `coerce ] as 'a) expr list -> annot -> (string, 'a) expr
val list_expr_of_expr_list_no_coerce :
?tl:(string,'a) expr -> (string, [> `coerce ] as 'a) expr list -> annot -> (string, 'a) expr
+val list_expr_of_expr_list_tail_coerce :
+ ?tl:(string,'a) expr -> (string, [> `coerce ] as 'a) expr list -> annot -> (string, 'a) expr
val list_expr_of_expr_list_unsafe : (string, [> `coerce ] as 'a) expr list -> (string, 'a) expr(**Fails if the list is empty*)
val list_constructors_of_string_list: (string * annot) list -> annot -> (string, [> `coerce ]) expr

0 comments on commit cf1818e

Please sign in to comment.