summaryrefslogtreecommitdiff
path: root/parsing/parser.mly
diff options
context:
space:
mode:
authorJeremie Dimino <jdimino@janestreet.com>2016-03-15 11:42:25 +0000
committerJeremie Dimino <jdimino@janestreet.com>2016-03-17 14:35:08 +0000
commit5531c727cabfe85b3eb62ea8262aa35a4b1dae62 (patch)
treef92db447985f8b1b208e6b4660a651c623f24ca4 /parsing/parser.mly
parent391d7f05a9b0f7e5a02b9e569f2328ce7b333c69 (diff)
downloadocaml-5531c727cabfe85b3eb62ea8262aa35a4b1dae62.tar.gz
Allow shortcut for extension on semicolons
Similarly to what is done for keywords. The syntax is: <expr> ;%foo <expr> and is a shortcut for: [%foo <expr> ; <expr>] The rationale is to have the equivalent of the normal semicolon when writing ml code using a monadic let%foo
Diffstat (limited to 'parsing/parser.mly')
-rw-r--r--parsing/parser.mly4
1 files changed, 4 insertions, 0 deletions
diff --git a/parsing/parser.mly b/parsing/parser.mly
index 577595e348..e2dadbb5cf 100644
--- a/parsing/parser.mly
+++ b/parsing/parser.mly
@@ -1305,6 +1305,10 @@ seq_expr:
| expr %prec below_SEMI { $1 }
| expr SEMI { reloc_exp $1 }
| expr SEMI seq_expr { mkexp(Pexp_sequence($1, $3)) }
+ | expr SEMI PERCENT attr_id seq_expr
+ { let seq = mkexp(Pexp_sequence ($1, $5)) in
+ let payload = PStr [mkstrexp seq []] in
+ mkexp (Pexp_extension ($4, payload)) }
;
labeled_simple_pattern:
QUESTION LPAREN label_let_pattern opt_default RPAREN