aboutsummaryrefslogtreecommitdiff
path: root/parsing
diff options
context:
space:
mode:
authorMaxime Dénès2017-04-07 12:56:40 +0200
committerMaxime Dénès2017-04-12 15:10:15 +0200
commita74d64efb554e9fd57b8ec97fca7677033cc4fc4 (patch)
tree361960411112f34147d058dc78c4716bef05b0f9 /parsing
parentf41944730792070d4a3074aa1fe1f8465062b758 (diff)
parent01622922a3a68cc4a0597bb08e0f7ba5966a7144 (diff)
Merge PR#422: Supporting all kinds of binders, including 'pat, in syntax of record fields.
Diffstat (limited to 'parsing')
-rw-r--r--parsing/g_constr.ml48
-rw-r--r--parsing/g_vernac.ml414
2 files changed, 12 insertions, 10 deletions
diff --git a/parsing/g_constr.ml4 b/parsing/g_constr.ml4
index 05cb74ddca..0f2ed88fea 100644
--- a/parsing/g_constr.ml4
+++ b/parsing/g_constr.ml4
@@ -43,9 +43,6 @@ let binder_of_name expl (loc,na) =
let binders_of_names l =
List.map (binder_of_name Explicit) l
-let binders_of_lidents l =
- List.map (fun (loc, id) -> binder_of_name Explicit (loc, Name id)) l
-
let mk_fixb (id,bl,ann,body,(loc,tyc)) =
let ty = match tyc with
Some ty -> ty
@@ -222,15 +219,14 @@ GEXTEND Gram
record_fields:
[ [ f = record_field_declaration; ";"; fs = record_fields -> f :: fs
- | f = record_field_declaration; ";" -> [f]
| f = record_field_declaration -> [f]
| -> []
] ]
;
record_field_declaration:
- [ [ id = global; params = LIST0 identref; ":="; c = lconstr ->
- (id, abstract_constr_expr c (binders_of_lidents params)) ] ]
+ [ [ id = global; bl = binders; ":="; c = lconstr ->
+ (id, mkCLambdaN (!@loc) bl c) ] ]
;
binder_constr:
[ [ "forall"; bl = open_binders; ","; c = operconstr LEVEL "200" ->
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index 71b93439bc..4fd316119f 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -236,16 +236,22 @@ GEXTEND Gram
(* Simple definitions *)
def_body:
[ [ bl = binders; ":="; red = reduce; c = lconstr ->
- let (bl, c) = expand_pattern_binders mkCLambdaN bl c in
- (match c with
- CCast(_,c, CastConv t) -> DefineBody (bl, red, c, Some t)
+ if List.exists (function CLocalPattern _ -> true | _ -> false) bl
+ then
+ (* FIXME: "red" will be applied to types in bl and Cast with remain *)
+ let c = mkCLambdaN (!@loc) bl c in
+ DefineBody ([], red, c, None)
+ else
+ (match c with
+ | CCast(_,c, CastConv t) -> DefineBody (bl, red, c, Some t)
| _ -> DefineBody (bl, red, c, None))
| bl = binders; ":"; t = lconstr; ":="; red = reduce; c = lconstr ->
let ((bl, c), tyo) =
if List.exists (function CLocalPattern _ -> true | _ -> false) bl
then
+ (* FIXME: "red" will be applied to types in bl and Cast with remain *)
let c = CCast (!@loc, c, CastConv t) in
- (expand_pattern_binders mkCLambdaN bl c, None)
+ (([],mkCLambdaN (!@loc) bl c), None)
else ((bl, c), Some t)
in
DefineBody (bl, red, c, tyo)