summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2009-10-16 16:35:58 +0000
committerAlain Frisch <alain@frisch.fr>2009-10-16 16:35:58 +0000
commit7d091147f44c91103073690625342d612407475d (patch)
tree14e5d84768b72366c71fa401029ec3b049487264
parent99d1a3eebbd4de24d72a57ecc10ea084a613854d (diff)
downloadocaml-7d091147f44c91103073690625342d612407475d.tar.gz
Functional syntax for 'let new type t in ...'.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/newtypein@9373 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--parsing/parser.mly6
1 files changed, 6 insertions, 0 deletions
diff --git a/parsing/parser.mly b/parsing/parser.mly
index 867db06c0c..5de19d15e2 100644
--- a/parsing/parser.mly
+++ b/parsing/parser.mly
@@ -831,6 +831,8 @@ expr:
{ mkexp(Pexp_function("", None, List.rev $3)) }
| FUN labeled_simple_pattern fun_def
{ let (l,o,p) = $2 in mkexp(Pexp_function(l, o, [p, $3])) }
+ | FUN LPAREN TYPE LIDENT RPAREN fun_def
+ { mkexp(Pexp_newtype($4, $6)) }
| MATCH seq_expr WITH opt_bar match_cases
{ mkexp(Pexp_match($2, List.rev $5)) }
| TRY seq_expr WITH opt_bar match_cases
@@ -1026,6 +1028,8 @@ strict_binding:
{ $2 }
| labeled_simple_pattern fun_binding
{ let (l, o, p) = $1 in ghexp(Pexp_function(l, o, [p, $2])) }
+ | LPAREN TYPE LIDENT RPAREN fun_binding
+ { mkexp(Pexp_newtype($3, $5)) }
;
match_cases:
pattern match_action { [$1, $2] }
@@ -1035,6 +1039,8 @@ fun_def:
match_action { $1 }
| labeled_simple_pattern fun_def
{ let (l,o,p) = $1 in ghexp(Pexp_function(l, o, [p, $2])) }
+ | LPAREN TYPE LIDENT RPAREN fun_def
+ { mkexp(Pexp_newtype($3, $5)) }
;
match_action:
MINUSGREATER seq_expr { $2 }