diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2009-09-12 12:41:07 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2009-09-12 12:41:07 +0000 |
commit | 9c6c8fb47e2257313ce9185d728eaa755c3519b8 (patch) | |
tree | 6cfcca89596732b5f2f6182107b8636b697fbfc8 /parsing/parser.mly | |
parent | 7be229fab34af1e43b5c6a64cdf7fb05f8ca0e0f (diff) |
As discussed at the latest consortium meeting:
Syntactic sugar {x} for {x=x} in record expressions and patterns.
Syntax { lbl=pat; _ } to mark record patterns where the user explicitly wants not to list all labels.
Warning (activated by E, the fragile match warning) to signal record patterns without '; _' that fail to list all labels.
To be done: adjust Camlp4 parser accordingly.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9331 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'parsing/parser.mly')
-rw-r--r-- | parsing/parser.mly | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/parsing/parser.mly b/parsing/parser.mly index b229fa1a4..77309e4e4 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -1113,8 +1113,8 @@ simple_pattern: { mkpat(Ppat_variant($1, None)) } | SHARP type_longident { mkpat(Ppat_type $2) } - | LBRACE lbl_pattern_list opt_semi RBRACE - { mkpat(Ppat_record(List.rev $2)) } + | LBRACE lbl_pattern_list record_pattern_end RBRACE + { mkpat(Ppat_record(List.rev $2, $3)) } | LBRACE lbl_pattern_list opt_semi error { unclosed "{" 1 "}" 4 } | LBRACKET pattern_semi_list opt_semi RBRACKET @@ -1151,7 +1151,11 @@ lbl_pattern_list: | lbl_pattern_list SEMI label_longident EQUAL pattern { ($3, $5) :: $1 } | lbl_pattern_list SEMI label_longident { ($3, pat_of_label $3) :: $1 } ; - +record_pattern_end: + opt_semi { Closed } + | SEMI UNDERSCORE opt_semi { Open } +; + /* Primitive declarations */ primitive_declaration: |