SHARE
TWEET

Untitled

a guest Feb 16th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 7cfd771288da557b056be51fba557def9b266e25 Mon Sep 17 00:00:00 2001
  2. From: Kaustuv Chaudhuri <kaustuv.chaudhuri@inria.fr>
  3. Date: Sat, 29 Jun 2013 10:58:54 +0200
  4. Subject: Add support for M.[] and M.{}.
  5.  
  6. They are abbreviations for M.([]) and M.({}), respectively.
  7. ---
  8.  camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml |    4 ++++
  9.  parsing/parser.mly                               |   11 +++++++++++
  10.  2 files changed, 15 insertions(+)
  11.  
  12. diff --git a/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml b/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml
  13. index 1545b5e..4146650 100644
  14. --- a/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml
  15. +++ b/camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.ml
  16. @@ -705,6 +705,10 @@ New syntax:\
  17.          | s = a_CHAR -> <:expr< $chr:s$ >>
  18.          | i = TRY module_longident_dot_lparen; e = sequence; ")" ->
  19.              <:expr< let open $i$ in $e$ >>
  20. +        | i = TRY module_longident_dot_lparen; "["; mk_list = sem_expr_for_list; "::"; last = expr; "]" ->
  21. +            <:expr< let open $i$ in $mk_list last$ >>
  22. +        | i = TRY module_longident_dot_lparen; "{"; el = label_expr_list; "}" ->
  23. +            <:expr< let open $i$ in { $el$ } >>
  24.          | i = TRY val_longident -> <:expr< $id:i$ >>
  25.          | "`"; s = a_ident -> <:expr< ` $s$ >>
  26.          | "["; "]" -> <:expr< [] >>
  27. diff --git a/parsing/parser.mly b/parsing/parser.mly
  28. index 429d6be..03df3b7 100644
  29. --- a/parsing/parser.mly
  30. +++ b/parsing/parser.mly
  31. @@ -1109,6 +1109,12 @@ simple_expr:
  32.        { let (exten, fields) = $2 in mkexp(Pexp_record(fields, exten)) }
  33.    | LBRACE record_expr error
  34.        { unclosed "{" 1 "}" 3 }
  35. +  | mod_longident DOT LBRACE record_expr RBRACE
  36. +      { let (exten, fields) = $4 in
  37. +        let rec_exp = mkexp(Pexp_record(fields, exten)) in
  38. +        mkexp(Pexp_open(Fresh, mkrhs $1 1, rec_exp)) }
  39. +  | mod_longident DOT LBRACE record_expr error
  40. +      { unclosed "{" 3 "}" 5 }
  41.    | LBRACKETBAR expr_semi_list opt_semi BARRBRACKET
  42.        { mkexp(Pexp_array(List.rev $2)) }
  43.    | LBRACKETBAR expr_semi_list opt_semi error
  44. @@ -1119,6 +1125,11 @@ simple_expr:
  45.        { reloc_exp (mktailexp (rhs_loc 4) (List.rev $2)) }
  46.    | LBRACKET expr_semi_list opt_semi error
  47.        { unclosed "[" 1 "]" 4 }
  48. +  | mod_longident DOT LBRACKET expr_semi_list opt_semi RBRACKET
  49. +      { let list_exp = reloc_exp (mktailexp (rhs_loc 6) (List.rev $4)) in
  50. +        mkexp(Pexp_open(Fresh, mkrhs $1 1, list_exp)) }
  51. +  | mod_longident DOT LBRACKET expr_semi_list opt_semi error
  52. +      { unclosed "[" 3 "]" 6 }
  53.    | PREFIXOP simple_expr
  54.        { mkexp(Pexp_apply(mkoperator $1 1, ["",$2])) }
  55.    | BANG simple_expr
  56. --
  57. 1.7.10.4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top