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
master
Jeremie Dimino 2016-03-15 11:42:25 +00:00
parent 391d7f05a9
commit 5531c727ca
4 changed files with 372 additions and 349 deletions

View File

@ -6,6 +6,8 @@ OCaml 4.04.0:
Language features:
- GPR#301: local exception declarations "let exception ... in"
(Alain Frisch)
- GPR#508: Allow shortcut for extension on semicolons: ;%foo
(Jeremie Dimino)
Tools:
- GPR#452: Make the output of ocamldep is more stable

View File

@ -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

View File

@ -11,6 +11,7 @@ let () =
(if%foo[@foo] () then () else ()) ;
while%foo[@foo] () do () done ;
for%foo[@foo] x = () to () do () done ;
() ;%foo () ;
assert%foo[@foo] true ;
lazy%foo[@foo] x ;
object%foo[@foo] end ;

File diff suppressed because it is too large Load Diff