camlspotter avatar camlspotter committed 48f87cd

ratio 0.564827

Comments (0)

Files changed (1)

ocaml/plparser.ml

     <|> case "primitive_declaration_0" (perform
 
            v_1 <-- get_STRING;
-           v_2 <-- self#primitive_declaration ;
-
-           return (fun () ->  v_1 :: v_2 ))
-
-    <!> case "primitive_declaration_1" (perform
-
-           v_1 <-- get_STRING;
-
-           return (fun () ->  [v_1] ))
+           v_2 <-- option (self#primitive_declaration);
+
+           return (fun () ->  
+             match v_2 with
+             | Some v_2 -> v_1 :: v_2 
+             | None -> [v_1]))
 
       )
 
     <!> case "type_kind_5" (perform
 
            token EQUAL;
-           token PRIVATE;
+           v_2 <-- option (token PRIVATE);
            v_3 <-- self#core_type ;
 
-           return (fun () ->  (Ptype_abstract, Private, Some v_3) ))
+           return (fun () -> 
+             match v_2 with
+             | Some () -> (Ptype_abstract, Private, Some v_3)
+             | None -> (Ptype_abstract, Public, Some v_3)))
 
     <!> case "type_kind_4" (perform
 
            token EQUAL;
-           token PRIVATE;
+           v_2 <-- option (token PRIVATE);
            v_3 <-- self#constructor_declarations ;
 
-           return (fun () ->  (Ptype_variant(List.rev v_3), Private, None) ))
-
-    (* type t = F.x must not be parsed as type t = F by "type_kind_6" *)
-    <!> case "type_kind_7" (perform
-
-           token EQUAL;
-           v_2 <-- self#core_type ;
-
-           return (fun () ->  (Ptype_abstract, Public, Some v_2) ))
-
-    <!> case "type_kind_6" (perform
-
-           token EQUAL;
-           v_2 <-- self#constructor_declarations ;
-
-           return (fun () ->  (Ptype_variant(List.rev v_2), Public, None) ))
-
-    <!> case "type_kind_8" (perform
+           return (fun () -> 
+             match v_2 with
+             | Some () -> (Ptype_variant(List.rev v_3), Private, None)
+             | None -> (Ptype_variant(List.rev v_3), Public, None)))
+
+    <|> case "type_kind_8" (perform
 
            (* empty *)
 
     <|> case "with_type_binder_0" (perform
 
            token EQUAL;
-           token PRIVATE;
-
-           return (fun () ->  Private ))
-
-    <!> case "with_type_binder_1" (perform
-
-           token EQUAL;
-
-           return (fun () ->  Public ))
+           v_2 <-- option (token PRIVATE);
+
+           return (fun () -> 
+             match v_2 with
+             | Some () -> Private 
+             | None -> Public ))
 
       )
 
            v_1 <-- self#core_type ;
 
            return (fun () ->  mktyp(Ptyp_poly([], v_1)) ))
-
       )
 
   method core_type = rule "core_type" (fun () -> dummy
                {ptyp_desc = Ptyp_constr(Ldot (Lident "*predef*", "option"), [v_4]);
                 ptyp_loc = v_4.ptyp_loc}, v_6)) ))
 
-    <!> case "core_type2_nonleftrec_1" (perform
+    <|> case "core_type2_nonleftrec_2" (perform
+
+           v_1 <-- get_OPTLABEL;
+           (* v_2 <-- self#core_type2 ; *) (* eats too much *)
+           v_2 <-- self#simple_core_type_or_tuple ; (* ??? *)
+           token MINUSGREATER;
+           v_4 <-- self#core_type2 ;
+
+           return (fun () ->  mktyp(Ptyp_arrow("?" ^ v_1 ,
+               {ptyp_desc = Ptyp_constr(Ldot (Lident "*predef*", "option"), [v_2]);
+                ptyp_loc = v_2.ptyp_loc}, v_4)) ))
+
+    <|> case "core_type2_nonleftrec_1" (perform
 
            v_1 <-- get_LIDENT;
            token COLON;
 
            return (fun () ->  mktyp(Ptyp_arrow(v_1, v_3, v_5)) ))
 
-    <!> case "core_type2_nonleftrec_2" (perform
-
-           v_1 <-- get_OPTLABEL;
-           (* v_2 <-- self#core_type2 ; *) (* eats too much *)
-           v_2 <-- self#simple_core_type_or_tuple ; (* ??? *)
-           token MINUSGREATER;
-           v_4 <-- self#core_type2 ;
-
-           return (fun () ->  mktyp(Ptyp_arrow("?" ^ v_1 ,
-               {ptyp_desc = Ptyp_constr(Ldot (Lident "*predef*", "option"), [v_2]);
-                ptyp_loc = v_2.ptyp_loc}, v_4)) ))
-
     <!> case "core_type2_nonleftrec_3" (perform
 
-           v_1 <-- self#simple_core_type_or_tuple ;
+           v_1 <-- self#simple_core_type_or_tuple ; (* may start with LIDENT *)
 
            return (fun () ->  v_1 ))
 
 
   method simple_core_type = rule "simple_core_type" (fun () -> dummy
     (* to prevent type t = (int * float) s is parsed as type t = (int * float) by simple_core_type_0 *)
-    <!> case "simple_core_type_1" (perform
+    <|> case "simple_core_type_1" (perform
 
            v_1 <-- self#simple_core_type2 ; (* with LPAREN ... *)
            (* %prec below_SHARP *)
            token LBRACKETLESS;
            _v_2 <-- self#opt_bar ;
            v_3 <-- self#row_field_list ;
-           token GREATER;
-           v_5 <-- self#name_tag_list ;
+           v_5 <-- option (perform
+                             token GREATER;
+                             self#name_tag_list); 
            token RBRACKET;
 
-           return (fun () ->  mktyp(Ptyp_variant(List.rev v_3, true, Some (List.rev v_5))) ))
-
-    <!> case "simple_core_type2_nonleftrec_5" (perform
-
-           token LBRACKETLESS;
-           _v_2 <-- self#opt_bar ;
-           v_3 <-- self#row_field_list ;
+           return (fun () -> 
+             match v_5 with
+             | Some v_5 -> mktyp(Ptyp_variant(List.rev v_3, true, Some (List.rev v_5)))
+             | None -> mktyp(Ptyp_variant(List.rev v_3, true, Some []))))
+
+    <|> case "simple_core_type2_nonleftrec_4" (perform
+
+           token LBRACKETGREATER;
+           v_3 <-- option (perform                                               
+                             self#opt_bar ;
+                             self#row_field_list);
            token RBRACKET;
 
-           return (fun () ->  mktyp(Ptyp_variant(List.rev v_3, true, Some [])) ))
+           return (fun () -> 
+             match v_3 with
+             | Some v_3 -> mktyp(Ptyp_variant(List.rev v_3, false, None))
+             | None -> mktyp(Ptyp_variant([], false, None))))
+
+    <|> case "simple_core_type2_nonleftrec_6" (perform
+
+           token LPAREN;
+           token MODULE;
+           v_3 <-- self#package_type ;
+           token RPAREN;
+
+           return (fun () ->  mktyp(Ptyp_package v_3) ))
 
     <!> case "simple_core_type2_nonleftrec_1" (perform
 
 
            return (fun () ->  mktyp(Ptyp_class(v_5, List.rev v_2, v_6)) ))
 
-    <!> case "simple_core_type2_nonleftrec_6" (perform
-
-           token LPAREN;
-           token MODULE;
-           v_3 <-- self#package_type ;
-           token RPAREN;
-
-           return (fun () ->  mktyp(Ptyp_package v_3) ))
-
     <!> case "simple_core_type2_nonleftrec_7" (perform
 
            token LPAREN;
 
            return (fun () ->  mktyp(Ptyp_variant([v_2], true, None)) ))
 
-    <!> case "simple_core_type2_nonleftrec_4" (perform
-
-           token LBRACKETGREATER;
-           _v_2 <-- self#opt_bar ;
-           v_3 <-- self#row_field_list ;
-           token RBRACKET;
-
-           return (fun () ->  mktyp(Ptyp_variant(List.rev v_3, false, None)) ))
-
-    <!> case "simple_core_type2_nonleftrec_11" (perform
-
-           token LBRACKETGREATER;
-           token RBRACKET;
-
-           return (fun () ->  mktyp(Ptyp_variant([], false, None)) ))
-
       )
 
   method simple_core_type2_leftrec v_1 = (dummy
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.