Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolved conflicts in parsers, removed unused entry points

  • Loading branch information...
commit 64b9281d058a4808d7475a1e38f896b73b2ea2c6 1 parent 70df32a
@def-lkb def-lkb authored
View
82 chunk_parser.mly
@@ -452,7 +452,6 @@ let wrap_type_annotation startpos endpos newtypes core_type body =
%token <string * Location.t> COMMENT
%token LET_LWT
-%token RAISE_LWT
%token TRY_LWT
%token MATCH_LWT
%token FINALLY_LWT
@@ -488,6 +487,7 @@ The precedences must be listed from low to high.
%nonassoc LET /* above SEMI ( ...; let ... in ...) */
%nonassoc below_WITH
%nonassoc FUNCTION WITH /* below BAR (match ... with ...) */
+%nonassoc FINALLY_LWT
%nonassoc AND /* above WITH (module rec A: SIG with ... and ...) */
%nonassoc THEN /* below ELSE (if ... then ...) */
%nonassoc ELSE /* (if ... then ... else ...) */
@@ -510,7 +510,6 @@ The precedences must be listed from low to high.
%nonassoc prec_unary_minus prec_unary_plus /* unary - */
%nonassoc prec_constant_constructor /* cf. simple_expr (C versus C x) */
%nonassoc prec_constr_appl /* above AS BAR COLONCOLON COMMA */
-%nonassoc below_SHARP
%nonassoc SHARP /* simple_expr/toplevel_directive */
%nonassoc below_DOT
%nonassoc DOT
@@ -526,16 +525,10 @@ The precedences must be listed from low to high.
%type <Parsetree.structure> implementation
%start interface /* for interface files */
%type <Parsetree.signature> interface
-%start toplevel_phrase /* for interactive use */
-%type <Parsetree.toplevel_phrase> toplevel_phrase
-%start use_file /* for the #use directive */
-%type <Parsetree.toplevel_phrase list> use_file
%start top_structure_item /* extension, ocaml-ty */
%type <Parsetree.structure_item Location.loc> top_structure_item
%start top_expr /* extension, ocaml-ty */
%type <Parsetree.expression> top_expr
-%start any_longident
-%type <Longident.t> any_longident
%%
/* Entry points */
@@ -546,32 +539,9 @@ implementation:
interface:
signature EOF { List.rev $1 }
;
-toplevel_phrase:
- top_structure SEMISEMI { Ptop_def $1 }
- | seq_expr SEMISEMI { Ptop_def[ghstrexp $startpos $endpos $1] }
- | toplevel_directive SEMISEMI { $1 }
- | EOF { raise End_of_file }
-;
top_expr:
| seq_expr EOF { $1 }
;
-top_structure:
- structure_item { [$1] }
- | structure_item top_structure { $1 :: $2 }
-;
-use_file:
- use_file_tail { $1 }
- | seq_expr use_file_tail { Ptop_def[ghstrexp $startpos $endpos $1] :: $2 }
-;
-use_file_tail:
- EOF { [] }
- | SEMISEMI EOF { [] }
- | SEMISEMI seq_expr use_file_tail { Ptop_def[ghstrexp $startpos $endpos $2] :: $3 }
- | SEMISEMI structure_item use_file_tail { Ptop_def[$2] :: $3 }
- | SEMISEMI toplevel_directive use_file_tail { $2 :: $3 }
- | structure_item use_file_tail { Ptop_def[$1] :: $2 }
- | toplevel_directive use_file_tail { $1 :: $2 }
-;
/* Module expressions */
@@ -1026,7 +996,7 @@ let_pattern:
{ mkpat $startpos $endpos (Ppat_constraint($1, $3)) }
;
expr:
- simple_expr %prec below_SHARP
+ simple_expr
{ $1 }
| simple_expr simple_labeled_expr_list
{ mkexp $startpos $endpos (Pexp_apply($1, List.rev $2)) }
@@ -1068,9 +1038,9 @@ expr:
Fake.app (Fake.app Fake.finally' expr) $7 }
| expr_comma_list %prec below_COMMA
{ mkexp $startpos $endpos (Pexp_tuple(List.rev $1)) }
- | constr_longident simple_expr %prec below_SHARP
+ | constr_longident simple_expr
{ mkexp $startpos $endpos (Pexp_construct(mkrhs $startpos($1) $endpos($1) $1, Some $2, false)) }
- | name_tag simple_expr %prec below_SHARP
+ | name_tag simple_expr
{ mkexp $startpos $endpos (Pexp_variant($1, Some $2)) }
| IF seq_expr THEN expr ELSE expr
{ mkexp $startpos $endpos (Pexp_ifthenelse($2, $4, Some $6)) }
@@ -1150,9 +1120,9 @@ expr:
{ bigarray_set $startpos($1) $endpos($7) $1 $4 $7 }
| label LESSMINUS expr
{ mkexp $startpos $endpos (Pexp_setinstvar(mkrhs $startpos($1) $endpos($1) $1, $3)) }
- | ASSERT simple_expr %prec below_SHARP
+ | ASSERT simple_expr
{ mkassert $startpos $endpos $2 }
- | LAZY simple_expr %prec below_SHARP
+ | LAZY simple_expr
{ mkexp $startpos $endpos (Pexp_lazy ($2)) }
| OBJECT class_structure END
{ mkexp $startpos $endpos (Pexp_object($2)) }
@@ -1162,8 +1132,6 @@ expr:
simple_expr:
val_longident
{ mkexp $startpos $endpos (Pexp_ident (mkrhs $startpos($1) $endpos($1) $1)) }
- | RAISE_LWT
- { mkexp $startpos $endpos (Pexp_ident (mkrhs $startpos($1) $endpos($1) Fake.raise_lwt')) }
| constant
{ mkexp $startpos $endpos (Pexp_constant $1) }
| constr_longident %prec prec_constant_constructor
@@ -1245,19 +1213,19 @@ simple_labeled_expr_list:
{ $2 :: $1 }
;
labeled_simple_expr:
- simple_expr %prec below_SHARP
+ simple_expr
{ ("", $1) }
| label_expr
{ $1 }
;
label_expr:
- LABEL simple_expr %prec below_SHARP
+ LABEL simple_expr
{ ($1, $2) }
| TILDE label_ident
{ $2 }
| QUESTION label_ident
{ ("?" ^ fst $2, snd $2) }
- | OPTLABEL simple_expr %prec below_SHARP
+ | OPTLABEL simple_expr
{ ("?" ^ $1, $2) }
;
label_ident:
@@ -1626,9 +1594,9 @@ core_type2:
;
simple_core_type:
- simple_core_type2 %prec below_SHARP
+ simple_core_type2
{ $1 }
- | LPAREN core_type_comma_list RPAREN %prec below_SHARP
+ | LPAREN core_type_comma_list RPAREN
{ match $2 with [sty] -> sty | _ -> raise Parsing.Parse_error }
;
simple_core_type2:
@@ -1846,34 +1814,6 @@ class_longident:
LIDENT { Lident $1 }
| mod_longident DOT LIDENT { Ldot($1, $3) }
;
-any_longident:
- val_ident { Lident $1 }
- | mod_ext_longident DOT val_ident { Ldot ($1, $3) }
- | mod_ext_longident { $1 }
- | LBRACKET RBRACKET { Lident "[]" }
- | LPAREN RPAREN { Lident "()" }
- | FALSE { Lident "false" }
- | TRUE { Lident "true" }
-;
-
-/* Toplevel directives */
-toplevel_ident:
- val_ident { Lident $1 }
- | mod_ext_longident DOT val_ident { Ldot($1, $3) }
- | mod_ext_longident { $1 }
-;
-
-toplevel_directive_:
- SHARP ident { ($2, Pdir_none) }
- | SHARP ident STRING { ($2, Pdir_string $3) }
- | SHARP ident INT { ($2, Pdir_int $3) }
- | SHARP ident toplevel_ident { ($2, Pdir_ident $3) }
- | SHARP ident FALSE { ($2, Pdir_bool false) }
- | SHARP ident TRUE { ($2, Pdir_bool true) }
-;
-
-toplevel_directive:
- toplevel_directive_ { let name, dir = $1 in Ptop_dir (name, dir) }
/* Miscellaneous */
View
1  chunk_parser_utils.ml
@@ -112,7 +112,6 @@ let token_to_string =
| WITH -> "WITH"
| COMMENT (s,_) -> "COMMENT(" ^ String.escaped s ^ ")"
| LET_LWT -> "LET_LWT"
- | RAISE_LWT -> "RAISE_LWT"
| TRY_LWT -> "TRY_LWT"
| FINALLY_LWT -> "FINALLY_LWT"
| MATCH_LWT -> "MATCH_LWT"
View
5 extensions.ml
@@ -11,7 +11,6 @@ let type_sig env sg =
let ext_lwt =
parse_sig
"module Lwt : sig
- val raise_lwt' : 'a -> 'b Lwt.t
val un_lwt : 'a Lwt.t -> 'a
val in_lwt : 'a Lwt.t -> 'a Lwt.t
val to_lwt : 'a -> 'a Lwt.t
@@ -19,7 +18,9 @@ let ext_lwt =
val un_stream : 'a Lwt_stream.t -> 'a
val unit_lwt : unit Lwt.t -> unit Lwt.t
end",
- parse_sig "val (>>) : unit Lwt.t -> 'a Lwt.t -> 'a Lwt.t"
+ parse_sig
+ "val (>>) : unit Lwt.t -> 'a Lwt.t -> 'a Lwt.t
+ val raise_lwt : exn -> 'a Lwt.t"
let registry = [ext_lwt]
View
1  lexer.mll
@@ -95,7 +95,6 @@ let keyword_table =
(* HACK: lwt extensions *)
"lwt", LET_LWT;
- "raise_lwt", RAISE_LWT;
"try_lwt", TRY_LWT;
"match_lwt", MATCH_LWT;
"finally", FINALLY_LWT;
View
77 outline_parser.mly
@@ -132,7 +132,6 @@
%token <string * Location.t> COMMENT
%token LET_LWT
-%token RAISE_LWT
%token TRY_LWT
%token MATCH_LWT
%token FINALLY_LWT
@@ -168,6 +167,7 @@ The precedences must be listed from low to high.
%nonassoc LET (* above SEMI ( ...; let ... in ...) *)
%nonassoc below_WITH
%nonassoc FUNCTION WITH (* below BAR (match ... with ...) *)
+%nonassoc FINALLY_LWT
%nonassoc AND (* above WITH (module rec A: SIG with ... and ...) *)
%nonassoc THEN (* below ELSE (if ... then ...) *)
%nonassoc ELSE (* (if ... then ... else ...) *)
@@ -190,7 +190,6 @@ The precedences must be listed from low to high.
%nonassoc prec_unary_minus prec_unary_plus (* unary - *)
%nonassoc prec_constant_constructor (* cf. simple_expr (C versus C x) *)
%nonassoc prec_constr_appl (* above AS BAR COLONCOLON COMMA *)
-%nonassoc below_SHARP
%nonassoc SHARP (* simple_expr/toplevel_directive *)
%nonassoc below_DOT
%nonassoc DOT
@@ -206,12 +205,6 @@ The precedences must be listed from low to high.
%type <unit> implementation
%start interface (* for interface files *)
%type <unit> interface
-%start toplevel_phrase (* for interactive use *)
-%type <unit> toplevel_phrase
-%start use_file (* for the #use directive *)
-%type <unit> use_file
-%start any_longident
-%type <unit> any_longident
%%
(* Entry points *)
@@ -226,30 +219,11 @@ implementation:
interface:
signature EOF { () }
;
-toplevel_phrase:
- top_structure SEMISEMI { () }
- | seq_expr SEMISEMI { () }
- | toplevel_directive SEMISEMI { () }
- | EOF { () }
-;
top_structure:
structure_item { () }
| structure_item top_structure { () }
| END { emit_top Leave_module $endpos }
;
-use_file:
- use_file_tail { () }
- | seq_expr use_file_tail { () }
-;
-use_file_tail:
- EOF { () }
- | SEMISEMI EOF { () }
- | SEMISEMI seq_expr use_file_tail { () }
- | SEMISEMI structure_item use_file_tail { () }
- | SEMISEMI toplevel_directive use_file_tail { () }
- | structure_item use_file_tail { () }
- | toplevel_directive use_file_tail { () }
-;
(* Module expressions *)
@@ -304,7 +278,7 @@ structure_tail:
| structure_item structure_tail { () }
;
structure_item:
- LET rec_flag let_bindings
+ LET enter_partial rec_flag let_bindings commit_partial leave_partial
{ emit_top Definition $endpos }
| EXTERNAL val_ident COLON core_type EQUAL primitive_declaration
{ emit_top Definition $endpos }
@@ -681,7 +655,7 @@ leave_partial:
| { leave_partial () }
expr:
- simple_expr %prec below_SHARP
+ simple_expr
{ () }
| simple_expr simple_labeled_expr_list
{ () }
@@ -715,9 +689,9 @@ expr:
{ () } *)
| expr_comma_list %prec below_COMMA
{ () }
- | constr_longident simple_expr %prec below_SHARP
+ | constr_longident simple_expr
{ () }
- | name_tag simple_expr %prec below_SHARP
+ | name_tag simple_expr
{ () }
| IF seq_expr THEN expr ELSE expr
{ () }
@@ -787,9 +761,9 @@ expr:
{ () }
| label LESSMINUS expr
{ () }
- | ASSERT simple_expr %prec below_SHARP
+ | ASSERT simple_expr
{ () }
- | LAZY simple_expr %prec below_SHARP
+ | LAZY simple_expr
{ () }
| OBJECT class_structure END
{ () }
@@ -799,8 +773,6 @@ expr:
simple_expr:
val_longident
{ () }
- | RAISE_LWT
- { () }
| constant
{ () }
| constr_longident %prec prec_constant_constructor
@@ -884,19 +856,19 @@ simple_labeled_expr_list:
{ () }
;
labeled_simple_expr:
- simple_expr %prec below_SHARP
+ simple_expr
{ () }
| label_expr
{ () }
;
label_expr:
- LABEL simple_expr %prec below_SHARP
+ LABEL simple_expr
{ () }
| TILDE label_ident
{ () }
| QUESTION label_ident
{ () }
- | OPTLABEL simple_expr %prec below_SHARP
+ | OPTLABEL simple_expr
{ () }
;
label_ident:
@@ -1241,9 +1213,9 @@ core_type2:
;
simple_core_type:
- simple_core_type2 %prec below_SHARP
+ simple_core_type2
{ () }
- | LPAREN core_type_comma_list RPAREN %prec below_SHARP
+ | LPAREN core_type_comma_list RPAREN
{ () }
;
simple_core_type2:
@@ -1461,31 +1433,6 @@ class_longident:
LIDENT { () }
| mod_longident DOT LIDENT { () }
;
-any_longident:
- val_ident { () }
- | mod_ext_longident DOT val_ident { () }
- | mod_ext_longident { () }
- | LBRACKET RBRACKET { () }
- | LPAREN RPAREN { () }
- | FALSE { () }
- | TRUE { () }
-;
-
-(* Toplevel directives *)
-
-toplevel_ident:
- val_ident { () }
- | mod_ext_longident DOT val_ident { () }
- | mod_ext_longident { () }
-;
-toplevel_directive:
- SHARP ident { () }
- | SHARP ident STRING { () }
- | SHARP ident INT { () }
- | SHARP ident toplevel_ident { () }
- | SHARP ident FALSE { () }
- | SHARP ident TRUE { () }
-;
(* Miscellaneous *)
Please sign in to comment.
Something went wrong with that request. Please try again.