diff options
Diffstat (limited to 'camlp4')
83 files changed, 3958 insertions, 2701 deletions
diff --git a/camlp4/CHANGES b/camlp4/CHANGES index 0cba993c44..2ad2822777 100644 --- a/camlp4/CHANGES +++ b/camlp4/CHANGES @@ -1,3 +1,10 @@ +- [12 may 2004] Added to the camlp4 tools the -version option that prints + the version number, in the same way as the other ocaml tools. +- [12 may 04] Locations are now handled as in OCaml. The main benefit + is that line numbers are now correct in error messages. However, this + slightly changes the interface of a few Camlp4 modules (see ICHANGES). + ** Warning: Some contribs of the camlp4 distribution are broken because + of this change. In particular the scheme/lisp syntaxes. - [20 nov 03] Illegal escape sequences in strings now issue a warning. Camlp4 Version 3.07 diff --git a/camlp4/ICHANGES b/camlp4/ICHANGES index 5b17aaf71d..809a65a669 100644 --- a/camlp4/ICHANGES +++ b/camlp4/ICHANGES @@ -1,6 +1,13 @@ Internal, very small, undocumented, or invisible changes ******************************************************** +- [april-may 04] the following interface files changed in order to + implement OCaml style locations: + camlp4/camlp4/{ast2pt.mli,pcaml.mli,reloc.mli,grammar.mli} + camlp4/lib/{stdpp.mli,token.mli} + The main changes are occurrences of "int" changed into + "Lexing.position" and "int * int" changed into + "Lexing.position * Lexing.position" (or an equivalent type). - [20 nov 03], token.mli: eval_string takes a location as a extra argument (needed to issue a warning). diff --git a/camlp4/Makefile b/camlp4/Makefile index f80090a0b4..4e1e888c9b 100644 --- a/camlp4/Makefile +++ b/camlp4/Makefile @@ -2,9 +2,9 @@ include config/Makefile -DIRS=odyl camlp4 meta etc top ocpp lib man +DIRS=odyl camlp4 meta lib etc top ocpp man FDIRS=odyl camlp4 meta lib -OPTDIRS= lib odyl camlp4 meta etc compile +OPTDIRS=lib odyl camlp4 meta etc compile SHELL=/bin/sh COLD_FILES=ocaml_src/camlp4/argl.ml ocaml_src/camlp4/ast2pt.ml ocaml_src/camlp4/ast2pt.mli ocaml_src/camlp4/mLast.mli ocaml_src/camlp4/pcaml.ml ocaml_src/camlp4/pcaml.mli ocaml_src/camlp4/quotation.ml ocaml_src/camlp4/quotation.mli ocaml_src/camlp4/reloc.ml ocaml_src/camlp4/reloc.mli ocaml_src/camlp4/spretty.ml ocaml_src/camlp4/spretty.mli ocaml_src/lib/extfun.ml ocaml_src/lib/extfun.mli ocaml_src/lib/fstream.ml ocaml_src/lib/fstream.mli ocaml_src/lib/gramext.ml ocaml_src/lib/gramext.mli ocaml_src/lib/grammar.ml ocaml_src/lib/grammar.mli ocaml_src/lib/plexer.ml ocaml_src/lib/plexer.mli ocaml_src/lib/stdpp.ml ocaml_src/lib/stdpp.mli ocaml_src/lib/token.ml ocaml_src/lib/token.mli ocaml_src/meta/pa_extend.ml ocaml_src/meta/pa_extend_m.ml ocaml_src/meta/pa_macro.ml ocaml_src/meta/pa_r.ml ocaml_src/meta/pa_rp.ml ocaml_src/meta/pr_dump.ml ocaml_src/meta/q_MLast.ml ocaml_src/odyl/odyl_main.ml ocaml_src/odyl/odyl_main.mli ocaml_src/odyl/odyl.ml @@ -152,6 +152,29 @@ bootstrap_sources: done); \ done +my_bootstrap_sources: + mkdir ocaml_src.new + @-for i in $(FDIRS); do \ + (mkdir ocaml_src.new/$$i; cd ocaml_src.new/$$i; \ + sed 's/# $$Id.*\$$/# $(TXTGEN)/' ../../$$i/Makefile | \ + sed 's-include ../config-include ../../config-g' | \ + sed 's-../boot-../../boot-g' > Makefile; \ + sed 's/# $$Id.*\$$/# $(TXTGEN)/' ../../$$i/Makefile.Mac | \ + sed 's-:boot-::boot-g' > Makefile.Mac; \ + cp ../../$$i/.depend . ; \ + cp ../../$$i/Makefile.Mac.depend .); \ + done + @-for i in $(FDIRS); do \ + (cd $$i; \ + for j in *.ml*; do \ + echo ============================================; \ + echo ocaml_src.new/$$i/$$j; \ + $$HOME/bin/conv.sh $$j | \ + sed 's/$$Id.*\$$/$(TXTGEN)/' > \ + ../ocaml_src.new/$$i/$$j; \ + done); \ + done + untouch_sources: @-cd ocaml_src; \ for i in $(FDIRS); do \ diff --git a/camlp4/camlp4/.depend b/camlp4/camlp4/.depend index 00ddb5ad46..63efcf4310 100644 --- a/camlp4/camlp4/.depend +++ b/camlp4/camlp4/.depend @@ -7,10 +7,12 @@ argl.cmo: ast2pt.cmi mLast.cmi ../odyl/odyl_main.cmi pcaml.cmi argl.cmx: ast2pt.cmx mLast.cmi ../odyl/odyl_main.cmx pcaml.cmx ast2pt.cmo: $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmi \ $(OTOP)/parsing/longident.cmi mLast.cmi $(OTOP)/parsing/parsetree.cmi \ - ast2pt.cmi + pcaml.cmi ast2pt.cmi ast2pt.cmx: $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmx \ $(OTOP)/parsing/longident.cmx mLast.cmi $(OTOP)/parsing/parsetree.cmi \ - ast2pt.cmi + pcaml.cmx ast2pt.cmi +pcaml.cmo: mLast.cmi quotation.cmi reloc.cmi spretty.cmi pcaml.cmi +pcaml.cmx: mLast.cmi quotation.cmx reloc.cmx spretty.cmx pcaml.cmi crc.cmo: $(OTOP)/otherlibs/dynlink/dynlink.cmi crc.cmx: $(OTOP)/otherlibs/dynlink/dynlink.cmx pcaml.cmo: ast2pt.cmi mLast.cmi quotation.cmi reloc.cmi spretty.cmi pcaml.cmi diff --git a/camlp4/camlp4/Makefile b/camlp4/camlp4/Makefile index 31ffc05057..088da74bbf 100644 --- a/camlp4/camlp4/Makefile +++ b/camlp4/camlp4/Makefile @@ -9,8 +9,8 @@ OCAMLCFLAGS= $(INCLUDES) -warn-error A $(INCLUDES) LINKFLAGS=$(INCLUDES) INTERFACES=-I $(OLIBDIR) Arg Array ArrayLabels Buffer Callback CamlinternalOO Char Complex Digest Filename Format Gc Genlex Hashtbl Int32 Int64 Lazy Lexing List ListLabels Map Marshal MoreLabels Nativeint Obj Oo Parsing Pervasives Printexc Printf Queue Random Scanf Set Sort Stack StdLabels Stream String StringLabels Sys Weak -I ../boot Extfold Extfun Fstream Gramext Grammar Plexer Stdpp Token -I $(OTOP)/utils Config Warnings -I $(OTOP)/parsing Asttypes Location Longident Parsetree -I . Ast2pt MLast Pcaml Quotation Spretty CAMLP4_INTF=$(OTOP)/utils/config.cmi $(OTOP)/utils/warnings.cmi $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmi $(OTOP)/parsing/longident.cmi $(OTOP)/parsing/parsetree.cmi ast2pt.cmi mLast.cmi pcaml.cmi spretty.cmi quotation.cmi -CAMLP4_OBJS=../boot/stdpp.cmo ../boot/token.cmo ../boot/plexer.cmo ../boot/gramext.cmo ../boot/grammar.cmo ../boot/extfold.cmo ../boot/extfun.cmo ../boot/fstream.cmo $(OTOP)/utils/config.cmo quotation.cmo ast2pt.cmo spretty.cmo reloc.cmo pcaml.cmo argl.cmo -CAMLP4_XOBJS=../lib/stdpp.cmx ../lib/token.cmx ../lib/plexer.cmx ../lib/gramext.cmx ../lib/grammar.cmx ../lib/extfold.cmx ../lib/extfun.cmx ../lib/fstream.cmx $(OTOP)/utils/config.cmx quotation.cmx ast2pt.cmx spretty.cmx reloc.cmx pcaml.cmx argl.cmx +CAMLP4_OBJS=../boot/stdpp.cmo ../boot/token.cmo ../boot/plexer.cmo ../boot/gramext.cmo ../boot/grammar.cmo ../boot/extfold.cmo ../boot/extfun.cmo ../boot/fstream.cmo $(OTOP)/utils/config.cmo quotation.cmo spretty.cmo reloc.cmo pcaml.cmo ast2pt.cmo argl.cmo +CAMLP4_XOBJS=../lib/stdpp.cmx ../lib/token.cmx ../lib/plexer.cmx ../lib/gramext.cmx ../lib/grammar.cmx ../lib/extfold.cmx ../lib/extfun.cmx ../lib/fstream.cmx $(OTOP)/utils/config.cmx quotation.cmx spretty.cmx reloc.cmx pcaml.cmx ast2pt.cmx argl.cmx OBJS=../odyl/odyl.cma camlp4.cma CAMLP4M= @@ -22,7 +22,7 @@ opt: $(OBJS:.cma=.cmxa) optp4: $(CAMLP4OPT) $(CAMLP4): $(OBJS) ../odyl/odyl.cmo - $(OCAMLC) $(OBJS) $(CAMLP4M) ../odyl/odyl.cmo -linkall -o $(CAMLP4) + $(OCAMLC) -g $(OBJS) $(CAMLP4M) ../odyl/odyl.cmo -linkall -o $(CAMLP4) $(CAMLP4OPT): $(OBJS:.cma=.cmxa) ../odyl/odyl.cmx $(OCAMLOPT) $(OBJS:.cma=.cmxa) $(CAMLP4M) ../odyl/odyl.cmx -linkall -o $(CAMLP4OPT) diff --git a/camlp4/camlp4/argl.ml b/camlp4/camlp4/argl.ml index 8880f07fd1..b726316e9c 100644 --- a/camlp4/camlp4/argl.ml +++ b/camlp4/camlp4/argl.ml @@ -123,7 +123,7 @@ value print_location loc = if Pcaml.input_file.val <> "-" then let (fname, line, bp, ep) = Stdpp.line_of_loc Pcaml.input_file.val loc in eprintf loc_fmt Pcaml.input_file.val line bp ep - else eprintf "At location %d-%d\n" (fst loc) (snd loc) + else eprintf "At location %d-%d\n" (fst loc).Lexing.pos_cnum (snd loc).Lexing.pos_cnum ; value print_warning loc s = @@ -216,6 +216,12 @@ value file_kind_of_name name = else raise (Arg.Bad ("don't know what to do with " ^ name)) ; +value print_version_string () = + do { + print_string Pcaml.version; print_newline(); exit 0 + } +; + value print_version () = do { eprintf "Camlp4 version %s\n" Pcaml.version; flush stderr; exit 0 @@ -343,7 +349,10 @@ value initial_spec_list = ("-o", Arg.String (fun x -> Pcaml.output_file.val := Some x), "<file> Output on <file> instead of standard output."); ("-v", Arg.Unit print_version, - "Print Camlp4 version and exit.")] + "Print Camlp4 version and exit."); + ("-version", Arg.Unit print_version_string, + "Print Camlp4 version number and exit.") + ] ; value anon_fun x = diff --git a/camlp4/camlp4/ast2pt.ml b/camlp4/camlp4/ast2pt.ml index 09b2e037b3..44ad62f4c2 100644 --- a/camlp4/camlp4/ast2pt.ml +++ b/camlp4/camlp4/ast2pt.ml @@ -19,7 +19,7 @@ open Longident; open Asttypes; value fast = ref False; -value no_constructors_arity = ref False; +value no_constructors_arity = Pcaml.no_constructors_arity; value get_tag x = if Obj.is_block (Obj.repr x) then Obj.tag (Obj.repr x) else Obj.magic x @@ -39,24 +39,35 @@ value string_of_string_token loc s = value glob_fname = ref ""; value mkloc (bp, ep) = - let loc_at n = { - Lexing.pos_fname = glob_fname.val; - Lexing.pos_lnum = 1; (* ddr met -1 ici ??? *) - Lexing.pos_bol = 0; - Lexing.pos_cnum = n + let loc_at n = + { (n) with + Lexing.pos_fname = + if n.Lexing.pos_fname = "" then + if glob_fname.val = "" then + Pcaml.input_file.val + else + glob_fname.val + else + n.Lexing.pos_fname } in {Location.loc_start = loc_at bp; Location.loc_end = loc_at ep; - Location.loc_ghost = False} (* ddr met: bp = 0 && ep = 0 *) + Location.loc_ghost = + bp.Lexing.pos_cnum = 0 && ep.Lexing.pos_cnum = 0} ; value mkghloc (bp, ep) = - let loc_at n = { - Lexing.pos_fname = ""; - Lexing.pos_lnum = 1; - Lexing.pos_bol = 0; - Lexing.pos_cnum = n + let loc_at n = + { (n) with + Lexing.pos_fname = + if n.Lexing.pos_fname = "" then + if glob_fname.val = "" then + Pcaml.input_file.val + else + glob_fname.val + else + n.Lexing.pos_fname } in {Location.loc_start = loc_at bp; @@ -131,22 +142,37 @@ value rec ctyp_fa al = | f -> (f, al) ] ; -value rec ctyp_long_id = - fun +value rec ctyp_long_id_prefix t = + match t with [ TyAcc _ m (TyLid _ s) -> - let (is_cls, li) = ctyp_long_id m in - (is_cls, ldot li s) + error (loc_of_ctyp t) "invalid module expression" | TyAcc _ m (TyUid _ s) -> - let (is_cls, li) = ctyp_long_id m in + let (is_cls, li) = ctyp_long_id_prefix m in (is_cls, ldot li s) | TyApp _ m1 m2 -> - let (is_cls, li1) = ctyp_long_id m1 in - let (_, li2) = ctyp_long_id m2 in + let (is_cls, li1) = ctyp_long_id_prefix m1 in + let (_, li2) = ctyp_long_id_prefix m2 in (is_cls, Lapply li1 li2) | TyUid _ s -> (False, lident s) + | TyLid _ s -> + error (loc_of_ctyp t) "invalid module expression" + | t -> error (loc_of_ctyp t) "invalid module expression" ] +; + +value ctyp_long_id t = + match t with + [ TyAcc _ m (TyLid _ s) -> + let (is_cls, li) = ctyp_long_id_prefix m in + (is_cls, ldot li s) + | TyAcc _ m (TyUid _ s as t) -> + error (loc_of_ctyp t) "invalid type name" + | TyApp _ m1 m2 -> + error (loc_of_ctyp t) "invalid type name" + | TyUid _ s -> + error (loc_of_ctyp t) "invalid type name" | TyLid _ s -> (False, lident s) | TyCls loc sl -> (True, long_id_of_string_list loc sl) - | t -> error (loc_of_ctyp t) "incorrect type" ] + | t -> error (loc_of_ctyp t) "invalid type" ] ; value rec ctyp = @@ -160,7 +186,7 @@ value rec ctyp = match (t1, t2) with [ (t, TyQuo _ s) -> (t, s) | (TyQuo _ s, t) -> (t, s) - | _ -> error loc "incorrect alias type" ] + | _ -> error loc "invalid alias type" ] in mktyp loc (Ptyp_alias (ctyp t) i) | TyAny loc -> mktyp loc Ptyp_any @@ -187,7 +213,7 @@ value rec ctyp = | TyRec loc _ _ -> error loc "record type not allowed here" | TySum loc _ _ -> error loc "sum type not allowed here" | TyTup loc tl -> mktyp loc (Ptyp_tuple (List.map ctyp tl)) - | TyUid loc s -> mktyp loc (Ptyp_constr (lident s) []) + | TyUid loc s as t -> error (loc_of_ctyp t) "invalid type" | TyVrn loc catl ool -> let catl = List.map @@ -391,7 +417,7 @@ value rec patt = match (p1, p2) with [ (p, PaLid _ s) -> (p, s) | (PaLid _ s, p) -> (p, s) - | _ -> error loc "incorrect alias pattern" ] + | _ -> error loc "invalid alias pattern" ] in mkpat loc (Ppat_alias (patt p) i) | PaAnt _ p -> patt p @@ -615,6 +641,14 @@ value rec expr = | ExLmd loc i me e -> mkexp loc (Pexp_letmodule i (module_expr me) (expr e)) | ExMat loc e pel -> mkexp loc (Pexp_match (expr e) (List.map mkpwe pel)) | ExNew loc id -> mkexp loc (Pexp_new (long_id_of_string_list loc id)) + | ExObj loc po cfl -> + let p = + match po with + [ Some p -> p + | None -> PaAny loc ] + in + let cil = List.fold_right class_str_item cfl [] in + mkexp loc (Pexp_object (patt p, cil)) | ExOlb loc _ _ -> error loc "labeled expression not allowed here" | ExOvr loc iel -> mkexp loc (Pexp_override (List.map mkideexp iel)) | ExRec loc lel eo -> diff --git a/camlp4/camlp4/ast2pt.mli b/camlp4/camlp4/ast2pt.mli index 3e7da854f6..cc5a225c08 100644 --- a/camlp4/camlp4/ast2pt.mli +++ b/camlp4/camlp4/ast2pt.mli @@ -14,8 +14,8 @@ value fast : ref bool; value no_constructors_arity : ref bool; -value mkloc : (int * int) -> Location.t; -value long_id_of_string_list : (int * int) -> list string -> Longident.t; +value mkloc : MLast.loc -> Location.t; +value long_id_of_string_list : MLast.loc -> list string -> Longident.t; value str_item : MLast.str_item -> Parsetree.structure -> Parsetree.structure; value interf : list MLast.sig_item -> Parsetree.signature; diff --git a/camlp4/camlp4/mLast.mli b/camlp4/camlp4/mLast.mli index 2d77944318..a4925bcd2c 100644 --- a/camlp4/camlp4/mLast.mli +++ b/camlp4/camlp4/mLast.mli @@ -19,7 +19,7 @@ these values in concrete syntax (see the Camlp4 documentation). See also the file q_MLast.ml in Camlp4 sources. *) -type loc = (int * int); +type loc = (Lexing.position * Lexing.position); type ctyp = [ TyAcc of loc and ctyp and ctyp @@ -104,6 +104,7 @@ and expr = | ExLmd of loc and string and module_expr and expr | ExMat of loc and expr and list (patt * option expr * expr) | ExNew of loc and list string + | ExObj of loc and option patt and list class_str_item | ExOlb of loc and string and option expr | ExOvr of loc and list (string * expr) | ExRec of loc and list (patt * expr) and option expr diff --git a/camlp4/camlp4/pcaml.ml b/camlp4/camlp4/pcaml.ml index 63c083ceba..77f223ff46 100644 --- a/camlp4/camlp4/pcaml.ml +++ b/camlp4/camlp4/pcaml.ml @@ -58,7 +58,10 @@ value input_file = ref ""; value output_file = ref None; value warning_default_function (bp, ep) txt = - do { Printf.eprintf "<W> loc %d %d: %s\n" bp ep txt; flush stderr } + let c1 = bp.Lexing.pos_cnum - bp.Lexing.pos_bol in + let c2 = ep.Lexing.pos_cnum - bp.Lexing.pos_bol in + do { Printf.eprintf "<W> File \"%s\", line %d, chars %d-%d: %s\n" + bp.Lexing.pos_fname bp.Lexing.pos_lnum c1 c2 txt; flush stderr } ; value warning = ref warning_default_function; @@ -82,21 +85,21 @@ List.iter (fun (n, f) -> Quotation.add n f) value quotation_dump_file = ref (None : option string); type err_ctx = - [ Finding | Expanding | ParsingResult of (int * int) and string | Locating ] + [ Finding | Expanding | ParsingResult of MLast.loc and string | Locating ] ; exception Qerror of string and err_ctx and exn; value expand_quotation loc expander shift name str = let new_warning = let warn = warning.val in - fun (bp, ep) txt -> warn (shift + bp, shift + ep) txt + fun (bp, ep) txt -> warn (Reloc.adjust_loc shift (bp, ep)) txt in apply_with_var warning new_warning (fun () -> try expander str with - [ Stdpp.Exc_located (p1, p2) exc -> + [ Stdpp.Exc_located loc exc -> let exc1 = Qerror name Expanding exc in - raise (Stdpp.Exc_located (shift + p1, shift + p2) exc1) + raise (Stdpp.Exc_located (Reloc.adjust_loc shift (Reloc.linearize loc)) exc1) | exc -> let exc1 = Qerror name Expanding exc in raise (Stdpp.Exc_located loc exc1) ]) @@ -106,7 +109,7 @@ value parse_quotation_result entry loc shift name str = let cs = Stream.of_string str in try Grammar.Entry.parse entry cs with [ Stdpp.Exc_located iloc (Qerror _ Locating _ as exc) -> - raise (Stdpp.Exc_located (shift + fst iloc, shift + snd iloc) exc) + raise (Stdpp.Exc_located (Reloc.adjust_loc shift iloc) exc) | Stdpp.Exc_located iloc (Qerror _ Expanding exc) -> let ctx = ParsingResult iloc str in let exc1 = Qerror name ctx exc in @@ -119,18 +122,22 @@ value parse_quotation_result entry loc shift name str = raise (Stdpp.Exc_located loc exc1) ] ; +value ghostify (bp, ep) = + let ghost p = { (p) with Lexing.pos_cnum = 0 } in + (ghost bp, ghost ep) +; + value handle_quotation loc proj in_expr entry reloc (name, str) = let shift = match name with [ "" -> String.length "<<" | _ -> String.length "<:" + String.length name + String.length "<" ] in - let shift = fst loc + shift in + let shift = Reloc.shift_pos shift (fst loc) in let expander = try Quotation.find name with exc -> let exc1 = Qerror name Finding exc in - let loc = (fst loc, shift) in - raise (Stdpp.Exc_located loc exc1) + raise (Stdpp.Exc_located (fst loc, shift) exc1) in let ast = match expander with @@ -140,7 +147,14 @@ value handle_quotation loc proj in_expr entry reloc (name, str) = | Quotation.ExAst fe_fp -> expand_quotation loc (proj fe_fp) shift name str ] in - reloc (fun _ -> loc) shift ast + (* Warning: below, we use a side-effecting function that produces a real location + on its first call, and ghost ones at subsequent calls. *) + reloc + (let zero = ref None in + fun _ -> match zero.val with [ + None -> do { zero.val := Some (ghostify loc) ; loc } + | Some x -> x ]) + shift ast ; value parse_locate entry shift str = @@ -149,12 +163,12 @@ value parse_locate entry shift str = [ Stdpp.Exc_located (p1, p2) exc -> let ctx = Locating in let exc1 = Qerror (Grammar.Entry.name entry) ctx exc in - raise (Stdpp.Exc_located (shift + p1, shift + p2) exc1) ] + raise (Stdpp.Exc_located (Reloc.adjust_loc shift (p1, p2)) exc1) ] ; value handle_locate loc entry ast_f (pos, str) = let s = str in - let loc = (pos, pos + String.length s) in + let loc = (pos, Reloc.shift_pos (String.length s) pos) in let x = parse_locate entry (fst loc) s in ast_f loc x ; @@ -190,11 +204,9 @@ value patt_reloc = Reloc.patt; value rename_id = ref (fun x -> x); value find_line (bp, ep) str = - find 0 1 0 where rec find i line col = - if i == String.length str then (line, 0, col) - else if i == bp then (line, col, col + ep - bp) - else if str.[i] == '\n' then find (succ i) (succ line) 0 - else find (succ i) line (succ col) + (bp.Lexing.pos_lnum, + bp.Lexing.pos_cnum - bp.Lexing.pos_bol, + ep.Lexing.pos_cnum - bp.Lexing.pos_bol) ; value loc_fmt = @@ -355,7 +367,7 @@ value report_error exn = | e -> print_exn exn ] ; -value no_constructors_arity = Ast2pt.no_constructors_arity; +value no_constructors_arity = ref False; (*value no_assert = ref False;*) value arg_spec_list_ref = ref []; diff --git a/camlp4/camlp4/pcaml.mli b/camlp4/camlp4/pcaml.mli index c87ebe39ae..5fddb6b577 100644 --- a/camlp4/camlp4/pcaml.mli +++ b/camlp4/camlp4/pcaml.mli @@ -83,15 +83,15 @@ value no_constructors_arity : ref bool; value sync : ref (Stream.t char -> unit); value handle_expr_quotation : MLast.loc -> (string * string) -> MLast.expr; -value handle_expr_locate : MLast.loc -> (int * string) -> MLast.expr; +value handle_expr_locate : MLast.loc -> (Lexing.position * string) -> MLast.expr; value handle_patt_quotation : MLast.loc -> (string * string) -> MLast.patt; -value handle_patt_locate : MLast.loc -> (int * string) -> MLast.patt; +value handle_patt_locate : MLast.loc -> (Lexing.position * string) -> MLast.patt; value expr_reloc : - (MLast.loc -> MLast.loc) -> int -> MLast.expr -> MLast.expr; + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.expr -> MLast.expr; value patt_reloc : - (MLast.loc -> MLast.loc) -> int -> MLast.patt -> MLast.patt; + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.patt -> MLast.patt; (** To possibly rename identifiers; parsers may call this function when generating their identifiers; default = identity *) @@ -99,7 +99,7 @@ value rename_id : ref (string -> string); (** Allow user to catch exceptions in quotations *) type err_ctx = - [ Finding | Expanding | ParsingResult of (int * int) and string | Locating ] + [ Finding | Expanding | ParsingResult of MLast.loc and string | Locating ] ; exception Qerror of string and err_ctx and exn; @@ -151,7 +151,8 @@ value inter_phrases : ref (option string); (* for system use *) -value warning : ref ((int * int) -> string -> unit); +value warning : ref (MLast.loc -> string -> unit); value expr_eoi : Grammar.Entry.e MLast.expr; value patt_eoi : Grammar.Entry.e MLast.patt; value arg_spec_list : unit -> list (string * Arg.spec * string); +value no_constructors_arity : ref bool; diff --git a/camlp4/camlp4/reloc.ml b/camlp4/camlp4/reloc.ml index 73f81b9b7b..9d0fa7e379 100644 --- a/camlp4/camlp4/reloc.ml +++ b/camlp4/camlp4/reloc.ml @@ -61,136 +61,229 @@ value class_infos a floc sh x = ciNam = x.ciNam; ciExp = a floc sh x.ciExp} ; +(* Debugging positions and locations *) +value eprint_pos msg p = + Printf.eprintf "%s: fname=%s; lnum=%d; bol=%d; cnum=%d\n%!" + msg p.Lexing.pos_fname p.Lexing.pos_lnum p.Lexing.pos_bol p.Lexing.pos_cnum +; + +value eprint_loc (bp, ep) = + do { eprint_pos " P1" bp; eprint_pos " P2" ep } +; + +value check_position msg p = + let ok = + if (p.Lexing.pos_lnum < 0 || + p.Lexing.pos_bol < 0 || + p.Lexing.pos_cnum < 0 || + p.Lexing.pos_cnum < p.Lexing.pos_bol) + then + do { + Printf.eprintf "*** Warning: (%s) strange position ***\n" msg; + eprint_pos msg p; + False + } + else + True in + (ok, p) +; + +value check_location msg ((bp, ep) as loc) = + let ok = + let (ok1,_) = check_position " From: " bp in + let (ok2,_) = check_position " To: " ep in + if ((not ok1) || (not ok2) || + bp.Lexing.pos_lnum > ep.Lexing.pos_lnum || + bp.Lexing.pos_bol > ep.Lexing.pos_bol || + bp.Lexing.pos_cnum > ep.Lexing.pos_cnum) + then + do { + Printf.eprintf "*** Warning: (%s) strange location ***\n" msg; + eprint_loc loc; + False + } + else + True in + (ok, loc) +; + +(* Change a location into linear positions *) +value linearize (bp, ep) = + ( { (bp) with Lexing.pos_lnum = 1; Lexing.pos_bol = 0 }, + { (ep) with Lexing.pos_lnum = 1; Lexing.pos_bol = 0 }) +; + +value shift_pos n p = + { (p) with Lexing.pos_cnum = p.Lexing.pos_cnum + n } +; + +value zero_loc = + { (Lexing.dummy_pos) with Lexing.pos_cnum = 0; Lexing.pos_lnum = 0 }; + + +value adjust_pos globpos local_pos = +{ + Lexing.pos_fname = globpos.Lexing.pos_fname; + Lexing.pos_lnum = globpos.Lexing.pos_lnum + local_pos.Lexing.pos_lnum - 1; + Lexing.pos_bol = + if local_pos.Lexing.pos_lnum <= 1 then + globpos.Lexing.pos_bol + else + local_pos.Lexing.pos_bol + globpos.Lexing.pos_cnum; + Lexing.pos_cnum = local_pos.Lexing.pos_cnum + globpos.Lexing.pos_cnum +}; + +value adjust_loc gpos (p1, p2) = + (adjust_pos gpos p1, adjust_pos gpos p2) +; + +(* Note: in the following, the "let nloc = floc loc in" is necessary + in order to force evaluation order: the "floc" function has a side-effect + that changes all locations produced but the first one into ghost locations *) + value rec patt floc sh = self where rec self = fun - [ PaAcc loc x1 x2 -> PaAcc (floc loc) (self x1) (self x2) - | PaAli loc x1 x2 -> PaAli (floc loc) (self x1) (self x2) - | PaAnt loc x1 -> - patt (fun (p1, p2) -> (sh + fst loc + p1, sh + fst loc + p2)) 0 x1 - | PaAny loc -> PaAny (floc loc) - | PaApp loc x1 x2 -> PaApp (floc loc) (self x1) (self x2) - | PaArr loc x1 -> PaArr (floc loc) (List.map self x1) - | PaChr loc x1 -> PaChr (floc loc) x1 - | PaInt loc x1 -> PaInt (floc loc) x1 - | PaInt32 loc x1 -> PaInt32 (floc loc) x1 - | PaInt64 loc x1 -> PaInt64 (floc loc) x1 - | PaNativeInt loc x1 -> PaNativeInt (floc loc) x1 - | PaFlo loc x1 -> PaFlo (floc loc) x1 - | PaLab loc x1 x2 -> PaLab (floc loc) x1 (option_map self x2) - | PaLid loc x1 -> PaLid (floc loc) x1 + [ PaAcc loc x1 x2 -> let nloc = floc loc in PaAcc nloc (self x1) (self x2) + | PaAli loc x1 x2 -> let nloc = floc loc in PaAli nloc (self x1) (self x2) + | PaAnt loc x1 -> (* Note that antiquotations are parsed by the OCaml parser, passing line numbers and begs of lines *) + patt (fun lloc -> adjust_loc (adjust_pos sh (fst loc)) (linearize lloc)) zero_loc x1 + | PaAny loc -> let nloc = floc loc in PaAny nloc + | PaApp loc x1 x2 -> let nloc = floc loc in PaApp nloc (self x1) (self x2) + | PaArr loc x1 -> let nloc = floc loc in PaArr nloc (List.map self x1) + | PaChr loc x1 -> let nloc = floc loc in PaChr nloc x1 + | PaInt loc x1 -> let nloc = floc loc in PaInt nloc x1 + | PaInt32 loc x1 -> let nloc = floc loc in PaInt32 nloc x1 + | PaInt64 loc x1 -> let nloc = floc loc in PaInt64 nloc x1 + | PaNativeInt loc x1 -> let nloc = floc loc in PaNativeInt nloc x1 + | PaFlo loc x1 -> let nloc = floc loc in PaFlo nloc x1 + | PaLab loc x1 x2 -> let nloc = floc loc in PaLab nloc x1 (option_map self x2) + | PaLid loc x1 -> let nloc = floc loc in PaLid nloc x1 | PaOlb loc x1 x2 -> - PaOlb (floc loc) x1 + let nloc = floc loc in + PaOlb nloc x1 (option_map (fun (x1, x2) -> (self x1, option_map (expr floc sh) x2)) x2) - | PaOrp loc x1 x2 -> PaOrp (floc loc) (self x1) (self x2) - | PaRng loc x1 x2 -> PaRng (floc loc) (self x1) (self x2) + | PaOrp loc x1 x2 -> let nloc = floc loc in PaOrp nloc (self x1) (self x2) + | PaRng loc x1 x2 -> let nloc = floc loc in PaRng nloc (self x1) (self x2) | PaRec loc x1 -> - PaRec (floc loc) (List.map (fun (x1, x2) -> (self x1, self x2)) x1) - | PaStr loc x1 -> PaStr (floc loc) x1 - | PaTup loc x1 -> PaTup (floc loc) (List.map self x1) - | PaTyc loc x1 x2 -> PaTyc (floc loc) (self x1) (ctyp floc sh x2) - | PaTyp loc x1 -> PaTyp (floc loc) x1 - | PaUid loc x1 -> PaUid (floc loc) x1 - | PaVrn loc x1 -> PaVrn (floc loc) x1 ] + let nloc = floc loc in PaRec nloc (List.map (fun (x1, x2) -> (self x1, self x2)) x1) + | PaStr loc x1 -> let nloc = floc loc in PaStr nloc x1 + | PaTup loc x1 -> let nloc = floc loc in PaTup nloc (List.map self x1) + | PaTyc loc x1 x2 -> let nloc = floc loc in PaTyc nloc (self x1) (ctyp floc sh x2) + | PaTyp loc x1 -> let nloc = floc loc in PaTyp nloc x1 + | PaUid loc x1 -> let nloc = floc loc in PaUid nloc x1 + | PaVrn loc x1 -> let nloc = floc loc in PaVrn nloc x1 ] and expr floc sh = self where rec self = fun - [ ExAcc loc x1 x2 -> ExAcc (floc loc) (self x1) (self x2) - | ExAnt loc x1 -> - expr (fun (p1, p2) -> (sh + fst loc + p1, sh + fst loc + p2)) 0 x1 - | ExApp loc x1 x2 -> ExApp (floc loc) (self x1) (self x2) - | ExAre loc x1 x2 -> ExAre (floc loc) (self x1) (self x2) - | ExArr loc x1 -> ExArr (floc loc) (List.map self x1) - | ExAsf loc -> ExAsf (floc loc) - | ExAsr loc x1 -> ExAsr (floc loc) (self x1) - | ExAss loc x1 x2 -> ExAss (floc loc) (self x1) (self x2) - | ExChr loc x1 -> ExChr (floc loc) x1 + [ ExAcc loc x1 x2 -> let nloc = floc loc in ExAcc nloc (self x1) (self x2) + | ExAnt loc x1 -> (* Note that antiquotations are parsed by the OCaml parser, passing line numbers and begs of lines *) + expr (fun lloc -> (adjust_loc (adjust_pos sh (fst loc)) (linearize lloc))) + zero_loc x1 + | ExApp loc x1 x2 -> let nloc = floc loc in ExApp nloc (self x1) (self x2) + | ExAre loc x1 x2 -> let nloc = floc loc in ExAre nloc (self x1) (self x2) + | ExArr loc x1 -> let nloc = floc loc in ExArr nloc (List.map self x1) + | ExAsf loc -> let nloc = floc loc in ExAsf nloc + | ExAsr loc x1 -> let nloc = floc loc in ExAsr nloc (self x1) + | ExAss loc x1 x2 -> let nloc = floc loc in ExAss nloc (self x1) (self x2) + | ExChr loc x1 -> let nloc = floc loc in ExChr nloc x1 | ExCoe loc x1 x2 x3 -> - ExCoe (floc loc) (self x1) (option_map (ctyp floc sh) x2) + let nloc = floc loc in + ExCoe nloc (self x1) (option_map (ctyp floc sh) x2) (ctyp floc sh x3) - | ExFlo loc x1 -> ExFlo (floc loc) x1 + | ExFlo loc x1 -> let nloc = floc loc in ExFlo nloc x1 | ExFor loc x1 x2 x3 x4 x5 -> - ExFor (floc loc) x1 (self x2) (self x3) x4 (List.map self x5) + let nloc = floc loc in ExFor nloc x1 (self x2) (self x3) x4 (List.map self x5) | ExFun loc x1 -> - ExFun (floc loc) + let nloc = floc loc in + ExFun nloc (List.map (fun (x1, x2, x3) -> (patt floc sh x1, option_map self x2, self x3)) x1) - | ExIfe loc x1 x2 x3 -> ExIfe (floc loc) (self x1) (self x2) (self x3) - | ExInt loc x1 -> ExInt (floc loc) x1 - | ExInt32 loc x1 -> ExInt32 (floc loc) x1 - | ExInt64 loc x1 -> ExInt64 (floc loc) x1 - | ExNativeInt loc x1 -> ExNativeInt (floc loc) x1 - | ExLab loc x1 x2 -> ExLab (floc loc) x1 (option_map self x2) - | ExLaz loc x1 -> ExLaz (floc loc) (self x1) + | ExIfe loc x1 x2 x3 -> let nloc = floc loc in ExIfe nloc (self x1) (self x2) (self x3) + | ExInt loc x1 -> let nloc = floc loc in ExInt nloc x1 + | ExInt32 loc x1 -> let nloc = floc loc in ExInt32 nloc x1 + | ExInt64 loc x1 -> let nloc = floc loc in ExInt64 nloc x1 + | ExNativeInt loc x1 -> let nloc = floc loc in ExNativeInt nloc x1 + | ExLab loc x1 x2 -> let nloc = floc loc in ExLab nloc x1 (option_map self x2) + | ExLaz loc x1 -> let nloc = floc loc in ExLaz nloc (self x1) | ExLet loc x1 x2 x3 -> - ExLet (floc loc) x1 + let nloc = floc loc in + ExLet nloc x1 (List.map (fun (x1, x2) -> (patt floc sh x1, self x2)) x2) (self x3) - | ExLid loc x1 -> ExLid (floc loc) x1 + | ExLid loc x1 -> let nloc = floc loc in ExLid nloc x1 | ExLmd loc x1 x2 x3 -> - ExLmd (floc loc) x1 (module_expr floc sh x2) (self x3) + let nloc = floc loc in ExLmd nloc x1 (module_expr floc sh x2) (self x3) | ExMat loc x1 x2 -> - ExMat (floc loc) (self x1) + let nloc = floc loc in + ExMat nloc (self x1) (List.map (fun (x1, x2, x3) -> (patt floc sh x1, option_map self x2, self x3)) x2) - | ExNew loc x1 -> ExNew (floc loc) x1 - | ExOlb loc x1 x2 -> ExOlb (floc loc) x1 (option_map self x2) + | ExNew loc x1 -> let nloc = floc loc in ExNew nloc x1 + | ExObj loc x1 x2 -> + let nloc = floc loc in ExObj nloc (option_map (patt floc sh) x1) + (List.map (class_str_item floc sh) x2) + | ExOlb loc x1 x2 -> let nloc = floc loc in ExOlb nloc x1 (option_map self x2) | ExOvr loc x1 -> - ExOvr (floc loc) (List.map (fun (x1, x2) -> (x1, self x2)) x1) + let nloc = floc loc in + ExOvr nloc (List.map (fun (x1, x2) -> (x1, self x2)) x1) | ExRec loc x1 x2 -> - ExRec (floc loc) + let nloc = floc loc in + ExRec nloc (List.map (fun (x1, x2) -> (patt floc sh x1, self x2)) x1) (option_map self x2) - | ExSeq loc x1 -> ExSeq (floc loc) (List.map self x1) - | ExSnd loc x1 x2 -> ExSnd (floc loc) (self x1) x2 - | ExSte loc x1 x2 -> ExSte (floc loc) (self x1) (self x2) - | ExStr loc x1 -> ExStr (floc loc) x1 + | ExSeq loc x1 -> let nloc = floc loc in ExSeq nloc (List.map self x1) + | ExSnd loc x1 x2 -> let nloc = floc loc in ExSnd nloc (self x1) x2 + | ExSte loc x1 x2 -> let nloc = floc loc in ExSte nloc (self x1) (self x2) + | ExStr loc x1 -> let nloc = floc loc in ExStr nloc x1 | ExTry loc x1 x2 -> - ExTry (floc loc) (self x1) + let nloc = floc loc in + ExTry nloc (self x1) (List.map (fun (x1, x2, x3) -> (patt floc sh x1, option_map self x2, self x3)) x2) - | ExTup loc x1 -> ExTup (floc loc) (List.map self x1) - | ExTyc loc x1 x2 -> ExTyc (floc loc) (self x1) (ctyp floc sh x2) - | ExUid loc x1 -> ExUid (floc loc) x1 - | ExVrn loc x1 -> ExVrn (floc loc) x1 - | ExWhi loc x1 x2 -> ExWhi (floc loc) (self x1) (List.map self x2) ] + | ExTup loc x1 -> let nloc = floc loc in ExTup nloc (List.map self x1) + | ExTyc loc x1 x2 -> let nloc = floc loc in ExTyc nloc (self x1) (ctyp floc sh x2) + | ExUid loc x1 -> let nloc = floc loc in ExUid nloc x1 + | ExVrn loc x1 -> let nloc = floc loc in ExVrn nloc x1 + | ExWhi loc x1 x2 -> let nloc = floc loc in ExWhi nloc (self x1) (List.map self x2) ] and module_type floc sh = self where rec self = fun - [ MtAcc loc x1 x2 -> MtAcc (floc loc) (self x1) (self x2) - | MtApp loc x1 x2 -> MtApp (floc loc) (self x1) (self x2) - | MtFun loc x1 x2 x3 -> MtFun (floc loc) x1 (self x2) (self x3) - | MtLid loc x1 -> MtLid (floc loc) x1 - | MtQuo loc x1 -> MtQuo (floc loc) x1 - | MtSig loc x1 -> MtSig (floc loc) (List.map (sig_item floc sh) x1) - | MtUid loc x1 -> MtUid (floc loc) x1 + [ MtAcc loc x1 x2 -> let nloc = floc loc in MtAcc nloc (self x1) (self x2) + | MtApp loc x1 x2 -> let nloc = floc loc in MtApp nloc (self x1) (self x2) + | MtFun loc x1 x2 x3 -> let nloc = floc loc in MtFun nloc x1 (self x2) (self x3) + | MtLid loc x1 -> let nloc = floc loc in MtLid nloc x1 + | MtQuo loc x1 -> let nloc = floc loc in MtQuo nloc x1 + | MtSig loc x1 -> let nloc = floc loc in MtSig nloc (List.map (sig_item floc sh) x1) + | MtUid loc x1 -> let nloc = floc loc in MtUid nloc x1 | MtWit loc x1 x2 -> - MtWit (floc loc) (self x1) (List.map (with_constr floc sh) x2) ] + let nloc = floc loc in MtWit nloc (self x1) (List.map (with_constr floc sh) x2) ] and sig_item floc sh = self where rec self = fun [ SgCls loc x1 -> - SgCls (floc loc) (List.map (class_infos class_type floc sh) x1) + let nloc = floc loc in SgCls nloc (List.map (class_infos class_type floc sh) x1) | SgClt loc x1 -> - SgClt (floc loc) (List.map (class_infos class_type floc sh) x1) - | SgDcl loc x1 -> SgDcl (floc loc) (List.map self x1) - | SgDir loc x1 x2 -> SgDir (floc loc) x1 x2 - | SgExc loc x1 x2 -> SgExc (floc loc) x1 (List.map (ctyp floc sh) x2) - | SgExt loc x1 x2 x3 -> SgExt (floc loc) x1 (ctyp floc sh x2) x3 - | SgInc loc x1 -> SgInc (floc loc) (module_type floc sh x1) - | SgMod loc x1 x2 -> SgMod (floc loc) x1 (module_type floc sh x2) + let nloc = floc loc in SgClt nloc (List.map (class_infos class_type floc sh) x1) + | SgDcl loc x1 -> let nloc = floc loc in SgDcl nloc (List.map self x1) + | SgDir loc x1 x2 -> let nloc = floc loc in SgDir nloc x1 x2 + | SgExc loc x1 x2 -> let nloc = floc loc in SgExc nloc x1 (List.map (ctyp floc sh) x2) + | SgExt loc x1 x2 x3 -> let nloc = floc loc in SgExt nloc x1 (ctyp floc sh x2) x3 + | SgInc loc x1 -> let nloc = floc loc in SgInc nloc (module_type floc sh x1) + | SgMod loc x1 x2 -> let nloc = floc loc in SgMod nloc x1 (module_type floc sh x2) | SgRecMod loc xxs - -> SgRecMod (floc loc) (List.map (fun (x1,x2) -> (x1, (module_type floc sh x2))) xxs) - | SgMty loc x1 x2 -> SgMty (floc loc) x1 (module_type floc sh x2) - | SgOpn loc x1 -> SgOpn (floc loc) x1 + -> let nloc = floc loc in SgRecMod nloc (List.map (fun (x1,x2) -> (x1, (module_type floc sh x2))) xxs) + | SgMty loc x1 x2 -> let nloc = floc loc in SgMty nloc x1 (module_type floc sh x2) + | SgOpn loc x1 -> let nloc = floc loc in SgOpn nloc x1 | SgTyp loc x1 -> - SgTyp (floc loc) + let nloc = floc loc in + SgTyp nloc (List.map (fun ((loc, x1), x2, x3, x4) -> ((floc loc, x1), x2, ctyp floc sh x3, @@ -198,42 +291,44 @@ and sig_item floc sh = x4)) x1) | SgUse loc x1 x2 -> SgUse loc x1 x2 - | SgVal loc x1 x2 -> SgVal (floc loc) x1 (ctyp floc sh x2) ] + | SgVal loc x1 x2 -> let nloc = floc loc in SgVal nloc x1 (ctyp floc sh x2) ] and with_constr floc sh = self where rec self = fun - [ WcTyp loc x1 x2 x3 -> WcTyp (floc loc) x1 x2 (ctyp floc sh x3) - | WcMod loc x1 x2 -> WcMod (floc loc) x1 (module_expr floc sh x2) ] + [ WcTyp loc x1 x2 x3 -> let nloc = floc loc in WcTyp nloc x1 x2 (ctyp floc sh x3) + | WcMod loc x1 x2 -> let nloc = floc loc in WcMod nloc x1 (module_expr floc sh x2) ] and module_expr floc sh = self where rec self = fun - [ MeAcc loc x1 x2 -> MeAcc (floc loc) (self x1) (self x2) - | MeApp loc x1 x2 -> MeApp (floc loc) (self x1) (self x2) + [ MeAcc loc x1 x2 -> let nloc = floc loc in MeAcc nloc (self x1) (self x2) + | MeApp loc x1 x2 -> let nloc = floc loc in MeApp nloc (self x1) (self x2) | MeFun loc x1 x2 x3 -> - MeFun (floc loc) x1 (module_type floc sh x2) (self x3) - | MeStr loc x1 -> MeStr (floc loc) (List.map (str_item floc sh) x1) - | MeTyc loc x1 x2 -> MeTyc (floc loc) (self x1) (module_type floc sh x2) - | MeUid loc x1 -> MeUid (floc loc) x1 ] + let nloc = floc loc in + MeFun nloc x1 (module_type floc sh x2) (self x3) + | MeStr loc x1 -> let nloc = floc loc in MeStr nloc (List.map (str_item floc sh) x1) + | MeTyc loc x1 x2 -> let nloc = floc loc in MeTyc nloc (self x1) (module_type floc sh x2) + | MeUid loc x1 -> let nloc = floc loc in MeUid nloc x1 ] and str_item floc sh = self where rec self = fun [ StCls loc x1 -> - StCls (floc loc) (List.map (class_infos class_expr floc sh) x1) + let nloc = floc loc in StCls nloc (List.map (class_infos class_expr floc sh) x1) | StClt loc x1 -> - StClt (floc loc) (List.map (class_infos class_type floc sh) x1) - | StDcl loc x1 -> StDcl (floc loc) (List.map self x1) - | StDir loc x1 x2 -> StDir (floc loc) x1 x2 - | StExc loc x1 x2 x3 -> StExc (floc loc) x1 (List.map (ctyp floc sh) x2) x3 - | StExp loc x1 -> StExp (floc loc) (expr floc sh x1) - | StExt loc x1 x2 x3 -> StExt (floc loc) x1 (ctyp floc sh x2) x3 - | StInc loc x1 -> StInc (floc loc) (module_expr floc sh x1) - | StMod loc x1 x2 -> StMod (floc loc) x1 (module_expr floc sh x2) + let nloc = floc loc in StClt nloc (List.map (class_infos class_type floc sh) x1) + | StDcl loc x1 -> let nloc = floc loc in StDcl nloc (List.map self x1) + | StDir loc x1 x2 -> let nloc = floc loc in StDir nloc x1 x2 + | StExc loc x1 x2 x3 -> let nloc = floc loc in StExc nloc x1 (List.map (ctyp floc sh) x2) x3 + | StExp loc x1 -> let nloc = floc loc in StExp nloc (expr floc sh x1) + | StExt loc x1 x2 x3 -> let nloc = floc loc in StExt nloc x1 (ctyp floc sh x2) x3 + | StInc loc x1 -> let nloc = floc loc in StInc nloc (module_expr floc sh x1) + | StMod loc x1 x2 -> let nloc = floc loc in StMod nloc x1 (module_expr floc sh x2) | StRecMod loc nmtmes -> - StRecMod (floc loc) (List.map (fun (n, mt, me) -> (n, module_type floc sh mt, module_expr floc sh me)) nmtmes) - | StMty loc x1 x2 -> StMty (floc loc) x1 (module_type floc sh x2) - | StOpn loc x1 -> StOpn (floc loc) x1 + let nloc = floc loc in StRecMod nloc (List.map (fun (n, mt, me) -> (n, module_type floc sh mt, module_expr floc sh me)) nmtmes) + | StMty loc x1 x2 -> let nloc = floc loc in StMty nloc x1 (module_type floc sh x2) + | StOpn loc x1 -> let nloc = floc loc in StOpn nloc x1 | StTyp loc x1 -> - StTyp (floc loc) + let nloc = floc loc in + StTyp nloc (List.map (fun ((loc, x1), x2, x3, x4) -> ((floc loc, x1), x2, ctyp floc sh x3, @@ -242,48 +337,50 @@ and str_item floc sh = x1) | StUse loc x1 x2 -> StUse loc x1 x2 | StVal loc x1 x2 -> - StVal (floc loc) x1 + let nloc = floc loc in StVal nloc x1 (List.map (fun (x1, x2) -> (patt floc sh x1, expr floc sh x2)) x2) ] and class_type floc sh = self where rec self = fun - [ CtCon loc x1 x2 -> CtCon (floc loc) x1 (List.map (ctyp floc sh) x2) - | CtFun loc x1 x2 -> CtFun (floc loc) (ctyp floc sh x1) (self x2) + [ CtCon loc x1 x2 -> let nloc = floc loc in CtCon nloc x1 (List.map (ctyp floc sh) x2) + | CtFun loc x1 x2 -> let nloc = floc loc in CtFun nloc (ctyp floc sh x1) (self x2) | CtSig loc x1 x2 -> - CtSig (floc loc) (option_map (ctyp floc sh) x1) + let nloc = floc loc in + CtSig nloc (option_map (ctyp floc sh) x1) (List.map (class_sig_item floc sh) x2) ] and class_sig_item floc sh = self where rec self = fun - [ CgCtr loc x1 x2 -> CgCtr (floc loc) (ctyp floc sh x1) (ctyp floc sh x2) - | CgDcl loc x1 -> CgDcl (floc loc) (List.map (class_sig_item floc sh) x1) - | CgInh loc x1 -> CgInh (floc loc) (class_type floc sh x1) - | CgMth loc x1 x2 x3 -> CgMth (floc loc) x1 x2 (ctyp floc sh x3) - | CgVal loc x1 x2 x3 -> CgVal (floc loc) x1 x2 (ctyp floc sh x3) - | CgVir loc x1 x2 x3 -> CgVir (floc loc) x1 x2 (ctyp floc sh x3) ] + [ CgCtr loc x1 x2 -> let nloc = floc loc in CgCtr nloc (ctyp floc sh x1) (ctyp floc sh x2) + | CgDcl loc x1 -> let nloc = floc loc in CgDcl nloc (List.map (class_sig_item floc sh) x1) + | CgInh loc x1 -> let nloc = floc loc in CgInh nloc (class_type floc sh x1) + | CgMth loc x1 x2 x3 -> let nloc = floc loc in CgMth nloc x1 x2 (ctyp floc sh x3) + | CgVal loc x1 x2 x3 -> let nloc = floc loc in CgVal nloc x1 x2 (ctyp floc sh x3) + | CgVir loc x1 x2 x3 -> let nloc = floc loc in CgVir nloc x1 x2 (ctyp floc sh x3) ] and class_expr floc sh = self where rec self = fun - [ CeApp loc x1 x2 -> CeApp (floc loc) (self x1) (expr floc sh x2) - | CeCon loc x1 x2 -> CeCon (floc loc) x1 (List.map (ctyp floc sh) x2) - | CeFun loc x1 x2 -> CeFun (floc loc) (patt floc sh x1) (self x2) + [ CeApp loc x1 x2 -> let nloc = floc loc in CeApp nloc (self x1) (expr floc sh x2) + | CeCon loc x1 x2 -> let nloc = floc loc in CeCon nloc x1 (List.map (ctyp floc sh) x2) + | CeFun loc x1 x2 -> let nloc = floc loc in CeFun nloc (patt floc sh x1) (self x2) | CeLet loc x1 x2 x3 -> - CeLet (floc loc) x1 + let nloc = floc loc in + CeLet nloc x1 (List.map (fun (x1, x2) -> (patt floc sh x1, expr floc sh x2)) x2) (self x3) | CeStr loc x1 x2 -> - CeStr (floc loc) (option_map (patt floc sh) x1) + let nloc = floc loc in CeStr nloc (option_map (patt floc sh) x1) (List.map (class_str_item floc sh) x2) - | CeTyc loc x1 x2 -> CeTyc (floc loc) (self x1) (class_type floc sh x2) ] + | CeTyc loc x1 x2 -> let nloc = floc loc in CeTyc nloc (self x1) (class_type floc sh x2) ] and class_str_item floc sh = self where rec self = fun - [ CrCtr loc x1 x2 -> CrCtr (floc loc) (ctyp floc sh x1) (ctyp floc sh x2) - | CrDcl loc x1 -> CrDcl (floc loc) (List.map (class_str_item floc sh) x1) - | CrInh loc x1 x2 -> CrInh (floc loc) (class_expr floc sh x1) x2 - | CrIni loc x1 -> CrIni (floc loc) (expr floc sh x1) + [ CrCtr loc x1 x2 -> let nloc = floc loc in CrCtr nloc (ctyp floc sh x1) (ctyp floc sh x2) + | CrDcl loc x1 -> let nloc = floc loc in CrDcl nloc (List.map (class_str_item floc sh) x1) + | CrInh loc x1 x2 -> let nloc = floc loc in CrInh nloc (class_expr floc sh x1) x2 + | CrIni loc x1 -> let nloc = floc loc in CrIni nloc (expr floc sh x1) | CrMth loc x1 x2 x3 x4 -> - CrMth (floc loc) x1 x2 (expr floc sh x3) (option_map (ctyp floc sh) x4) - | CrVal loc x1 x2 x3 -> CrVal (floc loc) x1 x2 (expr floc sh x3) - | CrVir loc x1 x2 x3 -> CrVir (floc loc) x1 x2 (ctyp floc sh x3) ] + let nloc = floc loc in CrMth nloc x1 x2 (expr floc sh x3) (option_map (ctyp floc sh) x4) + | CrVal loc x1 x2 x3 -> let nloc = floc loc in CrVal nloc x1 x2 (expr floc sh x3) + | CrVir loc x1 x2 x3 -> let nloc = floc loc in CrVir nloc x1 x2 (ctyp floc sh x3) ] ; diff --git a/camlp4/camlp4/reloc.mli b/camlp4/camlp4/reloc.mli index d1a09a4e1f..637c7558b8 100644 --- a/camlp4/camlp4/reloc.mli +++ b/camlp4/camlp4/reloc.mli @@ -12,5 +12,9 @@ (* $Id$ *) -value patt : (MLast.loc -> MLast.loc) -> int -> MLast.patt -> MLast.patt; -value expr : (MLast.loc -> MLast.loc) -> int -> MLast.expr -> MLast.expr; +value zero_loc : Lexing.position; +value shift_pos : int -> Lexing.position -> Lexing.position; +value adjust_loc : Lexing.position -> MLast.loc -> MLast.loc; +value linearize : MLast.loc -> MLast.loc; +value patt : (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.patt -> MLast.patt; +value expr : (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.expr -> MLast.expr; diff --git a/camlp4/compile/compile.ml b/camlp4/compile/compile.ml index 5fff04b27d..af478774f7 100644 --- a/camlp4/compile/compile.ml +++ b/camlp4/compile/compile.ml @@ -8,7 +8,10 @@ open Gramext; value strict_parsing = ref False; value keywords = ref []; -value loc = (0, 0); +value loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere,nowhere); (* Watch the segmentation faults here! the compiled file must have been loaded in camlp4 with the option pa_extend.cmo -meta_action. *) @@ -101,7 +104,7 @@ value nth_patt_of_act (e, n) = let patt_list = loop e where rec loop = fun - [ <:expr< fun (loc : (int * int)) -> $_$ >> -> [] + [ <:expr< fun (loc : (Lexing.position * Lexing.position)) -> $_$ >> -> [] | <:expr< fun ($p$ : $_$) -> $e$ >> -> [p :: loop e] | <:expr< fun $p$ -> $e$ >> -> [p :: loop e] | _ -> failwith "nth_patt_of_act" ] @@ -111,14 +114,14 @@ value nth_patt_of_act (e, n) = value rec last_patt_of_act = fun - [ <:expr< fun ($p$ : $_$) (loc : (int * int)) -> $_$ >> -> p + [ <:expr< fun ($p$ : $_$) (loc : (Lexing.position * Lexing.position)) -> $_$ >> -> p | <:expr< fun $_$ -> $e$ >> -> last_patt_of_act e | _ -> failwith "last_patt_of_act" ] ; value rec final_action = fun - [ <:expr< fun (loc : (int * int)) -> ($e$ : $_$) >> -> e + [ <:expr< fun (loc : (Lexing.position * Lexing.position)) -> ($e$ : $_$) >> -> e | <:expr< fun $_$ -> $e$ >> -> final_action e | _ -> failwith "final_action" ] ; @@ -560,7 +563,10 @@ value compile () = $expr_list list$ >> in - let loc = (1, 1) in + let loc = + let l1 = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 1 } in + (l1,l1) in ([(si1, loc); (si2, loc)], False) ; diff --git a/camlp4/etc/.depend b/camlp4/etc/.depend index 6349726235..9e7c7c07cd 100644 --- a/camlp4/etc/.depend +++ b/camlp4/etc/.depend @@ -11,6 +11,8 @@ pa_ifdef.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_ifdef.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx pa_lefteval.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_lefteval.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx +pa_lispr.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/reloc.cmi +pa_lispr.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/reloc.cmx pa_lisp.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_lisp.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx pa_lispr.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi @@ -31,10 +33,8 @@ pa_op.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_op.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx pa_ru.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_ru.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx -pa_scheme.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi -pa_scheme.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx -pa_schemer.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi -pa_schemer.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx +pa_schemer.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/reloc.cmi +pa_schemer.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/reloc.cmx pa_sml.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_sml.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx parserify.cmo: ../camlp4/mLast.cmi parserify.cmi diff --git a/camlp4/etc/Makefile b/camlp4/etc/Makefile index 9b8fc705f7..0bbc184fc0 100644 --- a/camlp4/etc/Makefile +++ b/camlp4/etc/Makefile @@ -4,18 +4,17 @@ include ../config/Makefile INCLUDES=-I ../camlp4 -I ../boot -I $(OTOP)/lex OCAMLCFLAGS=-warn-error A $(INCLUDES) -OBJS=q_phony.cmo pa_o.cmo pa_op.cmo pa_oop.cmo pa_ru.cmo pa_format.cmo \ - pa_olabl.cmo pa_sml.cmo pa_lisp.cmo pa_scheme.cmo pa_extfold.cmo \ - pa_extfun.cmo pa_fstream.cmo pa_lefteval.cmo pa_ifdef.cmo pr_r.cmo \ - pr_rp.cmo pr_o.cmo pr_op.cmo pr_scheme.cmo pr_schemep.cmo \ - pr_extend.cmo pr_extfun.cmo pr_null.cmo pr_depend.cmo +# pa_list, pa_scheme dont work any longer because of locations OBJS=q_phony.cmo pa_o.cmo pa_op.cmo pa_oop.cmo pa_ru.cmo pa_format.cmo pa_olabl.cmo pa_sml.cmo pa_lisp.cmo pa_scheme.cmo pa_extfold.cmo pa_extfun.cmo pa_fstream.cmo pa_lefteval.cmo pa_ifdef.cmo pr_r.cmo pr_rp.cmo pr_o.cmo pr_op.cmo pr_scheme.cmo pr_schemep.cmo pr_extend.cmo pr_extfun.cmo pr_null.cmo pr_depend.cmo +OBJS=q_phony.cmo pa_o.cmo pa_op.cmo pa_oop.cmo pa_ru.cmo pa_format.cmo pa_olabl.cmo pa_sml.cmo pa_extfold.cmo pa_extfun.cmo pa_fstream.cmo pa_lefteval.cmo pa_ifdef.cmo pr_r.cmo pr_rp.cmo pr_o.cmo pr_op.cmo pr_scheme.cmo pr_schemep.cmo pr_extend.cmo pr_extfun.cmo pr_null.cmo pr_depend.cmo + OBJSX=$(OBJS:.cmo=.cmx) INTF=pa_o.cmi CAMLP4OM=pa_o.cmo pa_op.cmo ../meta/pr_dump.cmo CAMLP4OMX=$(CAMLP4OM:.cmo=.cmx) CAMLP4SCHM=pa_scheme.cmo ../meta/pr_dump.cmo SHELL=/bin/sh -COUT=$(OBJS) camlp4o$(EXE) camlp4sch$(EXE) +# camlp4schm is broken COUT=$(OBJS) camlp4o$(EXE) #camlp4sch$(EXE) +COUT=$(OBJS) camlp4o$(EXE) COPT=$(OBJSX) camlp4o.opt all: $(COUT) mkcamlp4.sh @@ -100,7 +99,8 @@ install: cp $(OBJS) "$(LIBDIR)/camlp4/." cp $(INTF) "$(LIBDIR)/camlp4/." cp lib.sml "$(LIBDIR)/camlp4/." - cp camlp4o$(EXE) camlp4sch$(EXE) "$(BINDIR)/." +# cp camlp4o$(EXE) camlp4sch$(EXE) "$(BINDIR)/." + cp camlp4o$(EXE) "$(BINDIR)/." if test -f camlp4o.opt; then cp camlp4o.opt "$(BINDIR)/camlp4o.opt$(EXE)"; cp $(OBJSX) $(OBJSX:.cmx=.o) "$(LIBDIR)/camlp4/."; fi cp mkcamlp4.sh "$(BINDIR)/mkcamlp4" chmod a+x "$(BINDIR)/mkcamlp4" diff --git a/camlp4/etc/pa_lispr.ml b/camlp4/etc/pa_lispr.ml index fb150e2096..0f6f88a965 100644 --- a/camlp4/etc/pa_lispr.ml +++ b/camlp4/etc/pa_lispr.ml @@ -76,16 +76,20 @@ value quote = | [: `x; s :] -> char_or_quote_id x s ] ; -value rec lexer kwt = +value rec lexer kwt fname lnum bolpos = + let make_pos p = + {Lexing.pos_fname = fname.val; Lexing.pos_lnum = lnum.val; + Lexing.pos_bol = bolpos.val; Lexing.pos_cnum = p} in + let mkloc (bp, ep) = (make_pos bp, make_pos ep) in parser bp - [ [: `' ' | '\t' | '\n' | '\r'; s :] -> lexer kwt s - | [: `';'; a = semi kwt bp :] -> a - | [: `'(' :] -> (("", "("), (bp, bp + 1)) - | [: `')' :] -> (("", ")"), (bp, bp + 1)) - | [: `'"'; s = string 0 :] ep -> (("STRING", s), (bp, ep)) - | [: `'''; tok = quote :] ep -> (tok, (bp, ep)) - | [: `'<'; tok = less :] ep -> (tok, (bp, ep)) - | [: `('0'..'9' as c); n = number (Buff.store 0 c) :] ep -> (n, (bp, ep)) + [ [: `' ' | '\t' | '\n' | '\r'; s :] -> lexer kwt fname lnum bolpos s + | [: `';'; a = semi kwt mkloc fname lnum bolpos bp :] -> a + | [: `'(' :] -> (("", "("), mkloc(bp, bp + 1)) + | [: `')' :] -> (("", ")"), mkloc(bp, bp + 1)) + | [: `'"'; s = string 0 :] ep -> (("STRING", s), mkloc(bp, ep)) + | [: `'''; tok = quote :] ep -> (tok, mkloc(bp, ep)) + | [: `'<'; tok = less :] ep -> (tok, mkloc(bp, ep)) + | [: `('0'..'9' as c); n = number (Buff.store 0 c) :] ep -> (n, mkloc(bp, ep)) | [: `x; s = ident (Buff.store 0 x) :] ep -> let con = try do { (Hashtbl.find kwt s : unit); "" } with @@ -94,12 +98,12 @@ value rec lexer kwt = [ 'A'..'Z' -> "UIDENT" | _ -> "LIDENT" ] ] in - ((con, s), (bp, ep)) - | [: :] -> (("EOI", ""), (bp, bp + 1)) ] -and semi kwt bp = + ((con, s), mkloc(bp, ep)) + | [: :] -> (("EOI", ""), mkloc(bp, bp + 1)) ] +and semi kwt mkloc fname lnum bolpos bp = parser - [ [: `';'; _ = skip_to_eol; s :] -> lexer kwt s - | [: :] ep -> (("", ";"), (bp, ep)) ] + [ [: `';'; _ = skip_to_eol; s :] -> lexer kwt fname lnum bolpos s + | [: :] ep -> (("", ";"), mkloc(bp, ep)) ] and less = parser [ [: `':'; lab = label 0; `'<' ? "'<' expected"; q = quotation 0 :] -> @@ -139,8 +143,11 @@ value lexer_text (con, prm) = ; value lexer_gmake () = + let bolpos = ref 0 in + let lnum = ref 0 in + let fname = ref "" in let kwt = Hashtbl.create 89 in - {Token.tok_func = Token.lexer_func_of_parser (lexer kwt); + {Token.tok_func = Token.lexer_func_of_parser (lexer kwt fname lnum bolpos); Token.tok_using = lexer_using kwt; Token.tok_removing = fun []; Token.tok_match = Token.default_match; Token.tok_text = lexer_text; Token.tok_comm = None} @@ -378,7 +385,8 @@ and expr_ident_se loc s = if i = String.length s then if i > ibeg then expr_id loc (String.sub s ibeg (i - ibeg)) else - raise_with_loc (fst loc + i - 1, fst loc + i) + raise_with_loc + (Reloc.shift_pos "pa_lisp:expr_ident_se1" (i-1) (fst loc), Reloc.shift_pos "pa_lisp:expr_ident_se2" i (fst loc)) (Stream.Error "expr expected") else if s.[i] = '.' then if i > ibeg then @@ -386,7 +394,8 @@ and expr_ident_se loc s = let e2 = loop (i + 1) (i + 1) in <:expr< $e1$ . $e2$ >> else - raise_with_loc (fst loc + i - 1, fst loc + i + 1) + raise_with_loc + (Reloc.shift_pos "pa_lisp:expr_ident_se3" (i-1) (fst loc), Reloc.shift_pos "pa_lisp:expr_ident_se4" (i+1) (fst loc)) (Stream.Error "expr expected") else loop ibeg (i + 1) in @@ -493,7 +502,8 @@ and patt_ident_se loc s = if i = String.length s then if i > ibeg then patt_id loc (String.sub s ibeg (i - ibeg)) else - raise_with_loc (fst loc + i - 1, fst loc + i) + raise_with_loc + (Reloc.shift_pos "" (i-1) (fst loc), Reloc.shift_pos "" i (fst loc)) (Stream.Error "patt expected") else if s.[i] = '.' then if i > ibeg then @@ -501,7 +511,8 @@ and patt_ident_se loc s = let p2 = loop (i + 1) (i + 1) in <:patt< $p1$ . $p2$ >> else - raise_with_loc (fst loc + i - 1, fst loc + i + 1) + raise_with_loc + (Reloc.shift_pos "" (i-1) (fst loc), Reloc.shift_pos "" (i+1) (fst loc)) (Stream.Error "patt expected") else loop ibeg (i + 1) and ipatt_se se = @@ -554,7 +565,8 @@ and ctyp_ident_se loc s = if i = String.length s then if i > ibeg then ctyp_id loc (String.sub s ibeg (i - ibeg)) else - raise_with_loc (fst loc + i - 1, fst loc + i) + raise_with_loc + (Reloc.shift_pos "" (i-1) (fst loc), Reloc.shift_pos "" i (fst loc)) (Stream.Error "ctyp expected") else if s.[i] = '.' then if i > ibeg then @@ -562,7 +574,8 @@ and ctyp_ident_se loc s = let t2 = loop (i + 1) (i + 1) in <:ctyp< $t1$ . $t2$ >> else - raise_with_loc (fst loc + i - 1, fst loc + i + 1) + raise_with_loc + (Reloc.shift_pos "" (i-1) (fst loc), Reloc.shift_pos "" (i+1) (fst loc)) (Stream.Error "ctyp expected") else loop ibeg (i + 1) and constructor_declaration_se = @@ -617,6 +630,7 @@ Pcaml.parse_implem.val := Grammar.Entry.parse implem; value sexpr = Grammar.Entry.create gram "sexpr"; value atom = Grammar.Entry.create gram "atom"; + EXTEND implem: [ [ st = LIST0 [ s = str_item -> (s, loc) ]; EOI -> (st, False) ] ] diff --git a/camlp4/etc/pa_o.ml b/camlp4/etc/pa_o.ml index 4f27f5ecc6..be34d6cd25 100644 --- a/camlp4/etc/pa_o.ml +++ b/camlp4/etc/pa_o.ml @@ -70,6 +70,7 @@ value mkumin loc f arg = <:expr< $lid:f$ $arg$ >> ] ; + value mklistexp loc last = loop True where rec loop top = fun @@ -407,6 +408,7 @@ and sync_semisemi cs = Pcaml.sync.val := sync; *) + EXTEND GLOBAL: sig_item str_item ctyp patt expr module_type module_expr class_type class_expr class_sig_item class_str_item let_binding type_declaration; @@ -422,11 +424,13 @@ EXTEND <:module_expr< ( $me$ : $mt$ ) >> | "("; me = SELF; ")" -> <:module_expr< $me$ >> ] ] ; + mod_expr_ident: [ LEFTA [ i = SELF; "."; j = SELF -> <:module_expr< $i$ . $j$ >> ] | [ i = UIDENT -> <:module_expr< $uid:i$ >> ] ] ; + str_item: [ "top" [ "exception"; (_, c, tl) = constructor_declaration; b = rebind_exn -> @@ -458,6 +462,7 @@ EXTEND <:str_item< let module $m$ = $mb$ in $e$ >> | e = expr -> <:str_item< $exp:e$ >> ] ] ; + rebind_exn: [ [ "="; sl = mod_ident -> sl | -> [] ] ] @@ -564,7 +569,10 @@ EXTEND "do"; e = SELF; "done" -> <:expr< for $i$ = $e1$ $to:df$ $e2$ do { $list:get_seq e$ } >> | "while"; e1 = SELF; "do"; e2 = SELF; "done" -> - <:expr< while $e1$ do { $list:get_seq e2$ } >> ] + <:expr< while $e1$ do { $list:get_seq e2$ } >> + | "object"; cspo = OPT class_self_patt; cf = class_structure; "end" -> + (* <:expr< object $opt:cspo$ $list:cf$ end >> *) + MLast.ExObj loc cspo cf ] | [ e = SELF; ","; el = LIST1 NEXT SEP "," -> <:expr< ( $list:[e :: el]$ ) >> ] | ":=" NONA @@ -675,10 +683,13 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({Lexing.pos_fname = ""; + Lexing.pos_lnum = 0; + Lexing.pos_bol = 0; + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> (Token.nowhere, x) ] in Pcaml.handle_expr_locate loc x | x = QUOTATION -> @@ -810,10 +821,13 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({Lexing.pos_fname = ""; + Lexing.pos_lnum = 0; + Lexing.pos_bol = 0; + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> (Token.nowhere, x) ] in Pcaml.handle_patt_locate loc x | x = QUOTATION -> diff --git a/camlp4/etc/pa_ocamllex.ml b/camlp4/etc/pa_ocamllex.ml index d567c2ad73..ed550ac9ae 100644 --- a/camlp4/etc/pa_ocamllex.ml +++ b/camlp4/etc/pa_ocamllex.ml @@ -19,7 +19,7 @@ let output_byte buf b = Buffer.add_char buf (Char.chr(48 + (b / 10) mod 10)); Buffer.add_char buf (Char.chr(48 + b mod 10)) -let loc = (-1,-1) +let loc = (Lexing.dummy_pos,Lexing.dummy_pos) let output_array v = let b = Buffer.create (Array.length v * 3) in @@ -256,7 +256,7 @@ EXTEND ]; definition: [ - [ x=LIDENT; pl = LIST0 Pcaml.patt; "="; + [ x=LIDENT; pl = LIST0 Pcaml.patt LEVEL "simple"; "="; short=[ LIDENT "parse" -> false | LIDENT "shortest" -> true ]; OPT "|"; l = LIST0 [ r=regexp; a=action -> (r,a) ] SEP "|" -> { name=x ; shortest=short ; args=pl ; clauses = l } ] diff --git a/camlp4/etc/pa_olabl.ml b/camlp4/etc/pa_olabl.ml index d43b499dfd..77322f8432 100644 --- a/camlp4/etc/pa_olabl.ml +++ b/camlp4/etc/pa_olabl.ml @@ -186,13 +186,18 @@ module Plexer = | [: :] -> () ] ; value error_on_unknown_keywords = ref False; - value next_token_fun find_id_kwd find_spe_kwd = - let err bp ep msg = raise_with_loc (bp, ep) (Token.Error msg) in - let keyword_or_error (bp, ep) s = + value next_token_fun find_id_kwd find_spe_kwd fname lnum bolpos = + let make_pos p = + {Lexing.pos_fname = fname.val; Lexing.pos_lnum = lnum.val; + Lexing.pos_bol = bolpos.val; Lexing.pos_cnum = p} in + let mkloc (bp, ep) = (make_pos bp, make_pos ep) in + + let err loc msg = raise_with_loc loc (Token.Error msg) in + let keyword_or_error (bp,ep) s = try ("", find_spe_kwd s) with [ Not_found -> if error_on_unknown_keywords.val then - err bp ep ("illegal token: " ^ s) + err (mkloc (bp, ep)) ("illegal token: " ^ s) else ("", s) ] in let rec next_token = @@ -280,14 +285,14 @@ module Plexer = [ [: `'"' :] -> get_buff len | [: `'\\'; `c; s :] -> string bp (store (store len '\\') c) s | [: `c; s :] -> string bp (store len c) s - | [: :] ep -> err bp ep "string not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "string not terminated" ] and char bp len = parser [ [: `'''; s :] -> if len = 0 then char bp (store len ''') s else get_buff len | [: `'\\'; `c; s :] -> char bp (store (store len '\\') c) s | [: `c; s :] -> char bp (store len c) s - | [: :] ep -> err bp ep "char not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "char not terminated" ] and locate_or_antiquot bp len = parser [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) @@ -300,7 +305,7 @@ module Plexer = ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) | [: `c; s :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err bp ep "antiquotation not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "antiquotation not terminated" ] and maybe_locate bp len = parser [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) @@ -311,7 +316,7 @@ module Plexer = ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) | [: `c; s :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err bp ep "antiquotation not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "antiquotation not terminated" ] and antiquot bp len = parser [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) @@ -324,13 +329,13 @@ module Plexer = ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) | [: `c; s :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err bp ep "antiquotation not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "antiquotation not terminated" ] and locate_or_antiquot_rest bp len = parser [ [: `'$' :] -> get_buff len | [: `'\\'; `c; s :] -> locate_or_antiquot_rest bp (store len c) s | [: `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: :] ep -> err bp ep "antiquotation not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "antiquotation not terminated" ] and quotation bp len = parser [ [: `'>'; s :] -> maybe_end_quotation bp len s @@ -344,7 +349,7 @@ module Plexer = s :] -> quotation bp len s | [: `c; s :] -> quotation bp (store len c) s - | [: :] ep -> err bp ep "quotation not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "quotation not terminated" ] and maybe_nested_quotation bp len = parser [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" @@ -366,20 +371,20 @@ module Plexer = next_token_loc s | [: `'('; s :] -> maybe_comment bp s | [: `'#'; _ = spaces_tabs; a = linenum bp :] -> a - | [: tok = next_token :] ep -> (tok, (bp, ep)) - | [: _ = Stream.empty :] -> (("EOI", ""), (bp, succ bp)) ] + | [: tok = next_token :] ep -> (tok, mkloc(bp, ep)) + | [: _ = Stream.empty :] -> (("EOI", ""), mkloc(bp, succ bp)) ] and maybe_comment bp = parser [ [: `'*'; s :] -> do { comment bp s; next_token_loc s } | [: :] ep -> let tok = keyword_or_error (bp, ep) "(" in - (tok, (bp, ep)) ] + (tok, mkloc(bp, ep)) ] and comment bp = parser [ [: `'('; s :] -> maybe_nested_comment bp s | [: `'*'; s :] -> maybe_end_comment bp s | [: `c; s :] -> comment bp s - | [: :] ep -> err bp ep "comment not terminated" ] + | [: :] ep -> err (mkloc(bp,ep)) "comment not terminated" ] and maybe_nested_comment bp = parser [ [: `'*'; s :] -> do { comment bp s; comment bp s } @@ -391,7 +396,7 @@ module Plexer = [ [: `'0'..'9'; _ = digits; _ = spaces_tabs; `'"'; _ = any_to_nl; s :] -> next_token_loc s - | [: :] -> (keyword_or_error (bp, bp + 1) "#", (bp, bp + 1)) ] + | [: :] -> (keyword_or_error (bp, bp + 1) "#", mkloc(bp, bp + 1)) ] and spaces_tabs = parser [ [: `' ' | '\t'; s :] -> spaces_tabs s | [: :] -> () ] and digits = parser [ [: `'0'..'9'; s :] -> digits s | [: :] -> () ] @@ -404,7 +409,7 @@ module Plexer = fun cstrm -> try next_token_loc cstrm with [ Stream.Error str -> - err (Stream.count cstrm) (Stream.count cstrm + 1) str ] + err (mkloc(Stream.count cstrm, Stream.count cstrm + 1)) str ] ; value locerr () = invalid_arg "Lexer: location function"; value loct_create () = ref (Array.create 1024 None); @@ -429,9 +434,12 @@ module Plexer = } ; value func kwd_table = + let bolpos = ref 0 in + let lnum = ref 0 in + let fname = ref "" in let find = Hashtbl.find kwd_table in let lex cstrm = - let next_token_loc = next_token_fun find find in + let next_token_loc = next_token_fun find find fname lnum bolpos in let loct = loct_create () in let ts = Stream.from @@ -620,7 +628,7 @@ value mkumin loc f arg = <:expr< $lid:f$ $arg$ >> ] ; -external loc_of_node : 'a -> (int * int) = "%field0"; +external loc_of_node : 'a -> MLast.loc = "%field0"; value mklistexp loc last = loop True where rec loop top = @@ -1139,10 +1147,13 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({Lexing.pos_fname = ""; + Lexing.pos_lnum = 0; + Lexing.pos_bol = 0; + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> (Token.nowhere, x) ] in Pcaml.handle_expr_locate loc x | x = QUOTATION -> @@ -1265,10 +1276,13 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({Lexing.pos_fname = ""; + Lexing.pos_lnum = 0; + Lexing.pos_bol = 0; + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> (Token.nowhere, x) ] in Pcaml.handle_patt_locate loc x | x = QUOTATION -> diff --git a/camlp4/etc/pa_oop.ml b/camlp4/etc/pa_oop.ml index fd56158346..1316bda1b2 100644 --- a/camlp4/etc/pa_oop.ml +++ b/camlp4/etc/pa_oop.ml @@ -109,6 +109,7 @@ value rec cstream gloc = (* Syntax extensions in Ocaml grammar *) + EXTEND GLOBAL: expr; expr: LEVEL "expr1" diff --git a/camlp4/etc/pa_schemer.ml b/camlp4/etc/pa_schemer.ml index a7d64ce4a5..ff2f9447ce 100644 --- a/camlp4/etc/pa_schemer.ml +++ b/camlp4/etc/pa_schemer.ml @@ -111,7 +111,7 @@ value digits kind bp len = parser [ [: d = kind; s :] -> ("INT", digits_under kind (Buff.store len d) s) | [: s :] ep -> - raise_with_loc (bp, ep) (Failure "ill-formed integer constant") ] + raise_with_loc (Reloc.shift_pos "" bp Token.nowhere, Reloc.shift_pos "" ep Token.nowhere) (Failure "ill-formed integer constant") ] ; value base_number kwt bp len = @@ -133,7 +133,7 @@ value char_or_quote_id x = [ [: `''' :] -> ("CHAR", String.make 1 x) | [: s :] ep -> if List.mem x no_ident then - Stdpp.raise_with_loc (ep - 2, ep - 1) (Stream.Error "bad quote") + Stdpp.raise_with_loc (Reloc.shift_pos "" (ep - 2) Token.nowhere, Reloc.shift_pos "" (ep - 1) Token.nowhere) (Stream.Error "bad quote") else let len = Buff.store (Buff.store 0 ''') x in let (s, dot) = ident len s in @@ -168,7 +168,7 @@ value rec lexer kwt = parser [: t = lexer0 kwt; _ = no_dot :] -> t and no_dot = parser [ [: `'.' :] ep -> - Stdpp.raise_with_loc (ep - 1, ep) (Stream.Error "bad dot") + Stdpp.raise_with_loc (Reloc.shift_pos "" (ep - 1) Token.nowhere, Reloc.shift_pos "" ep Token.nowhere) (Stream.Error "bad dot") | [: :] -> () ] and lexer0 kwt = parser bp @@ -262,7 +262,10 @@ value lexer_text (con, prm) = value lexer_gmake () = let kwt = Hashtbl.create 89 in - {Token.tok_func = Token.lexer_func_of_parser (lexer kwt); + {Token.tok_func = + Token.lexer_func_of_parser + (fun s -> let (r,(bp,ep)) = lexer kwt s in + (r, (Reloc.shift_pos "" bp Token.nowhere, Reloc.shift_pos "" ep Token.nowhere))); Token.tok_using = lexer_using kwt; Token.tok_removing = fun []; Token.tok_match = Token.default_match; Token.tok_text = lexer_text; Token.tok_comm = None} diff --git a/camlp4/etc/pa_sml.ml b/camlp4/etc/pa_sml.ml index ee5db540d1..719b52a4bd 100644 --- a/camlp4/etc/pa_sml.ml +++ b/camlp4/etc/pa_sml.ml @@ -912,7 +912,9 @@ EXTEND else match x4 with [ <:module_expr< struct $list:list$ end >> -> - let si = let loc = (0, 0) in <:str_item< open AAA >> in + let si = + let loc = (Token.nowhere, Token.nowhere) in + <:str_item< open AAA >> in <:module_expr< struct $list:[si :: list]$ end >> | _ -> not_impl loc "fctb 1" ] in diff --git a/camlp4/etc/parserify.ml b/camlp4/etc/parserify.ml index c8ce441714..04040858d3 100644 --- a/camlp4/etc/parserify.ml +++ b/camlp4/etc/parserify.ml @@ -1,7 +1,7 @@ (* camlp4r q_MLast.cmo *) (* $Id$ *) -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); type spc = [ SPCterm of (MLast.patt * option MLast.expr) diff --git a/camlp4/etc/pr_extend.ml b/camlp4/etc/pr_extend.ml index 43e3794e17..7a658ed278 100644 --- a/camlp4/etc/pr_extend.ml +++ b/camlp4/etc/pr_extend.ml @@ -99,7 +99,7 @@ value unassoc = value rec unaction = fun - [ <:expr< fun ($lid:locp$ : (int * int)) -> ($a$ : $_$) >> + [ <:expr< fun ($lid:locp$ : (Lexing.position * Lexing.position)) -> ($a$ : $_$) >> when locp = Stdpp.loc_name.val -> let ao = match a with @@ -111,7 +111,7 @@ value rec unaction = let (pl, a) = unaction e in ([p :: pl], a) | <:expr< fun _ -> $e$ >> -> let (pl, a) = unaction e in - (let loc = (0, 0) in [<:patt< _ >> :: pl], a) + (let loc = (Token.nowhere, Token.nowhere) in [<:patt< _ >> :: pl], a) | _ -> raise Not_found ] ; @@ -174,7 +174,7 @@ and unrule = [ <:expr< ($e1$, Gramext.action $e2$) >> -> let (pl, a) = match unaction e2 with - [ ([], None) -> let loc = (0, 0) in ([], Some <:expr< () >>) + [ ([], None) -> let loc = (Token.nowhere, Token.nowhere) in ([], Some <:expr< () >>) | x -> x ] in let sl = unpsymbol_list (List.rev pl) e1 in @@ -389,6 +389,8 @@ value label = | None -> [: :] ] ; +value intloc loc = ((fst loc).Lexing.pos_cnum, (snd loc).Lexing.pos_cnum); + value assoc = fun [ Some Gramext.NonA -> [: `S LR "NONA" :] @@ -419,7 +421,7 @@ value level_list ll k = value entry (e, pos, ll) k = BEbox - [: `LocInfo (MLast.loc_of_expr e) + [: `LocInfo (intloc(MLast.loc_of_expr e)) (HVbox [: `expr e "" [: `S RO ":" :]; position pos :]); `level_list ll [: :]; `HVbox [: `S RO ";"; k :] :] diff --git a/camlp4/etc/pr_extfun.ml b/camlp4/etc/pr_extfun.ml index 4d5c036615..b12527eb39 100644 --- a/camlp4/etc/pr_extfun.ml +++ b/camlp4/etc/pr_extfun.ml @@ -4,7 +4,7 @@ open Pcaml; open Spretty; -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); value expr e dg k = pr_expr.pr_fun "top" e dg k; value patt e dg k = pr_patt.pr_fun "top" e dg k; diff --git a/camlp4/etc/pr_o.ml b/camlp4/etc/pr_o.ml index d87566726a..bf15c54283 100644 --- a/camlp4/etc/pr_o.ml +++ b/camlp4/etc/pr_o.ml @@ -143,7 +143,7 @@ value conv_lab = (* default global loc *) -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); value id_var s = if has_special_chars s || is_infix s then @@ -204,17 +204,19 @@ value private_flag = | _ -> [: :] ] ; +value intloc loc = ((fst loc).Lexing.pos_cnum, (snd loc).Lexing.pos_cnum); + value rec labels loc b vl _ k = match vl with [ [] -> [: b; k :] | [v] -> - [: `label True b v "" k; `LocInfo (snd loc, snd loc) (HVbox [: :]) :] + [: `label True b v "" k; `LocInfo (intloc(snd loc, snd loc)) (HVbox [: :]) :] | [v :: l] -> [: `label False b v "" [: :]; labels loc [: :] l "" k :] ] and label is_last b (loc, f, m, t) _ k = let m = flag "mutable" m in let k = [: if is_last then [: :] else [: `S RO ";" :]; k :] in Hbox - [: `LocInfo loc + [: `LocInfo (intloc loc) (HVbox [: `HVbox [: b; m; `S LR (conv_lab f); `S LR ":" :]; `ctyp t "" [: :] :]); @@ -226,15 +228,15 @@ value rec ctyp_list tel _ k = listws simple_ctyp (S LR "*") tel "" k; value rec variants loc b vl dg k = match vl with [ [] -> [: b; k :] - | [v] -> [: `variant b v "" k; `LocInfo (snd loc, snd loc) (HVbox [: :]) :] + | [v] -> [: `variant b v "" k; `LocInfo (intloc(snd loc, snd loc)) (HVbox [: :]) :] | [v :: l] -> [: `variant b v "" [: :]; variants loc [: `S LR "|" :] l "" k :] ] and variant b (loc, c, tl) _ k = match tl with - [ [] -> HVbox [: `LocInfo loc (HVbox b); `HOVbox [: `S LR c; k :] :] + [ [] -> HVbox [: `LocInfo (intloc loc) (HVbox b); `HOVbox [: `S LR c; k :] :] | _ -> HVbox - [: `LocInfo loc (HVbox b); + [: `LocInfo (intloc loc) (HVbox b); `HOVbox [: `S LR c; `S LR "of"; ctyp_list tl "" k :] :] ] ; @@ -342,7 +344,7 @@ value raise_match_failure (bp, ep) k = if Pcaml.input_file.val <> "-" then Stdpp.line_of_loc Pcaml.input_file.val (bp, ep) else - ("-", 1, bp, ep) + ("-", bp.Lexing.pos_lnum, bp.Lexing.pos_cnum - bp.Lexing.pos_bol, ep.Lexing.pos_cnum - ep.Lexing.pos_bol) in HOVbox [: `S LR "raise"; `S LO "("; `S LR "Match_failure"; `S LO "("; @@ -362,7 +364,7 @@ and let_binding b (p, e) _ k = let (bp2, ep2) = MLast.loc_of_expr e in (min bp1 bp2, max ep1 ep2) in - LocInfo loc (BEbox (let_binding0 b p e k)) + LocInfo (intloc loc) (BEbox (let_binding0 b p e k)) and let_binding0 b p e k = let (pl, e) = match p with @@ -387,7 +389,7 @@ and match_assoc_list loc pel dg k = [: `HVbox [: `S LR "_"; `S LR "->" :]; `raise_match_failure loc k :] | _ -> BEVbox - [: `HVbox [: :]; listwbws match_assoc [: :] (S LR "|") pel "" k :] ] + [: `HVbox [: :]; listwbws match_assoc [: :] (S LR "|") pel dg k :] ] and match_assoc b (p, w, e) dg k = let s = match w with @@ -606,7 +608,7 @@ and class_signature cs k = class_self_type [: `S LR "object" :] cst [: `HVbox [: `HVbox [: :]; list class_sig_item csf "" [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] | _ -> HVbox [: `not_impl "class_signature" cs; k :] ] and class_self_type b cst k = @@ -664,7 +666,7 @@ pr_module_type.pr_levels := [: `S LR "sig"; `HVbox [: `HVbox [: :]; list sig_item s "" [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] :] | e -> fun curr next dg k -> [: `next e dg k :] ]}; {pr_label = ""; pr_box mt x = HVbox x; @@ -697,7 +699,7 @@ pr_module_expr.pr_levels := [: `HVbox [: :]; `HVbox [: `S LR "struct"; list str_item s "" [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] | <:module_expr< functor ($s$ : $mt$) -> $me$ >> -> fun curr next dg k -> @@ -740,7 +742,7 @@ pr_module_expr.pr_levels := pr_sig_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_sig_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_sig_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ <:sig_item< type $list:stl$ >> -> @@ -788,7 +790,7 @@ pr_sig_item.pr_levels := pr_str_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_str_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_str_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ <:str_item< open $i$ >> -> @@ -871,14 +873,14 @@ value ocaml_char = ; pr_expr.pr_levels := - [{pr_label = "top"; pr_box e x = LocInfo (MLast.loc_of_expr e) (HOVbox x); + [{pr_label = "top"; pr_box e x = LocInfo (intloc(MLast.loc_of_expr e)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:expr< do { $list:el$ } >> -> fun curr next dg k -> [: `HVbox [: `HVbox [: :]; listws next (S RO ";") el dg k :] :] | e -> fun curr next dg k -> [: `next e dg k :] ]}; - {pr_label = "expr1"; pr_box e x = LocInfo (MLast.loc_of_expr e) (HOVbox x); + {pr_label = "expr1"; pr_box e x = LocInfo (intloc(MLast.loc_of_expr e)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:expr< let $opt:r$ $p1$ = $e1$ in $e$ >> -> @@ -955,11 +957,11 @@ pr_expr.pr_levels := [: `S LR "fun"; list simple_patt [p :: pl] "" [: `S LR "->" :] :]; - `expr e "" k :] :] + `expr e dg k :] :] | _ -> [: `Vbox [: `HVbox [: :]; `S LR "function"; - `match_assoc_list loc pel "" k :] :] ] + `match_assoc_list loc pel dg k :] :] ] else match pel with [ [] -> @@ -1079,7 +1081,7 @@ pr_expr.pr_levels := `HVbox [: `S LR "else"; `expr1 e dg k :] :] :] ] else match eel_e with - [ (_, <:expr< () >>) -> [: `next e "" k :] + [ (_, <:expr< () >>) -> [: `simple_expr e "" k :] | (eel, e) -> [: `HVbox [: `HVbox [: :]; @@ -1309,7 +1311,7 @@ pr_expr.pr_levels := | Some x -> [: `next e "" k :] ] | e -> fun curr next dg k -> [: `next e dg k :] ]}; {pr_label = "simple"; - pr_box e x = LocInfo (MLast.loc_of_expr e) (HOVbox x); + pr_box e x = LocInfo (intloc(MLast.loc_of_expr e)) (HOVbox x); pr_rules = extfun Extfun.empty with [ ( <:expr< $int:x$ >> | <:expr< $flo:x$ >> ) @@ -1412,7 +1414,7 @@ pr_expr.pr_levels := | e -> fun curr next _ k -> [: `not_impl "expr" e :] ]}]; pr_patt.pr_levels := - [{pr_label = "top"; pr_box p x = LocInfo (MLast.loc_of_patt p) (HOVCbox x); + [{pr_label = "top"; pr_box p x = LocInfo (intloc(MLast.loc_of_patt p)) (HOVCbox x); pr_rules = extfun Extfun.empty with [ <:patt< ($x$ as $lid:y$) >> -> @@ -1480,7 +1482,7 @@ pr_patt.pr_levels := | _ -> [: curr x "" [: :]; `next y "" k :] ] | p -> fun curr next dg k -> [: `next p "" k :] ]}; {pr_label = "simple"; - pr_box p x = LocInfo (MLast.loc_of_patt p) (HOVbox x); + pr_box p x = LocInfo (intloc(MLast.loc_of_patt p)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:patt< $x$ . $y$ >> -> @@ -1574,7 +1576,7 @@ pr_patt.pr_levels := | p -> fun curr next dg k -> [: `next p "" k :] ]}]; pr_ctyp.pr_levels := - [{pr_label = "top"; pr_box t x = LocInfo (MLast.loc_of_ctyp t) (HOVbox x); + [{pr_label = "top"; pr_box t x = LocInfo (intloc(MLast.loc_of_ctyp t)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:ctyp< $x$ as $y$ >> -> @@ -1600,7 +1602,7 @@ pr_ctyp.pr_levels := fun curr next dg k -> listws next (S LR "*") tl "" k | t -> fun curr next dg k -> [: `next t "" k :] ]}; {pr_label = "simple"; - pr_box t x = LocInfo (MLast.loc_of_ctyp t) (HOVbox x); + pr_box t x = LocInfo (intloc(MLast.loc_of_ctyp t)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:ctyp< $t1$ == $t2$ >> -> @@ -1718,7 +1720,7 @@ pr_ctyp.pr_levels := pr_class_str_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_class_str_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_class_str_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ MLast.CrDcl _ s -> @@ -1756,7 +1758,7 @@ pr_class_str_item.pr_levels := pr_class_sig_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_class_sig_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_class_sig_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ MLast.CgCtr _ t1 t2 -> @@ -1834,7 +1836,7 @@ pr_class_expr.pr_levels := [: `HVbox [: `S LR "object"; `class_self_patt_opt csp :]; `HVbox [: `HVbox [: :]; list class_str_item cf "" [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] :] | MLast.CeTyc _ ce ct -> fun curr next dg k -> @@ -2006,16 +2008,16 @@ value apply_printer printer ast = List.fold_left (fun (first, last_pos) (si, (bp, ep)) -> do { - copy_source ic oc first last_pos bp; + copy_source ic oc first last_pos.Lexing.pos_cnum bp.Lexing.pos_cnum; flush oc; - print_pretty pr_ch pr_str pr_nl "" "" maxl.val getcom bp + print_pretty pr_ch pr_str pr_nl "" "" maxl.val getcom bp.Lexing.pos_cnum (printer si "" [: :]); flush oc; (False, ep) }) - (True, 0) ast + (True, Token.nowhere) ast in - do { copy_to_end ic oc first last_pos; flush oc } + do { copy_to_end ic oc first last_pos.Lexing.pos_cnum; flush oc } with x -> do { close_in ic; cleanup (); raise x }; close_in ic; diff --git a/camlp4/etc/pr_op_main.ml b/camlp4/etc/pr_op_main.ml index d7203e6e38..17049e74d0 100644 --- a/camlp4/etc/pr_op_main.ml +++ b/camlp4/etc/pr_op_main.ml @@ -15,7 +15,7 @@ open Pcaml; open Spretty; -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); value expr e dg k = pr_expr.pr_fun "top" e dg k; value patt e dg k = pr_patt.pr_fun "top" e dg k; diff --git a/camlp4/etc/pr_r.ml b/camlp4/etc/pr_r.ml index bedff1936e..7a35ab8ca0 100644 --- a/camlp4/etc/pr_r.ml +++ b/camlp4/etc/pr_r.ml @@ -127,7 +127,7 @@ value flag n f = if f then [: `S LR n :] else [: :]; (* default global loc *) -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); (* extensible printers *) @@ -150,6 +150,8 @@ value class_type x k = pr_class_type.pr_fun "top" x "" k; value class_expr x k = pr_class_expr.pr_fun "top" x "" k; +value intloc loc = ((fst loc).Lexing.pos_cnum, (snd loc).Lexing.pos_cnum); + (* type core *) value rec labels loc b vl k = @@ -158,13 +160,13 @@ value rec labels loc b vl k = | [v] -> [: `HVbox [: `HVbox [: :]; `label True b v [: :]; - `LocInfo (snd loc, snd loc) (HVbox k) :] :] + `LocInfo (intloc(snd loc, snd loc)) (HVbox k) :] :] | [v :: l] -> [: `label False b v [: :]; labels loc [: :] l k :] ] and label is_last b (loc, f, m, t) k = let m = flag "mutable" m in let k = [: if is_last then [: :] else [: `S RO ";" :]; k :] in Hbox - [: `LocInfo loc + [: `LocInfo (intloc loc) (HVbox [: `HVbox [: b; `S LR f; `S LR ":" :]; `HVbox [: m; `ctyp t [: :] :] :]); @@ -179,14 +181,14 @@ value rec variants loc b vl k = | [v] -> [: `HVbox [: `HVbox [: :]; `variant b v [: :]; - `LocInfo (snd loc, snd loc) (HVbox k) :] :] + `LocInfo (intloc(snd loc, snd loc)) (HVbox k) :] :] | [v :: l] -> [: `variant b v [: :]; variants loc [: `S LR "|" :] l k :] ] and variant b (loc, c, tl) k = match tl with - [ [] -> HVbox [: `LocInfo loc (HVbox b); `HOVbox [: `S LR c; k :] :] + [ [] -> HVbox [: `LocInfo (intloc loc) (HVbox b); `HOVbox [: `S LR c; k :] :] | _ -> HVbox - [: `LocInfo loc (HVbox b); + [: `LocInfo (intloc loc) (HVbox b); `HOVbox [: `S LR c; `S LR "of"; ctyp_list tl k :] :] ] ; @@ -321,7 +323,7 @@ and let_binding b (p, e) k = let (bp2, ep2) = MLast.loc_of_expr e in (min bp1 bp2, max ep1 ep2) in - LocInfo loc (BEbox [: let_binding0 [: b; `patt p [: :] :] e [: :]; k :]) + LocInfo (intloc loc) (BEbox [: let_binding0 [: b; `patt p [: :] :] e [: :]; k :]) and let_binding0 b e k = let (pl, e) = expr_fun_args e in match e with @@ -603,7 +605,7 @@ and class_signature cs k = class_self_type [: `S LR "object" :] cst [: `HVbox [: `HVbox [: :]; list class_sig_item csf [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] | _ -> HVbox [: `not_impl "class_signature" cs; k :] ] and class_self_type b cst k = @@ -658,7 +660,7 @@ pr_module_type.pr_levels := [: `S LR "sig"; `HVbox [: `HVbox [: :]; list sig_item s [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] :] | e -> fun curr next dg k -> [: `next e dg k :] ]}; {pr_label = ""; pr_box s x = HVbox x; @@ -695,7 +697,7 @@ pr_module_expr.pr_levels := [: `HVbox [: :]; `HVbox [: `S LR "struct"; list str_item s [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] | <:module_expr< functor ($s$ : $mt$) -> $me$ >> -> fun curr next _ k -> @@ -735,7 +737,7 @@ pr_module_expr.pr_levels := pr_sig_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_sig_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_sig_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ <:sig_item< type $list:stl$ >> -> @@ -788,7 +790,7 @@ pr_sig_item.pr_levels := pr_str_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_str_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_str_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ <:str_item< open $i$ >> -> @@ -885,7 +887,7 @@ END; *) pr_expr.pr_levels := - [{pr_label = "top"; pr_box e x = LocInfo (MLast.loc_of_expr e) (HOVbox x); + [{pr_label = "top"; pr_box e x = LocInfo (intloc(MLast.loc_of_expr e)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:expr< let $opt:r$ $p1$ = $e1$ in $e$ >> -> @@ -1163,7 +1165,7 @@ pr_expr.pr_levels := fun curr next _ k -> [: curr e "" [: :]; `S NO "#"; `label lab; k :] | e -> fun curr next _ k -> [: `next e "" k :] ]}; {pr_label = "simple"; - pr_box e x = LocInfo (MLast.loc_of_expr e) (HOVbox x); + pr_box e x = LocInfo (intloc(MLast.loc_of_expr e)) (HOVbox x); pr_rules = extfun Extfun.empty with [ ( <:expr< $int:x$ >> | <:expr< $flo:x$ >> ) -> @@ -1274,7 +1276,7 @@ pr_expr.pr_levels := pr_patt.pr_levels := [{pr_label = "top"; - pr_box p x = LocInfo (MLast.loc_of_patt p) (HOVbox [: `HVbox [: :]; x :]); + pr_box p x = LocInfo (intloc(MLast.loc_of_patt p)) (HOVbox [: `HVbox [: :]; x :]); pr_rules = extfun Extfun.empty with [ <:patt< $x$ | $y$ >> -> @@ -1301,7 +1303,7 @@ pr_patt.pr_levels := fun curr next _ k -> [: curr x "" [: `S NO "." :]; `next y "" k :] | p -> fun curr next _ k -> [: `next p "" k :] ]}; {pr_label = "simple"; - pr_box p x = LocInfo (MLast.loc_of_patt p) (HOVbox x); + pr_box p x = LocInfo (intloc(MLast.loc_of_patt p)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:patt< [$_$ :: $_$] >> as p -> @@ -1408,7 +1410,7 @@ pr_patt.pr_levels := | p -> fun curr next _ k -> [: `next p "" k :] ]}]; pr_ctyp.pr_levels := - [{pr_label = "top"; pr_box t x = LocInfo (MLast.loc_of_ctyp t) (HOVbox x); + [{pr_label = "top"; pr_box t x = LocInfo (intloc(MLast.loc_of_ctyp t)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:ctyp< $t1$ == $t2$ >> -> @@ -1460,7 +1462,7 @@ pr_ctyp.pr_levels := [: curr t1 "" [: :]; `S NO "."; `next t2 "" k :] | t -> fun curr next _ k -> [: `next t "" k :] ]}; {pr_label = "simple"; - pr_box t x = LocInfo (MLast.loc_of_ctyp t) (HOVbox x); + pr_box t x = LocInfo (intloc(MLast.loc_of_ctyp t)) (HOVbox x); pr_rules = extfun Extfun.empty with [ <:ctyp< ($list:tl$) >> -> @@ -1536,7 +1538,7 @@ pr_ctyp.pr_levels := pr_class_sig_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_class_sig_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_class_sig_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ <:class_sig_item< type $t1$ = $t2$ >> -> @@ -1579,7 +1581,7 @@ pr_class_sig_item.pr_levels := pr_class_str_item.pr_levels := [{pr_label = "top"; - pr_box s x = LocInfo (MLast.loc_of_class_str_item s) (HVbox x); + pr_box s x = LocInfo (intloc(MLast.loc_of_class_str_item s)) (HVbox x); pr_rules = extfun Extfun.empty with [ MLast.CrDcl _ s -> @@ -1664,7 +1666,7 @@ pr_class_expr.pr_levels := [: `HVbox [: `S LR "object"; `class_self_patt_opt csp :]; `HVbox [: `HVbox [: :]; list class_str_item cf [: :]; - `LocInfo (ep, ep) (HVbox [: :]) :]; + `LocInfo (intloc(ep, ep)) (HVbox [: :]) :]; `HVbox [: `S LR "end"; k :] :] :] | MLast.CeTyc _ ce ct -> fun curr next _ k -> @@ -1838,16 +1840,16 @@ value apply_printer printer ast = List.fold_left (fun (first, last_pos) (si, (bp, ep)) -> do { - copy_source ic oc first last_pos bp; + copy_source ic oc first last_pos.Lexing.pos_cnum bp.Lexing.pos_cnum; flush oc; - print_pretty pr_ch pr_str pr_nl "" "" maxl.val getcom bp + print_pretty pr_ch pr_str pr_nl "" "" maxl.val getcom bp.Lexing.pos_cnum (printer si [: :]); flush oc; (False, ep) }) - (True, 0) ast + (True, Token.nowhere) ast in - do { copy_to_end ic oc first last_pos; flush oc } + do { copy_to_end ic oc first last_pos.Lexing.pos_cnum; flush oc } with x -> do { close_in ic; cleanup (); raise x }; close_in ic; diff --git a/camlp4/etc/pr_rp.ml b/camlp4/etc/pr_rp.ml index 3487165e9f..f1782d2323 100644 --- a/camlp4/etc/pr_rp.ml +++ b/camlp4/etc/pr_rp.ml @@ -15,7 +15,7 @@ open Pcaml; open Spretty; -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); value expr e dg k = pr_expr.pr_fun "top" e dg k; value patt e dg k = pr_patt.pr_fun "top" e dg k; diff --git a/camlp4/etc/pr_rp_main.ml b/camlp4/etc/pr_rp_main.ml index 11ad11af77..b1e737af6d 100644 --- a/camlp4/etc/pr_rp_main.ml +++ b/camlp4/etc/pr_rp_main.ml @@ -15,7 +15,7 @@ open Pcaml; open Spretty; -value loc = (0, 0); +value loc = (Token.nowhere, Token.nowhere); value expr e dg k = pr_expr.pr_fun "top" e dg k; value patt e dg k = pr_patt.pr_fun "top" e dg k; diff --git a/camlp4/etc/pr_scheme.ml b/camlp4/etc/pr_scheme.ml index a7c2309488..7c5a230432 100644 --- a/camlp4/etc/pr_scheme.ml +++ b/camlp4/etc/pr_scheme.ml @@ -789,13 +789,13 @@ value apply_printer printer ast = List.fold_left (fun (first, last_pos) (si, (bp, ep)) -> do { - fprintf ppf "@[%a@]@?" copy_source (ic, first, last_pos, bp); + fprintf ppf "@[%a@]@?" copy_source (ic, first, last_pos.Lexing.pos_cnum, bp.Lexing.pos_cnum); fprintf ppf "@[%a@]@?" printer (si, nok); (False, ep) }) - (True, 0) ast + (True, Token.nowhere) ast in - fprintf ppf "@[%a@]@?" copy_to_end (ic, first, last_pos) + fprintf ppf "@[%a@]@?" copy_to_end (ic, first, last_pos.Lexing.pos_cnum) with x -> do { fprintf ppf "@."; close_in ic; raise x }; close_in ic; diff --git a/camlp4/etc/q_phony.ml b/camlp4/etc/q_phony.ml index 841e2bec90..85dd9545da 100644 --- a/camlp4/etc/q_phony.ml +++ b/camlp4/etc/q_phony.ml @@ -23,14 +23,14 @@ Quotation.add "" if t.val = "" then "<<" ^ s ^ ">>" else "<:" ^ t.val ^ "<" ^ s ^ ">>" in - let loc = (0, 0) in + let loc = (Token.nowhere, Token.nowhere) in <:expr< $uid:t$ >>, fun s -> let t = if t.val = "" then "<<" ^ s ^ ">>" else "<:" ^ t.val ^ "<" ^ s ^ ">>" in - let loc = (0, 0) in + let loc = (Token.nowhere, Token.nowhere) in <:patt< $uid:t$ >>)) ; diff --git a/camlp4/lib/.depend b/camlp4/lib/.depend index 0d5adc691f..d7afaebeb2 100644 --- a/camlp4/lib/.depend +++ b/camlp4/lib/.depend @@ -2,6 +2,7 @@ extfold.cmi: gramext.cmi gramext.cmi: token.cmi grammar.cmi: gramext.cmi token.cmi plexer.cmi: token.cmi +stdpp.cmi: token.cmi extfold.cmo: gramext.cmi grammar.cmi extfold.cmi extfold.cmx: gramext.cmx grammar.cmx extfold.cmi extfun.cmo: extfun.cmi @@ -14,7 +15,7 @@ grammar.cmo: gramext.cmi stdpp.cmi token.cmi grammar.cmi grammar.cmx: gramext.cmx stdpp.cmx token.cmx grammar.cmi plexer.cmo: stdpp.cmi token.cmi plexer.cmi plexer.cmx: stdpp.cmx token.cmx plexer.cmi -stdpp.cmo: stdpp.cmi -stdpp.cmx: stdpp.cmi +stdpp.cmo: token.cmi stdpp.cmi +stdpp.cmx: token.cmx stdpp.cmi token.cmo: token.cmi token.cmx: token.cmi diff --git a/camlp4/lib/Makefile b/camlp4/lib/Makefile index ece72d1519..2a61589945 100644 --- a/camlp4/lib/Makefile +++ b/camlp4/lib/Makefile @@ -43,6 +43,6 @@ install: installopt: cp $(TARGET:.cma=.cmxa) *.cmx "$(LIBDIR)/camlp4/." - tar cf - $(TARGET:.cma=.$(A)) | (cd "$(LIBDIR)/camlp4/."; tar xf -) + TARG=`echo "$(TARGET)" | sed -e "s/\.cma\$$/.$(A)/g"` && tar cf - $$TARG | (cd "$(LIBDIR)/camlp4/." && tar xf -) include .depend diff --git a/camlp4/lib/grammar.ml b/camlp4/lib/grammar.ml index b8c22d5073..f6d40bd9ef 100644 --- a/camlp4/lib/grammar.ml +++ b/camlp4/lib/grammar.ml @@ -203,14 +203,14 @@ external grammar_obj : g -> grammar Token.t = "%identity"; value floc = ref (fun _ -> failwith "internal error when computing location"); value loc_of_token_interval bp ep = if bp == ep then - if bp == 0 then (0, 1) + if bp == 0 then (Token.nowhere, Token.succ_pos Token.nowhere) else let a = snd (floc.val (bp - 1)) in - (a, a + 1) + (a, Token.succ_pos a) else let (bp1, bp2) = floc.val bp in let (ep1, ep2) = floc.val (pred ep) in - (if bp1 < ep1 then bp1 else ep1, if bp2 > ep2 then bp2 else ep2) + (if Token.lt_pos bp1 ep1 then bp1 else ep1, if Token.lt_pos ep2 bp2 then bp2 else ep2) ; value rec name_of_symbol entry = @@ -737,8 +737,7 @@ value parse_parsable entry efun (cs, (ts, fun_loc)) = let loc = fun_loc cnt in if token_count.val - 1 <= cnt then loc else (fst loc, snd (fun_loc (token_count.val - 1))) - with _ -> - (Stream.count cs, Stream.count cs + 1) + with _ -> (Token.nowhere, Token.succ_pos Token.nowhere) in do { floc.val := fun_loc; @@ -758,7 +757,7 @@ value parse_parsable entry efun (cs, (ts, fun_loc)) = let loc = get_loc () in do { restore (); raise_with_loc loc exc } | exc -> - let loc = (Stream.count cs, Stream.count cs + 1) in + let loc = (Token.nowhere, Token.succ_pos Token.nowhere) in do { restore (); raise_with_loc loc exc } ] } ; @@ -1009,7 +1008,7 @@ module type ReinitType = sig value reinit_gram : g -> Token.lexer -> unit; end module GGMake (R : ReinitType) (L : GLexerType) = struct type te = L.te; - type parsable = (Stream.t char * (Stream.t te * Token.location_function)); + type parsable = (Stream.t char * (Stream.t te * Token.flocation_function)); value gram = gcreate L.lexer; value parsable cs = (cs, L.lexer.Token.tok_func cs); value tokens = tokens gram; diff --git a/camlp4/lib/grammar.mli b/camlp4/lib/grammar.mli index fe8345fb36..10074b9e7c 100644 --- a/camlp4/lib/grammar.mli +++ b/camlp4/lib/grammar.mli @@ -192,7 +192,7 @@ value create : Token.lexer -> g; (*** For system use *) -value loc_of_token_interval : int -> int -> (int * int); +value loc_of_token_interval : int -> int -> Token.flocation; value extend : list (Gramext.g_entry 'te * option Gramext.position * diff --git a/camlp4/lib/plexer.ml b/camlp4/lib/plexer.ml index 329380b267..7a4fb635c3 100644 --- a/camlp4/lib/plexer.ml +++ b/camlp4/lib/plexer.ml @@ -88,6 +88,9 @@ and digits_under kind len = parser [ [: d = kind; s :] -> digits_under kind (store len d) s | [: `'_'; s :] -> digits_under kind len s + | [: `'l' :] -> ("INT32", get_buff len) + | [: `'L' :] -> ("INT64", get_buff len) + | [: `'n' :] -> ("NATIVEINT", get_buff len) | [: :] -> ("INT", get_buff len) ] and octal = parser [ [: `('0'..'7' as d) :] -> d ] and hexa = parser [ [: `('0'..'9' | 'a'..'f' | 'A'..'F' as d) :] -> d ] @@ -126,388 +129,102 @@ and end_exponent_part_under len = value error_on_unknown_keywords = ref False; value err loc msg = raise_with_loc loc (Token.Error msg); -(* -value next_token_fun dfa find_kwd = - let keyword_or_error loc s = - try (("", find_kwd s), loc) with - [ Not_found -> - if error_on_unknown_keywords.val then err loc ("illegal token: " ^ s) - else (("", s), loc) ] - in - let rec next_token = - parser bp - [ [: `' ' | '\010' | '\013' | '\t' | '\026' | '\012'; s :] -> - next_token s - | [: `'('; s :] -> left_paren bp s - | [: `'#'; s :] -> do { spaces_tabs s; linenum bp s } - | [: `('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c); s :] -> - let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in - (try ("", find_kwd id) with [ Not_found -> ("UIDENT", id) ], loc) - | [: `('a'..'z' | '\223'..'\246' | '\248'..'\255' | '_' as c); s :] -> - let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in - (try ("", find_kwd id) with [ Not_found -> ("LIDENT", id) ], loc) - | [: `('1'..'9' as c); s :] -> - let tok = number (store 0 c) s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'0'; s :] -> - let tok = base_number (store 0 '0') s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'''; s :] -> - match Stream.npeek 3 s with - [ [_; '''; _] | ['\\'; _; _] | ['\x0D'; '\x0A'; '''] -> - let tok = ("CHAR", get_buff (char bp 0 s)) in - let loc = (bp, Stream.count s) in - (tok, loc) - | _ -> keyword_or_error (bp, Stream.count s) "'" ] - | [: `'"'; s :] -> - let tok = ("STRING", get_buff (string bp 0 s)) in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'$'; s :] -> - let tok = dollar bp 0 s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `('!' | '=' | '@' | '^' | '&' | '+' | '-' | '*' | '/' | '%' as c); - s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id - | [: `('~' as c); - a = - parser - [ [: `('a'..'z' as c); len = ident (store 0 c) :] ep -> - (("TILDEIDENT", get_buff len), (bp, ep)) - | [: s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id ] :] -> - a - | [: `('?' as c); - a = - parser - [ [: `('a'..'z' as c); len = ident (store 0 c) :] ep -> - (("QUESTIONIDENT", get_buff len), (bp, ep)) - | [: s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id ] :] -> - a - | [: `'<'; s :] -> less bp s - | [: `(':' as c1); - len = - parser - [ [: `(']' | ':' | '=' | '>' as c2) :] -> store (store 0 c1) c2 - | [: :] -> store 0 c1 ] :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `('>' | '|' as c1); - len = - parser - [ [: `(']' | '}' as c2) :] -> store (store 0 c1) c2 - | [: a = ident2 (store 0 c1) :] -> a ] :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `('[' | '{' as c1); s :] -> - let len = - match Stream.npeek 2 s with - [ ['<'; '<' | ':'] -> store 0 c1 - | _ -> - match s with parser - [ [: `('|' | '<' | ':' as c2) :] -> store (store 0 c1) c2 - | [: :] -> store 0 c1 ] ] - in - let ep = Stream.count s in - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `'.'; - id = - parser - [ [: `'.' :] -> ".." - | [: :] -> if ssd && after_space then " ." else "." ] :] ep -> - keyword_or_error (bp, ep) id - | [: `';'; - id = - parser - [ [: `';' :] -> ";;" - | [: :] -> ";" ] :] ep -> - keyword_or_error (bp, ep) id - | [: `'\\'; s :] ep -> (("LIDENT", get_buff (ident3 0 s)), (bp, ep)) - | [: `c :] ep -> keyword_or_error (bp, ep) (String.make 1 c) - | [: _ = Stream.empty :] -> (("EOI", ""), (bp, succ bp)) ] - and less bp strm = - if no_quotations.val then - match strm with parser - [ [: len = ident2 (store 0 '<') :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id ] - else - match strm with parser - [ [: `'<'; len = quotation bp 0 :] ep -> - (("QUOTATION", ":" ^ get_buff len), (bp, ep)) - | [: `':'; i = parser [: len = ident 0 :] -> get_buff len; - `'<' ? "character '<' expected"; len = quotation bp 0 :] ep -> - (("QUOTATION", i ^ ":" ^ get_buff len), (bp, ep)) - | [: len = ident2 (store 0 '<') :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id ] - and string bp len = - parser - [ [: `'"' :] -> len - | [: `'\\'; `c; s :] -> string bp (store (store len '\\') c) s - | [: `c; s :] -> string bp (store len c) s - | [: :] ep -> err (bp, ep) "string not terminated" ] - and char bp len = - parser - [ [: `'''; s :] -> if len = 0 then char bp (store len ''') s else len - | [: `'\\'; `c; s :] -> char bp (store (store len '\\') c) s - | [: `c; s :] -> char bp (store len c) s - | [: :] ep -> err (bp, ep) "char not terminated" ] - and dollar bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('a'..'z' | 'A'..'Z' as c); s :] -> antiquot bp (store len c) s - | [: `('0'..'9' as c); s :] -> maybe_locate bp (store len c) s - | [: `':'; s :] -> - let k = get_buff len in - ("ANTIQUOT", k ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: s :] -> - if dfa then - match s with parser - [ [: `c :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - else ("", get_buff (ident2 (store 0 '$') s)) ] - and maybe_locate bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('0'..'9' as c); s :] -> maybe_locate bp (store len c) s - | [: `':'; s :] -> - ("LOCATE", get_buff len ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and antiquot bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('a'..'z' | 'A'..'Z' | '0'..'9' as c); s :] -> - antiquot bp (store len c) s - | [: `':'; s :] -> - let k = get_buff len in - ("ANTIQUOT", k ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and locate_or_antiquot_rest bp len = - parser - [ [: `'$' :] -> get_buff len - | [: `'\\'; `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and quotation bp len = - parser - [ [: `'>'; s :] -> maybe_end_quotation bp len s - | [: `'<'; s :] -> - quotation bp (maybe_nested_quotation bp (store len '<') s) s - | [: `'\\'; - len = - parser - [ [: `('>' | '<' | '\\' as c) :] -> store len c - | [: :] -> store len '\\' ]; - s :] -> - quotation bp len s - | [: `c; s :] -> quotation bp (store len c) s - | [: :] ep -> err (bp, ep) "quotation not terminated" ] - and maybe_nested_quotation bp len = - parser - [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" - | [: `':'; len = ident (store len ':'); - a = - parser - [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" - | [: :] -> len ] :] -> - a - | [: :] -> len ] - and maybe_end_quotation bp len = - parser - [ [: `'>' :] -> len - | [: a = quotation bp (store len '>') :] -> a ] - and left_paren bp = - parser - [ [: `'*'; _ = comment bp; a = next_token True :] -> a - | [: :] ep -> keyword_or_error (bp, ep) "(" ] - and comment bp = - parser - [ [: `'('; s :] -> left_paren_in_comment bp s - | [: `'*'; s :] -> star_in_comment bp s - | [: `'"'; _ = string bp 0; s :] -> comment bp s - | [: `'''; s :] -> quote_in_comment bp s - | [: `c; s :] -> comment bp s - | [: :] ep -> err (bp, ep) "comment not terminated" ] - and quote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: `'\013'; s :] -> quote_cr_in_comment bp s - | [: `'\\'; s :] -> quote_antislash_in_comment bp s - | [: `'('; s :] -> quote_left_paren_in_comment bp s - | [: `'*'; s :] -> quote_star_in_comment bp s - | [: `'"'; s :] -> quote_doublequote_in_comment bp s - | [: `_; s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and quote_any_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> comment bp s ] - and quote_cr_in_comment bp = - parser - [ [: `'\010'; s :] -> quote_any_in_comment bp s - | [: s :] -> quote_any_in_comment bp s ] - and quote_left_paren_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> left_paren_in_comment bp s ] - and quote_star_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> star_in_comment bp s ] - and quote_doublequote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: _ = string bp 0; s :] -> comment bp s ] - and quote_antislash_in_comment bp = - parser - [ [: `'''; s :] -> quote_antislash_quote_in_comment bp s - | [: `('\\' | '"' | 'n' | 't' | 'b' | 'r'); s :] -> - quote_any_in_comment bp s - | [: `('0'..'9'); s :] -> quote_antislash_digit_in_comment bp s - | [: `'x'; s :] -> quote_antislash_x_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_quote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> quote_in_comment bp s ] - and quote_antislash_digit_in_comment bp = - parser - [ [: `('0'..'9'); s :] -> quote_antislash_digit2_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_digit2_in_comment bp = - parser - [ [: `('0'..'9'); s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_x_in_comment bp = - parser - [ [: _ = hexa; s :] -> quote_antislash_x_digit_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_x_digit_in_comment bp = - parser - [ [: _ = hexa; s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and left_paren_in_comment bp = - parser - [ [: `'*'; s :] -> do { comment bp s; comment bp s } - | [: a = comment bp :] -> a ] - and star_in_comment bp = - parser - [ [: `')' :] -> () - | [: a = comment bp :] -> a ] - and linedir n s = - match stream_peek_nth n s with - [ Some (' ' | '\t') -> linedir (n + 1) s - | Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> False ] - and linedir_digits n s = - match stream_peek_nth n s with - [ Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> linedir_quote n s ] - and linedir_quote n s = - match stream_peek_nth n s with - [ Some (' ' | '\t') -> linedir_quote (n + 1) s - | Some '"' -> True - | _ -> False ] - and any_to_nl = - parser - [ [: `'\013' | '\010' :] ep -> bolpos.val := ep - | [: `_; s :] -> any_to_nl s - | [: :] -> () ] - in - fun cstrm -> - try - let glex = glexr.val in - let comm_bp = Stream.count cstrm in - let r = next_token False cstrm in - do { - match glex.tok_comm with - [ Some list -> - if fst (snd r) > comm_bp then - let comm_loc = (comm_bp, fst (snd r)) in - glex.tok_comm := Some [comm_loc :: list] - else () - | None -> () ]; - r - } - with - [ Stream.Error str -> - err (Stream.count cstrm, Stream.count cstrm + 1) str ] +(* Debugging positions and locations *) +value eprint_pos msg p = + Printf.eprintf "%s: fname=%s; lnum=%d; bol=%d; cnum=%d\n%!" + msg p.Lexing.pos_fname p.Lexing.pos_lnum p.Lexing.pos_bol p.Lexing.pos_cnum +; + +value eprint_loc (bp, ep) = + do { eprint_pos "P1" bp; eprint_pos "P2" ep } +; + +value check_location msg ((bp, ep) as loc) = + let ok = + if (bp.Lexing.pos_lnum > ep.Lexing.pos_lnum || + bp.Lexing.pos_bol > ep.Lexing.pos_bol || + bp.Lexing.pos_cnum > ep.Lexing.pos_cnum || + bp.Lexing.pos_lnum < 0 || ep.Lexing.pos_lnum < 0 || + bp.Lexing.pos_bol < 0 || ep.Lexing.pos_bol < 0 || + bp.Lexing.pos_cnum < 0 || ep.Lexing.pos_cnum < 0) + (* Here, we don't check + bp.Lexing.pos_cnum < bp.Lexing.pos_bol || ep.Lexing.pos_cnum < bp.Lexing.pos_bol + since the lexer is called on antiquotations, with cnum=0, but lnum and bolpos + have "correct" values *) + then + do { + Printf.eprintf "*** Warning: (%s) strange positions ***\n" msg; + eprint_loc loc; + False + } + else + True in + (ok, loc) ; -*) -value next_token_fun dfa ssd find_kwd bolpos glexr = - let keyword_or_error loc s = - try (("", find_kwd s), loc) with - [ Not_found -> +value next_token_fun dfa ssd find_kwd fname lnum bolpos glexr = + let make_pos p = + {Lexing.pos_fname = fname.val; Lexing.pos_lnum = lnum.val; + Lexing.pos_bol = bolpos.val; Lexing.pos_cnum = p} in + let mkloc (bp, ep) = (make_pos bp, make_pos ep) in + let keyword_or_error (bp,ep) s = + let loc = mkloc (bp, ep) in + try (("", find_kwd s), loc) with + [ Not_found -> if error_on_unknown_keywords.val then err loc ("illegal token: " ^ s) else (("", s), loc) ] in - let error_if_keyword ( ((_,id), loc) as a) = + let error_if_keyword ( ((_,id) as a), bep) = + let loc = mkloc bep in try do { ignore(find_kwd id); err loc ("illegal use of a keyword as a label: " ^ id) } - with [ Not_found -> a ] + with [ Not_found -> (a, loc) ] in let rec next_token after_space = parser bp - [ [: `'\010' | '\013'; s :] ep -> - do { bolpos.val := ep; next_token True s } + [ [: `'\010'; s :] ep -> + do { bolpos.val := ep; incr lnum; next_token True s } + | [: `'\013'; s :] ep -> + let ep = + match Stream.peek s with + [ Some '\010' -> do { Stream.junk s; ep+1 } + | _ -> ep ] in + do { bolpos.val := ep; incr lnum; next_token True s } | [: `' ' | '\t' | '\026' | '\012'; s :] -> next_token True s | [: `'#' when bp = bolpos.val; s :] -> - if linedir 1 s then do { any_to_nl s; next_token True s } + if linedir 1 s then do { line_directive s; next_token True s } else keyword_or_error (bp, bp + 1) "#" | [: `'('; s :] -> left_paren bp s | [: `('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c); s :] -> let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, (Stream.count s)) in (try ("", find_kwd id) with [ Not_found -> ("UIDENT", id) ], loc) | [: `('a'..'z' | '\223'..'\246' | '\248'..'\255' | '_' as c); s :] -> let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, (Stream.count s)) in (try ("", find_kwd id) with [ Not_found -> ("LIDENT", id) ], loc) | [: `('1'..'9' as c); s :] -> let tok = number (store 0 c) s in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, (Stream.count s)) in (tok, loc) | [: `'0'; s :] -> let tok = base_number (store 0 '0') s in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, (Stream.count s)) in (tok, loc) | [: `'''; s :] -> match Stream.npeek 2 s with [ [_; '''] | ['\\'; _] -> let tok = ("CHAR", get_buff (char bp 0 s)) in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, (Stream.count s)) in (tok, loc) | _ -> keyword_or_error (bp, Stream.count s) "'" ] | [: `'"'; s :] -> let tok = ("STRING", get_buff (string bp 0 s)) in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, Stream.count s) in (tok, loc) | [: `'$'; s :] -> let tok = dollar bp 0 s in - let loc = (bp, Stream.count s) in + let loc = mkloc (bp, Stream.count s) in (tok, loc) | [: `('!' | '=' | '@' | '^' | '&' | '+' | '-' | '*' | '/' | '%' as c); s :] -> @@ -519,7 +236,7 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = [ [: `('a'..'z' as c); len = ident (store 0 c); s :] ep -> let id = get_buff len in match s with parser - [ [: `':' :] eb -> error_if_keyword (("LABEL", id), (bp,ep)) + [ [: `':' :] eb -> error_if_keyword (("LABEL", id), (bp, ep)) | [: :] -> error_if_keyword (("TILDEIDENT", id), (bp, ep)) ] | [: s :] -> let id = get_buff (ident2 (store 0 c) s) in @@ -577,9 +294,9 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = [ [: `';' :] -> ";;" | [: :] -> ";" ] :] ep -> keyword_or_error (bp, ep) id - | [: `'\\'; s :] ep -> (("LIDENT", get_buff (ident3 0 s)), (bp, ep)) + | [: `'\\'; s :] ep -> (("LIDENT", get_buff (ident3 0 s)), mkloc (bp, ep)) | [: `c :] ep -> keyword_or_error (bp, ep) (String.make 1 c) - | [: _ = Stream.empty :] -> (("EOI", ""), (bp, succ bp)) ] + | [: _ = Stream.empty :] -> (("EOI", ""), mkloc (bp, succ bp)) ] and less bp strm = if no_quotations.val then match strm with parser @@ -589,10 +306,10 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = else match strm with parser [ [: `'<'; len = quotation bp 0 :] ep -> - (("QUOTATION", ":" ^ get_buff len), (bp, ep)) + (("QUOTATION", ":" ^ get_buff len), mkloc (bp, ep)) | [: `':'; i = parser [: len = ident 0 :] -> get_buff len; `'<' ? "character '<' expected"; len = quotation bp 0 :] ep -> - (("QUOTATION", i ^ ":" ^ get_buff len), (bp, ep)) + (("QUOTATION", i ^ ":" ^ get_buff len), mkloc (bp, ep)) | [: len = ident2 (store 0 '<') :] ep -> let id = get_buff len in keyword_or_error (bp, ep) id ] @@ -600,14 +317,28 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = parser [ [: `'"' :] -> len | [: `'\\'; `c; s :] ep -> string bp (store (store len '\\') c) s + | [: `'\010'; s :] ep -> do { bolpos.val := ep; incr lnum; string bp len s } + | [: `'\013'; s :] ep -> + let (len, ep) = + match Stream.peek s with + [ Some '\010' -> do { Stream.junk s; (store (store len '\013') '\010', ep+1) } + | _ -> (store len '\013', ep) ] in + do { bolpos.val := ep; incr lnum; string bp len s } | [: `c; s :] -> string bp (store len c) s - | [: :] ep -> err (bp, ep) "string not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "string not terminated" ] and char bp len = parser [ [: `'''; s :] -> if len = 0 then char bp (store len ''') s else len | [: `'\\'; `c; s :] -> char bp (store (store len '\\') c) s + | [: `'\010'; s :] -> do {bolpos.val := bp+1; incr lnum; char bp (store len '\010') s} + | [: `'\013'; s :] -> + let bol = + match Stream.peek s with + [ Some '\010' -> do { Stream.junk s; bp+2 } + | _ -> bp+1 ] in + do { bolpos.val := bol; incr lnum; char bp (store len '\013') s} | [: `c; s :] -> char bp (store len c) s - | [: :] ep -> err (bp, ep) "char not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "char not terminated" ] and dollar bp len = parser [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) @@ -623,7 +354,7 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = match s with parser [ [: `c :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "antiquotation not terminated" ] else ("", get_buff (ident2 (store 0 '$') s)) ] and maybe_locate bp len = parser @@ -635,7 +366,7 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) | [: `c; s :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "antiquotation not terminated" ] and antiquot bp len = parser [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) @@ -648,13 +379,13 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) | [: `c; s :] -> ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "antiquotation not terminated" ] and locate_or_antiquot_rest bp len = parser [ [: `'$' :] -> get_buff len | [: `'\\'; `c; s :] -> locate_or_antiquot_rest bp (store len c) s | [: `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "antiquotation not terminated" ] and quotation bp len = parser [ [: `'>'; s :] -> maybe_end_quotation bp len s @@ -668,7 +399,7 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = s :] -> quotation bp len s | [: `c; s :] -> quotation bp (store len c) s - | [: :] ep -> err (bp, ep) "quotation not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "quotation not terminated" ] and maybe_nested_quotation bp len = parser [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" @@ -693,8 +424,15 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = | [: `'*'; s :] -> star_in_comment bp s | [: `'"'; _ = string bp 0; s :] -> comment bp s | [: `'''; s :] -> quote_in_comment bp s + | [: `'\010'; s :] ep -> do { bolpos.val := ep; incr lnum; comment bp s } + | [: `'\013'; s :] ep -> + let ep = + match Stream.peek s with + [ Some '\010' -> do { Stream.junk s; ep+1 } + | _ -> ep ] in + do { bolpos.val := ep; incr lnum; comment bp s } | [: `c; s :] -> comment bp s - | [: :] ep -> err (bp, ep) "comment not terminated" ] + | [: :] ep -> err (mkloc (bp, ep)) "comment not terminated" ] and quote_in_comment bp = parser [ [: `'''; s :] -> comment bp s @@ -702,7 +440,15 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = | [: s :] -> do { match Stream.npeek 2 s with - [ [_; '''] -> do { Stream.junk s; Stream.junk s } + [ [ ( '\013' | '\010' ); '''] -> + do { bolpos.val := bp + 1; incr lnum; + Stream.junk s; Stream.junk s } + | [ '\013'; '\010' ] -> + match Stream.npeek 3 s with + [ [_; _; '''] -> do { bolpos.val := bp + 2; incr lnum; + Stream.junk s; Stream.junk s; Stream.junk s } + | _ -> () ] + | [_; '''] -> do { Stream.junk s; Stream.junk s } | _ -> () ]; comment bp s } ] @@ -736,22 +482,42 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = and linedir n s = match stream_peek_nth n s with [ Some (' ' | '\t') -> linedir (n + 1) s - | Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> False ] - and linedir_digits n s = - match stream_peek_nth n s with - [ Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> linedir_quote n s ] - and linedir_quote n s = - match stream_peek_nth n s with - [ Some (' ' | '\t') -> linedir_quote (n + 1) s - | Some '"' -> True + | Some ('0'..'9') -> True | _ -> False ] and any_to_nl = parser - [ [: `'\013' | '\010' :] ep -> bolpos.val := ep + [ [: `'\010'; s :] ep -> + do { bolpos.val := ep; incr lnum } + | [: `'\013'; s :] ep -> + let ep = + match Stream.peek s with + [ Some '\010' -> do { Stream.junk s; ep+1 } + | _ -> ep ] in + do { bolpos.val := ep; incr lnum } | [: `_; s :] -> any_to_nl s | [: :] -> () ] + and line_directive = parser (* we are sure that there is a line directive here *) + [ [: _ = skip_spaces; n = line_directive_number 0; + _ = skip_spaces; _ = line_directive_string; + _ = any_to_nl :] ep + -> do { bolpos.val := ep; lnum.val := n } + ] + and skip_spaces = parser + [ [: `' ' | '\t'; s :] -> skip_spaces s + | [: :] -> () ] + and line_directive_number n = parser + [ [: `('0'..'9' as c) ; s :] + -> line_directive_number (10*n + (Char.code c - Char.code '0')) s + | [: :] -> n ] + and line_directive_string = parser + [ [: ` '"' ; _ = line_directive_string_contents 0 :] -> () + | [: :] -> () + ] + and line_directive_string_contents len = parser + [ [: ` '\010' | '\013' :] -> () + | [: ` '"' :] -> fname.val := get_buff len + | [: `c; s :] -> line_directive_string_contents (store len c) s + ] in fun cstrm -> try @@ -761,8 +527,9 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = do { match glex.tok_comm with [ Some list -> - if fst (snd r) > comm_bp then - let comm_loc = (comm_bp, fst (snd r)) in + let next_bp = (fst (snd r)).Lexing.pos_cnum in + if next_bp > comm_bp then + let comm_loc = mkloc (comm_bp, next_bp) in glex.tok_comm := Some [comm_loc :: list] else () | None -> () ]; @@ -770,7 +537,7 @@ value next_token_fun dfa ssd find_kwd bolpos glexr = } with [ Stream.Error str -> - err (Stream.count cstrm, Stream.count cstrm + 1) str ] + err (mkloc (Stream.count cstrm, Stream.count cstrm + 1)) str ] ; @@ -779,10 +546,12 @@ value specific_space_dot = ref False; value func kwd_table glexr = let bolpos = ref 0 in + let lnum = ref 1 in + let fname = ref "" in let find = Hashtbl.find kwd_table in let dfa = dollar_for_antiquotation.val in let ssd = specific_space_dot.val in - Token.lexer_func_of_parser (next_token_fun dfa ssd find bolpos glexr) + Token.lexer_func_of_parser (next_token_fun dfa ssd find fname lnum bolpos glexr) ; value rec check_keyword_stream = diff --git a/camlp4/lib/stdpp.ml b/camlp4/lib/stdpp.ml index a89cb15d8e..665dac1f30 100644 --- a/camlp4/lib/stdpp.ml +++ b/camlp4/lib/stdpp.ml @@ -12,7 +12,7 @@ (* $Id$ *) -exception Exc_located of (int * int) and exn; +exception Exc_located of Token.flocation and exn; value raise_with_loc loc exc = match exc with @@ -21,6 +21,14 @@ value raise_with_loc loc exc = ; value line_of_loc fname (bp, ep) = + (bp.Lexing.pos_fname, + bp.Lexing.pos_lnum, + bp.Lexing.pos_cnum - bp.Lexing.pos_bol, + ep.Lexing.pos_cnum - bp.Lexing.pos_bol) +; + +(* +value line_of_loc fname (bp, ep) = try let ic = open_in_bin fname in let strm = Stream.of_channel ic in @@ -75,5 +83,6 @@ value line_of_loc fname (bp, ep) = with [ Sys_error _ -> (fname, 1, bp, ep) ] ; +*) value loc_name = ref "loc"; diff --git a/camlp4/lib/stdpp.mli b/camlp4/lib/stdpp.mli index 069e56bee3..a260cc69df 100644 --- a/camlp4/lib/stdpp.mli +++ b/camlp4/lib/stdpp.mli @@ -14,18 +14,18 @@ (** Standard definitions. *) -exception Exc_located of (int * int) and exn; +exception Exc_located of Token.flocation and exn; (** [Exc_located loc e] is an encapsulation of the exception [e] with the input location [loc]. To be used in quotation expanders and in grammars to specify some input location for an error. Do not raise this exception directly: rather use the following function [raise_with_loc]. *) -value raise_with_loc : (int * int) -> exn -> 'a; +value raise_with_loc : Token.flocation -> exn -> 'a; (** [raise_with_loc loc e], if [e] is already the exception [Exc_located], re-raise it, else raise the exception [Exc_located loc e]. *) -value line_of_loc : string -> (int * int) -> (string * int * int * int); +value line_of_loc : string -> Token.flocation -> (string * int * int * int); (** [line_of_loc fname loc] reads the file [fname] up to the location [loc] and returns the real input file, the line number and the characters location in the line; the real input file diff --git a/camlp4/lib/token.ml b/camlp4/lib/token.ml index e26798af9c..5bfc6541f1 100644 --- a/camlp4/lib/token.ml +++ b/camlp4/lib/token.ml @@ -17,9 +17,23 @@ type pattern = (string * string); exception Error of string; -type location = (int * int); -type location_function = int -> (int * int); -type lexer_func 'te = Stream.t char -> (Stream.t 'te * location_function); +value make_loc (bp, ep) = + ({ (Lexing.dummy_pos) with Lexing.pos_cnum = bp; Lexing.pos_lnum = 1 }, + { (Lexing.dummy_pos) with Lexing.pos_cnum = ep; Lexing.pos_lnum = 1 }) +; + +value nowhere = { (Lexing.dummy_pos) with Lexing.pos_cnum = 0 }; + +value dummy_loc = (Lexing.dummy_pos, Lexing.dummy_pos); + +value succ_pos p = + { ( p ) with Lexing.pos_cnum = p.Lexing.pos_cnum + 1}; +value lt_pos p1 p2 = p1.Lexing.pos_cnum < p2.Lexing.pos_cnum; + +type flocation = (Lexing.position * Lexing.position); + +type flocation_function = int -> flocation; +type lexer_func 'te = Stream.t char -> (Stream.t 'te * flocation_function); type glexer 'te = { tok_func : lexer_func 'te; @@ -27,7 +41,7 @@ type glexer 'te = tok_removing : pattern -> unit; tok_match : pattern -> 'te -> string; tok_text : pattern -> string; - tok_comm : mutable option (list location) } + tok_comm : mutable option (list flocation) } ; type lexer = { func : lexer_func t; @@ -43,31 +57,41 @@ value lexer_text (con, prm) = else con ^ " '" ^ prm ^ "'" ; -value locerr () = invalid_arg "Lexer: location function"; -value loct_create () = (ref (Array.create 1024 None), ref False); +value locerr () = invalid_arg "Lexer: flocation function"; + +value tsz = 256; (* up to 2^29 entries on a 32-bit machine, 2^61 on 64-bit *) + +value loct_create () = (ref [| |], ref False); + value loct_func (loct, ov) i = match - if i < 0 || i >= Array.length loct.val then - if ov.val then Some (0, 0) else None - else Array.unsafe_get loct.val i + if i < 0 || i/tsz >= Array.length loct.val then None + else if loct.val.(i/tsz) = [| |] then + if ov.val then Some (nowhere, nowhere) else None + else Array.unsafe_get (Array.unsafe_get loct.val (i/tsz)) (i mod tsz) with [ Some loc -> loc | _ -> locerr () ] ; -value loct_add (loct, ov) i loc = - if i >= Array.length loct.val then - let new_tmax = Array.length loct.val * 2 in + +value loct_add (loct, ov) i loc = do { + while i/tsz >= Array.length loct.val && (not ov.val) do { + let new_tmax = Array.length loct.val * 2 + 1 in if new_tmax < Sys.max_array_length then do { - let new_loct = Array.create new_tmax None in + let new_loct = Array.make new_tmax [| |] in Array.blit loct.val 0 new_loct 0 (Array.length loct.val); - loct.val := new_loct; - loct.val.(i) := Some loc - } - else ov.val := True - else loct.val.(i) := Some loc -; + loct.val := new_loct + } else ov.val := True + }; + if not(ov.val) then do { + if loct.val.(i/tsz) = [| |] then + loct.val.(i/tsz) := Array.make tsz None + else (); + loct.val.(i/tsz).(i mod tsz) := Some loc + } else () +}; -value make_stream_and_location next_token_loc = +value make_stream_and_flocation next_token_loc = let loct = loct_create () in let ts = Stream.from @@ -79,7 +103,7 @@ value make_stream_and_location next_token_loc = ; value lexer_func_of_parser next_token_loc cs = - make_stream_and_location (fun () -> next_token_loc cs) + make_stream_and_flocation (fun () -> next_token_loc cs) ; value lexer_func_of_ocamllex lexfun cs = @@ -90,10 +114,10 @@ value lexer_func_of_ocamllex lexfun cs = in let next_token_loc _ = let tok = lexfun lb in - let loc = (Lexing.lexeme_start lb, Lexing.lexeme_end lb) in + let loc = (Lexing.lexeme_start_p lb, Lexing.lexeme_end_p lb) in (tok, loc) in - make_stream_and_location next_token_loc + make_stream_and_flocation next_token_loc ; (* Char and string tokens to real chars and string *) @@ -209,7 +233,7 @@ value eval_string (bp, ep) s = [ Not_found -> do { Printf.eprintf "Warning: char %d, Invalid backslash escape in string\n%!" - (bp+i+1); + (bp.Lexing.pos_cnum + i + 1); (store (store len '\\') c, i + 1) } ] ] else (store len s.[i], i + 1) in diff --git a/camlp4/lib/token.mli b/camlp4/lib/token.mli index fbd1aefd30..db025d0f2f 100644 --- a/camlp4/lib/token.mli +++ b/camlp4/lib/token.mli @@ -33,11 +33,19 @@ exception Error of string; (** {6 Lexer type} *) -type location = (int * int); -type location_function = int -> location; +type flocation = (Lexing.position * Lexing.position); + +value nowhere : Lexing.position; +value dummy_loc : flocation; + +value make_loc : (int * int) -> flocation; +value succ_pos : Lexing.position -> Lexing.position; +value lt_pos : Lexing.position -> Lexing.position -> bool; + +type flocation_function = int -> flocation; (** The type for a function associating a number of a token in a stream (starting from 0) to its source location. *) -type lexer_func 'te = Stream.t char -> (Stream.t 'te * location_function); +type lexer_func 'te = Stream.t char -> (Stream.t 'te * flocation_function); (** The type for a lexer function. The character stream is the input stream to be lexed. The result is a pair of a token stream and a location function for this tokens stream. *) @@ -48,7 +56,7 @@ type glexer 'te = tok_removing : pattern -> unit; tok_match : pattern -> 'te -> string; tok_text : pattern -> string; - tok_comm : mutable option (list location) } + tok_comm : mutable option (list flocation) } ; (** The type for a lexer used by Camlp4 grammars. - The field [tok_func] is the main lexer function. See [lexer_func] @@ -96,14 +104,14 @@ value default_match : pattern -> (string * string) -> string; as well. *) value lexer_func_of_parser : - (Stream.t char -> ('te * location)) -> lexer_func 'te; + (Stream.t char -> ('te * flocation)) -> lexer_func 'te; (** A lexer function from a lexer written as a char stream parser returning the next token and its location. *) value lexer_func_of_ocamllex : (Lexing.lexbuf -> 'te) -> lexer_func 'te; (** A lexer function from a lexer created by [ocamllex] *) -value make_stream_and_location : - (unit -> ('te * location)) -> (Stream.t 'te * location_function); +value make_stream_and_flocation : + (unit -> ('te * flocation)) -> (Stream.t 'te * flocation_function); (** General function *) (** {6 Useful functions} *) @@ -114,7 +122,7 @@ value eval_char : string -> char; incorrect backslash sequence is found; [Token.eval_char (Char.escaped c)] returns [c] *) -value eval_string : location -> string -> string; +value eval_string : flocation -> string -> string; (** Convert a string token, where the escape sequences (backslashes) remain to be interpreted; issue a warning if an incorrect backslash sequence is found; diff --git a/camlp4/meta/.depend b/camlp4/meta/.depend index 737ea5ec6b..7c8bcbfbea 100644 --- a/camlp4/meta/.depend +++ b/camlp4/meta/.depend @@ -1,5 +1,5 @@ -pa_extend.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi -pa_extend.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx +pa_extend.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/reloc.cmi +pa_extend.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/reloc.cmx pa_extend_m.cmo: pa_extend.cmo pa_extend_m.cmx: pa_extend.cmx pa_ifdef.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi @@ -12,5 +12,7 @@ pa_rp.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_rp.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx pr_dump.cmo: ../camlp4/ast2pt.cmi $(OTOP)/utils/config.cmi ../camlp4/pcaml.cmi pr_dump.cmx: ../camlp4/ast2pt.cmx $(OTOP)/utils/config.cmx ../camlp4/pcaml.cmx -q_MLast.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/quotation.cmi -q_MLast.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/quotation.cmx +q_MLast.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/quotation.cmi \ + ../camlp4/reloc.cmi +q_MLast.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/quotation.cmx \ + ../camlp4/reloc.cmx diff --git a/camlp4/meta/Makefile b/camlp4/meta/Makefile index ba1481bed7..2469a35330 100644 --- a/camlp4/meta/Makefile +++ b/camlp4/meta/Makefile @@ -49,11 +49,7 @@ install: cp camlp4r$(EXE) "$(BINDIR)/." if test -f camlp4r.opt; then \ cp camlp4r.opt "$(BINDIR)/camlp4r.opt$(EXE)" ;\ - for target in $(OBJSX) $(OBJSX:.cmx=.$(O)) ; do \ - if test -f $$target; then \ - cp $$target "$(LIBDIR)/camlp4/."; \ - fi; \ - done; \ + cp $(OBJSX) $(OBJSX:.cmx=.$(O)) "$(LIBDIR)/camlp4/."; \ fi include .depend diff --git a/camlp4/meta/pa_extend.ml b/camlp4/meta/pa_extend.ml index e8fed87b62..0364230453 100644 --- a/camlp4/meta/pa_extend.ml +++ b/camlp4/meta/pa_extend.ml @@ -22,9 +22,9 @@ Pcaml.add_option "-split_ext" (Arg.Set split_ext) Pcaml.add_option "-split_gext" (Arg.Set split_ext) "Old name for the option -split_ext."; -type loc = (int * int); +type loc = (Lexing.position * Lexing.position); -type name 'e = { expr : 'e; tvar : string; loc : (int * int) }; +type name 'e = { expr : 'e; tvar : string; loc : loc }; type styp = [ STlid of loc and string @@ -163,7 +163,10 @@ module MetaAction = in failwith (f ^ ", not impl: " ^ desc) ; - value loc = (0, 0); + value loc = + let nowhere = + { (Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere, nowhere); value rec mlist mf = fun [ [] -> <:expr< [] >> @@ -179,7 +182,10 @@ module MetaAction = [ False -> <:expr< False >> | True -> <:expr< True >> ] ; - value mloc = <:expr< (0, 0) >>; + value mloc = + <:expr< let nowhere = + { (Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere, nowhere) >>; value rec mexpr = fun [ MLast.ExAcc loc e1 e2 -> @@ -355,7 +361,10 @@ value quotify_action psl act = (fun e ps -> match ps.pattern with [ Some <:patt< ($list:pl$) >> -> - let loc = (0, 0) in + let loc = + let nowhere = + { (Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere, nowhere) in let pname = pname_of_ptuple pl in let (pl1, el1) = let (l, _) = @@ -453,7 +462,7 @@ value text_of_action loc psl rtvar act tvar = [ Some act -> if quotify.val then quotify_action psl act else act | None -> <:expr< () >> ] in - let e = <:expr< fun [ ($locid$ : (int * int)) -> ($act$ : '$rtvar$) ] >> in + let e = <:expr< fun [ ($locid$ : (Lexing.position * Lexing.position)) -> ($act$ : '$rtvar$) ] >> in let txt = List.fold_left (fun txt ps -> @@ -724,6 +733,8 @@ value text_of_functorial_extend loc gmod gl el = let_in_of_extend loc gmod True gl el args ; +value zero_loc = {(Lexing.dummy_pos) with Lexing.pos_cnum = 0}; + open Pcaml; value symbol = Grammar.Entry.create gram "symbol"; value semi_sep = @@ -899,13 +910,13 @@ EXTEND string: [ [ s = STRING -> <:expr< $str:s$ >> | i = ANTIQUOT -> - let shift = fst loc + String.length "$" in + let shift = Reloc.shift_pos (String.length "$") (fst loc) in let e = try Grammar.Entry.parse Pcaml.expr_eoi (Stream.of_string i) with [ Exc_located (bp, ep) exc -> - raise_with_loc (shift + bp, shift + ep) exc ] + raise_with_loc (Reloc.adjust_loc shift (bp,ep)) exc ] in - Pcaml.expr_reloc (fun (bp, ep) -> (shift + bp, shift + ep)) 0 e ] ] + Pcaml.expr_reloc (fun (bp, ep) -> (Reloc.adjust_loc shift (bp,ep))) zero_loc e ] ] ; END; diff --git a/camlp4/meta/pa_macro.ml b/camlp4/meta/pa_macro.ml index 406a3bd622..b495997e2c 100644 --- a/camlp4/meta/pa_macro.ml +++ b/camlp4/meta/pa_macro.ml @@ -64,7 +64,10 @@ value defined = ref []; value is_defined i = List.mem_assoc i defined.val; -value loc = (0, 0); +value loc = + let nowhere = + { (Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere, nowhere); value subst mloc env = loop where rec loop = @@ -119,12 +122,12 @@ value define eo x = [ Some ([], e) -> EXTEND expr: LEVEL "simple" - [ [ UIDENT $x$ -> Pcaml.expr_reloc (fun _ -> loc) 0 e ] ] + [ [ UIDENT $x$ -> Pcaml.expr_reloc (fun _ -> loc) (fst loc) e ] ] ; patt: LEVEL "simple" [ [ UIDENT $x$ -> let p = substp loc [] e in - Pcaml.patt_reloc (fun _ -> loc) 0 p ] ] + Pcaml.patt_reloc (fun _ -> loc) (fst loc) p ] ] ; END | Some (sl, e) -> @@ -139,7 +142,7 @@ value define eo x = if List.length el = List.length sl then let env = List.combine sl el in let e = subst loc env e in - Pcaml.expr_reloc (fun _ -> loc) 0 e + Pcaml.expr_reloc (fun _ -> loc) (fst loc) e else incorrect_number loc el sl ] ] ; @@ -153,7 +156,7 @@ value define eo x = if List.length pl = List.length sl then let env = List.combine sl pl in let p = substp loc env e in - Pcaml.patt_reloc (fun _ -> loc) 0 p + Pcaml.patt_reloc (fun _ -> loc) (fst loc) p else incorrect_number loc pl sl ] ] ; @@ -228,8 +231,8 @@ EXTEND expr: LEVEL "simple" [ [ LIDENT "__FILE__" -> <:expr< $str:Pcaml.input_file.val$ >> | LIDENT "__LOCATION__" -> - let bp = string_of_int (fst loc) in - let ep = string_of_int (snd loc) in + let bp = string_of_int ((fst loc).Lexing.pos_cnum) in + let ep = string_of_int ((snd loc).Lexing.pos_cnum) in <:expr< ($int:bp$, $int:ep$) >> ] ] ; patt: diff --git a/camlp4/meta/pa_r.ml b/camlp4/meta/pa_r.ml index dd6b499ac5..14954cdde9 100644 --- a/camlp4/meta/pa_r.ml +++ b/camlp4/meta/pa_r.ml @@ -323,7 +323,10 @@ EXTEND "do"; "{"; seq = sequence; "}" -> <:expr< for $i$ = $e1$ $to:df$ $e2$ do { $list:seq$ } >> | "while"; e = SELF; "do"; "{"; seq = sequence; "}" -> - <:expr< while $e$ do { $list:seq$ } >> ] + <:expr< while $e$ do { $list:seq$ } >> + | "object"; cspo = OPT class_self_patt; cf = class_structure; "end" -> + (* <:expr< object $opt:cspo$ $list:cf$ end >> *) + MLast.ExObj loc cspo cf ] | "where" [ e = SELF; "where"; rf = OPT "rec"; lb = let_binding -> <:expr< let $opt:o2b rf$ $list:[lb]$ in $e$ >> ] @@ -392,9 +395,8 @@ EXTEND mklistexp loc last el | "[|"; el = LIST0 expr SEP ";"; "|]" -> <:expr< [| $list:el$ |] >> | "{"; lel = LIST1 label_expr SEP ";"; "}" -> <:expr< { $list:lel$ } >> - | "{"; "("; e = SELF; ")"; "with"; lel = LIST1 label_expr SEP ";"; - "}" -> - <:expr< { ($e$) with $list:lel$ } >> + | "{"; "("; e = SELF; ")"; "with"; lel = LIST1 label_expr SEP ";"; "}" + -> <:expr< { ($e$) with $list:lel$ } >> | "("; ")" -> <:expr< () >> | "("; e = SELF; ":"; t = ctyp; ")" -> <:expr< ($e$ : $t$) >> | "("; e = SELF; ","; el = LIST1 expr SEP ","; ")" -> @@ -735,8 +737,14 @@ EXTEND ; ctyp: LEVEL "simple" [ [ "#"; id = class_longident -> <:ctyp< # $list:id$ >> - | "<"; ml = LIST0 field SEP ";"; v = OPT ".."; ">" -> - <:ctyp< < $list:ml$ $opt:o2b v$ > >> ] ] + | "<"; (ml, v) = meth_list; ">" -> <:ctyp< < $list:ml$ $opt:v$ > >> + | "<"; ">" -> <:ctyp< < > >> ] ] + ; + meth_list: + [ [ f = field; ";"; (ml, v) = SELF -> ([f :: ml], v) + | f = field; ";" -> ([f], False) + | f = field -> ([f], False) + | ".." -> ([], True) ] ] ; field: [ [ lab = LIDENT; ":"; t = ctyp -> (lab, t) ] ] @@ -760,6 +768,10 @@ EXTEND | "["; "<"; rfl = row_field_list; "]" -> <:ctyp< [ < $list:rfl$ ] >> | "["; "<"; rfl = row_field_list; ">"; ntl = LIST1 name_tag; "]" -> + <:ctyp< [ < $list:rfl$ > $list:ntl$ ] >> + | "[<"; rfl = row_field_list; "]" -> + <:ctyp< [ < $list:rfl$ ] >> + | "[<"; rfl = row_field_list; ">"; ntl = LIST1 name_tag; "]" -> <:ctyp< [ < $list:rfl$ > $list:ntl$ ] >> ] ] ; row_field_list: @@ -901,10 +913,11 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({ (Lexing.dummy_pos) with Lexing.pos_cnum = int_of_string (String.sub x 0 i) } + , String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> ({(Lexing.dummy_pos) with Lexing.pos_cnum = 0}, x) ] in Pcaml.handle_expr_locate loc x | x = QUOTATION -> @@ -923,10 +936,11 @@ EXTEND let x = try let i = String.index x ':' in - (int_of_string (String.sub x 0 i), + ({(Lexing.dummy_pos) with Lexing.pos_cnum = int_of_string (String.sub x 0 i)} + , String.sub x (i + 1) (String.length x - i - 1)) with - [ Not_found | Failure _ -> (0, x) ] + [ Not_found | Failure _ -> ({(Lexing.dummy_pos) with Lexing.pos_cnum = 0}, x) ] in Pcaml.handle_patt_locate loc x | x = QUOTATION -> diff --git a/camlp4/meta/q_MLast.ml b/camlp4/meta/q_MLast.ml index c10ad7980c..2c79b43d28 100644 --- a/camlp4/meta/q_MLast.ml +++ b/camlp4/meta/q_MLast.ml @@ -30,7 +30,10 @@ module Qast = | Loc | Antiquot of MLast.loc and string ] ; - value loc = (0, 0); + value loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0 } in + (nowhere,nowhere); value rec to_expr = fun [ Node n al -> @@ -56,7 +59,7 @@ module Qast = let e = try Grammar.Entry.parse Pcaml.expr_eoi (Stream.of_string s) with [ Stdpp.Exc_located (bp, ep) exc -> - raise (Stdpp.Exc_located (fst loc + bp, fst loc + ep) exc) ] + raise (Stdpp.Exc_located (Reloc.adjust_loc (fst loc) (bp,ep)) exc) ] in <:expr< $anti:e$ >> ] and to_expr_label (l, a) = (<:patt< MLast.$lid:l$ >>, to_expr a); @@ -83,7 +86,7 @@ module Qast = let p = try Grammar.Entry.parse Pcaml.patt_eoi (Stream.of_string s) with [ Stdpp.Exc_located (bp, ep) exc -> - raise (Stdpp.Exc_located (fst loc + bp, fst loc + ep) exc) ] + raise (Stdpp.Exc_located (Reloc.adjust_loc (fst loc) (bp, ep)) exc) ] in <:patt< $anti:p$ >> ] and to_patt_label (l, a) = (<:patt< MLast.$lid:l$ >>, to_patt a); @@ -95,7 +98,7 @@ value antiquot k (bp, ep) x = if k = "" then String.length "$" else String.length "$" + String.length k + String.length ":" in - Qast.Antiquot (shift + bp, shift + ep) x + Qast.Antiquot (Reloc.shift_pos shift bp, Reloc.shift_pos (-1) ep) x ; value sig_item = Grammar.Entry.create gram "signature item"; @@ -123,6 +126,9 @@ value a_opt = Grammar.Entry.create gram "a_opt"; value a_UIDENT = Grammar.Entry.create gram "a_UIDENT"; value a_LIDENT = Grammar.Entry.create gram "a_LIDENT"; value a_INT = Grammar.Entry.create gram "a_INT"; +value a_INT32 = Grammar.Entry.create gram "a_INT32"; +value a_INT64 = Grammar.Entry.create gram "a_INT64"; +value a_NATIVEINT = Grammar.Entry.create gram "a__NATIVEINT"; value a_FLOAT = Grammar.Entry.create gram "a_FLOAT"; value a_STRING = Grammar.Entry.create gram "a_STRING"; value a_CHAR = Grammar.Entry.create gram "a_CHAR"; @@ -254,7 +260,7 @@ value not_yet_warned_variant = ref True; value warn_variant _ = if not_yet_warned_variant.val then do { not_yet_warned_variant.val := False; - Pcaml.warning.val (0, 1) + Pcaml.warning.val (Lexing.dummy_pos, Reloc.shift_pos 1 Lexing.dummy_pos) (Printf.sprintf "use of syntax of variants types deprecated since version 3.05"); } @@ -265,7 +271,7 @@ value not_yet_warned_seq = ref True; value warn_sequence _ = if not_yet_warned_seq.val then do { not_yet_warned_seq.val := False; - Pcaml.warning.val (0, 1) + Pcaml.warning.val (Lexing.dummy_pos, Reloc.shift_pos 1 Lexing.dummy_pos) (Printf.sprintf "use of syntax of sequences deprecated since version 3.01.1"); } @@ -623,6 +629,9 @@ EXTEND [Qast.Loc; Qast.Node "ExLid" [Qast.Loc; Qast.Str "~-."]; e] ] | "simple" [ s = a_INT -> Qast.Node "ExInt" [Qast.Loc; s] + | s = a_INT32 -> Qast.Node "ExInt32" [Qast.Loc; s] + | s = a_INT64 -> Qast.Node "ExInt64" [Qast.Loc; s] + | s = a_NATIVEINT -> Qast.Node "ExNativeInt" [Qast.Loc; s] | s = a_FLOAT -> Qast.Node "ExFlo" [Qast.Loc; s] | s = a_STRING -> Qast.Node "ExStr" [Qast.Loc; s] | s = a_CHAR -> Qast.Node "ExChr" [Qast.Loc; s] @@ -712,10 +721,16 @@ EXTEND [ s = a_LIDENT -> Qast.Node "PaLid" [Qast.Loc; s] | s = a_UIDENT -> Qast.Node "PaUid" [Qast.Loc; s] | s = a_INT -> Qast.Node "PaInt" [Qast.Loc; s] + | s = a_INT32 -> Qast.Node "PaInt32" [Qast.Loc; s] + | s = a_INT64 -> Qast.Node "PaInt64" [Qast.Loc; s] + | s = a_NATIVEINT -> Qast.Node "PaNativeInt" [Qast.Loc; s] | s = a_FLOAT -> Qast.Node "PaFlo" [Qast.Loc; s] | s = a_STRING -> Qast.Node "PaStr" [Qast.Loc; s] | s = a_CHAR -> Qast.Node "PaChr" [Qast.Loc; s] | "-"; s = a_INT -> mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool True) s + | "-"; s = a_INT32 -> mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool True) s + | "-"; s = a_INT64 -> mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool True) s + | "-"; s = a_NATIVEINT -> mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool True) s | "-"; s = a_FLOAT -> mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool False) s | "["; "]" -> Qast.Node "PaUid" [Qast.Loc; Qast.Str "[]"] @@ -1027,6 +1042,13 @@ EXTEND Qast.Option (Some (Qast.Option (Some (Qast.List []))))] | "["; "<"; rfl = row_field_list; ">"; ntl = SLIST1 name_tag; "]" -> Qast.Node "TyVrn" + [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))] + | "[<"; rfl = row_field_list; "]" -> + Qast.Node "TyVrn" + [Qast.Loc; rfl; + Qast.Option (Some (Qast.Option (Some (Qast.List []))))] + | "[<"; rfl = row_field_list; ">"; ntl = SLIST1 name_tag; "]" -> + Qast.Node "TyVrn" [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))] ] ] ; row_field_list: @@ -1332,6 +1354,21 @@ EXTEND | a = ANTIQUOT -> antiquot "" loc a | s = INT -> Qast.Str s ] ] ; + a_INT32: + [ [ a = ANTIQUOT "int32" -> antiquot "int32" loc a + | a = ANTIQUOT -> antiquot "" loc a + | s = INT32 -> Qast.Str s ] ] + ; + a_INT64: + [ [ a = ANTIQUOT "int64" -> antiquot "int64" loc a + | a = ANTIQUOT -> antiquot "" loc a + | s = INT64 -> Qast.Str s ] ] + ; + a_NATIVEINT: + [ [ a = ANTIQUOT "nativeint" -> antiquot "nativeint" loc a + | a = ANTIQUOT -> antiquot "" loc a + | s = NATIVEINT -> Qast.Str s ] ] + ; a_FLOAT: [ [ a = ANTIQUOT "flo" -> antiquot "flo" loc a | a = ANTIQUOT -> antiquot "" loc a diff --git a/camlp4/ocaml_src/camlp4/.depend b/camlp4/ocaml_src/camlp4/.depend index bf82065403..63efcf4310 100644 --- a/camlp4/ocaml_src/camlp4/.depend +++ b/camlp4/ocaml_src/camlp4/.depend @@ -7,10 +7,14 @@ argl.cmo: ast2pt.cmi mLast.cmi ../odyl/odyl_main.cmi pcaml.cmi argl.cmx: ast2pt.cmx mLast.cmi ../odyl/odyl_main.cmx pcaml.cmx ast2pt.cmo: $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmi \ $(OTOP)/parsing/longident.cmi mLast.cmi $(OTOP)/parsing/parsetree.cmi \ - ast2pt.cmi + pcaml.cmi ast2pt.cmi ast2pt.cmx: $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmx \ $(OTOP)/parsing/longident.cmx mLast.cmi $(OTOP)/parsing/parsetree.cmi \ - ast2pt.cmi + pcaml.cmx ast2pt.cmi +pcaml.cmo: mLast.cmi quotation.cmi reloc.cmi spretty.cmi pcaml.cmi +pcaml.cmx: mLast.cmi quotation.cmx reloc.cmx spretty.cmx pcaml.cmi +crc.cmo: $(OTOP)/otherlibs/dynlink/dynlink.cmi +crc.cmx: $(OTOP)/otherlibs/dynlink/dynlink.cmx pcaml.cmo: ast2pt.cmi mLast.cmi quotation.cmi reloc.cmi spretty.cmi pcaml.cmi pcaml.cmx: ast2pt.cmx mLast.cmi quotation.cmx reloc.cmx spretty.cmx pcaml.cmi quotation.cmo: mLast.cmi quotation.cmi diff --git a/camlp4/ocaml_src/camlp4/Makefile b/camlp4/ocaml_src/camlp4/Makefile index 0e5d05762d..c60f6d1e11 100644 --- a/camlp4/ocaml_src/camlp4/Makefile +++ b/camlp4/ocaml_src/camlp4/Makefile @@ -9,8 +9,8 @@ OCAMLCFLAGS= $(INCLUDES) -warn-error A $(INCLUDES) LINKFLAGS=$(INCLUDES) INTERFACES=-I $(OLIBDIR) Arg Array ArrayLabels Buffer Callback CamlinternalOO Char Complex Digest Filename Format Gc Genlex Hashtbl Int32 Int64 Lazy Lexing List ListLabels Map Marshal MoreLabels Nativeint Obj Oo Parsing Pervasives Printexc Printf Queue Random Scanf Set Sort Stack StdLabels Stream String StringLabels Sys Weak -I ../../boot Extfold Extfun Fstream Gramext Grammar Plexer Stdpp Token -I $(OTOP)/utils Config Warnings -I $(OTOP)/parsing Asttypes Location Longident Parsetree -I . Ast2pt MLast Pcaml Quotation Spretty CAMLP4_INTF=$(OTOP)/utils/config.cmi $(OTOP)/utils/warnings.cmi $(OTOP)/parsing/asttypes.cmi $(OTOP)/parsing/location.cmi $(OTOP)/parsing/longident.cmi $(OTOP)/parsing/parsetree.cmi ast2pt.cmi mLast.cmi pcaml.cmi spretty.cmi quotation.cmi -CAMLP4_OBJS=../../boot/stdpp.cmo ../../boot/token.cmo ../../boot/plexer.cmo ../../boot/gramext.cmo ../../boot/grammar.cmo ../../boot/extfold.cmo ../../boot/extfun.cmo ../../boot/fstream.cmo $(OTOP)/utils/config.cmo quotation.cmo ast2pt.cmo spretty.cmo reloc.cmo pcaml.cmo argl.cmo -CAMLP4_XOBJS=../lib/stdpp.cmx ../lib/token.cmx ../lib/plexer.cmx ../lib/gramext.cmx ../lib/grammar.cmx ../lib/extfold.cmx ../lib/extfun.cmx ../lib/fstream.cmx $(OTOP)/utils/config.cmx quotation.cmx ast2pt.cmx spretty.cmx reloc.cmx pcaml.cmx argl.cmx +CAMLP4_OBJS=../../boot/stdpp.cmo ../../boot/token.cmo ../../boot/plexer.cmo ../../boot/gramext.cmo ../../boot/grammar.cmo ../../boot/extfold.cmo ../../boot/extfun.cmo ../../boot/fstream.cmo $(OTOP)/utils/config.cmo quotation.cmo spretty.cmo reloc.cmo pcaml.cmo ast2pt.cmo argl.cmo +CAMLP4_XOBJS=../lib/stdpp.cmx ../lib/token.cmx ../lib/plexer.cmx ../lib/gramext.cmx ../lib/grammar.cmx ../lib/extfold.cmx ../lib/extfun.cmx ../lib/fstream.cmx $(OTOP)/utils/config.cmx quotation.cmx spretty.cmx reloc.cmx pcaml.cmx ast2pt.cmx argl.cmx OBJS=../odyl/odyl.cma camlp4.cma CAMLP4M= @@ -22,7 +22,7 @@ opt: $(OBJS:.cma=.cmxa) optp4: $(CAMLP4OPT) $(CAMLP4): $(OBJS) ../odyl/odyl.cmo - $(OCAMLC) $(OBJS) $(CAMLP4M) ../odyl/odyl.cmo -linkall -o $(CAMLP4) + $(OCAMLC) -g $(OBJS) $(CAMLP4M) ../odyl/odyl.cmo -linkall -o $(CAMLP4) $(CAMLP4OPT): $(OBJS:.cma=.cmxa) ../odyl/odyl.cmx $(OCAMLOPT) $(OBJS:.cma=.cmxa) $(CAMLP4M) ../odyl/odyl.cmx -linkall -o $(CAMLP4OPT) diff --git a/camlp4/ocaml_src/camlp4/argl.ml b/camlp4/ocaml_src/camlp4/argl.ml index 0f6ac98ced..ced893b1ad 100644 --- a/camlp4/ocaml_src/camlp4/argl.ml +++ b/camlp4/ocaml_src/camlp4/argl.ml @@ -128,7 +128,9 @@ let print_location loc = if !(Pcaml.input_file) <> "-" then let (fname, line, bp, ep) = Stdpp.line_of_loc !(Pcaml.input_file) loc in eprintf loc_fmt !(Pcaml.input_file) line bp ep - else eprintf "At location %d-%d\n" (fst loc) (snd loc) + else + eprintf "At location %d-%d\n" (fst loc).Lexing.pos_cnum + (snd loc).Lexing.pos_cnum ;; let print_warning loc s = print_location loc; eprintf "%s\n" s;; @@ -215,6 +217,10 @@ let file_kind_of_name name = else raise (Arg.Bad ("don't know what to do with " ^ name)) ;; +let print_version_string () = + print_string Pcaml.version; print_newline (); exit 0 +;; + let print_version () = eprintf "Camlp4 version %s\n" Pcaml.version; flush stderr; exit 0 ;; @@ -291,14 +297,7 @@ let print_usage_list l = let usage ini_sl ext_sl = eprintf "\ -Usage: camlp4 [load-options] [--] [other-options] -Load options: - -I directory Add directory in search patch for object files. - -where Print camlp4 library directory and exit. - -nolib No automatic search for object files in library directory. - <object-file> Load this file in Camlp4 core. -Other options: - <file> Parse this file.\n"; +Usage: camlp4 [load-options] [--] [other-options]Load options: -I directory Add directory in search patch for object files. -where Print camlp4 library directory and exit. -nolib No automatic search for object files in library directory. <object-file> Load this file in Camlp4 core.Other options: <file> Parse this file.\n"; print_usage_list ini_sl; begin let rec loop = @@ -318,9 +317,7 @@ Other options: let warn_noassert () = eprintf "\ -camlp4 warning: option -noassert is obsolete -You should give the -noassert option to the ocaml compiler instead. -" +camlp4 warning: option -noassert is obsoleteYou should give the -noassert option to the ocaml compiler instead." ;; let initial_spec_list = @@ -340,7 +337,9 @@ let initial_spec_list = "<file> Dump quotation expander result in case of syntax error."; "-o", Arg.String (fun x -> Pcaml.output_file := Some x), "<file> Output on <file> instead of standard output."; - "-v", Arg.Unit print_version, "Print Camlp4 version and exit."] + "-v", Arg.Unit print_version, "Print Camlp4 version and exit."; + "-version", Arg.Unit print_version_string, + "Print Camlp4 version number and exit."] ;; let anon_fun x = Pcaml.input_file := x; file_kind := file_kind_of_name x;; diff --git a/camlp4/ocaml_src/camlp4/ast2pt.ml b/camlp4/ocaml_src/camlp4/ast2pt.ml index b243109b73..786075527c 100644 --- a/camlp4/ocaml_src/camlp4/ast2pt.ml +++ b/camlp4/ocaml_src/camlp4/ast2pt.ml @@ -19,7 +19,7 @@ open Longident;; open Asttypes;; let fast = ref false;; -let no_constructors_arity = ref false;; +let no_constructors_arity = Pcaml.no_constructors_arity;; let get_tag x = if Obj.is_block (Obj.repr x) then Obj.tag (Obj.repr x) else Obj.magic x @@ -41,17 +41,23 @@ let glob_fname = ref "";; let mkloc (bp, ep) = let loc_at n = - {Lexing.pos_fname = !glob_fname; Lexing.pos_lnum = 1; Lexing.pos_bol = 0; - Lexing.pos_cnum = n} + {n with + Lexing.pos_fname = + if n.Lexing.pos_fname = "" then + if !glob_fname = "" then !(Pcaml.input_file) else !glob_fname + else n.Lexing.pos_fname} in {Location.loc_start = loc_at bp; Location.loc_end = loc_at ep; - Location.loc_ghost = false} + Location.loc_ghost = bp.Lexing.pos_cnum = 0 && ep.Lexing.pos_cnum = 0} ;; let mkghloc (bp, ep) = let loc_at n = - {Lexing.pos_fname = ""; Lexing.pos_lnum = 1; Lexing.pos_bol = 0; - Lexing.pos_cnum = n} + {n with + Lexing.pos_fname = + if n.Lexing.pos_fname = "" then + if !glob_fname = "" then !(Pcaml.input_file) else !glob_fname + else n.Lexing.pos_fname} in {Location.loc_start = loc_at bp; Location.loc_end = loc_at ep; Location.loc_ghost = true} @@ -125,19 +131,31 @@ let rec ctyp_fa al = | f -> f, al ;; -let rec ctyp_long_id = - function +let rec ctyp_long_id_prefix t = + match t with TyAcc (_, m, TyLid (_, s)) -> - let (is_cls, li) = ctyp_long_id m in is_cls, ldot li s + error (loc_of_ctyp t) "invalid module expression" | TyAcc (_, m, TyUid (_, s)) -> - let (is_cls, li) = ctyp_long_id m in is_cls, ldot li s + let (is_cls, li) = ctyp_long_id_prefix m in is_cls, ldot li s | TyApp (_, m1, m2) -> - let (is_cls, li1) = ctyp_long_id m1 in - let (_, li2) = ctyp_long_id m2 in is_cls, Lapply (li1, li2) + let (is_cls, li1) = ctyp_long_id_prefix m1 in + let (_, li2) = ctyp_long_id_prefix m2 in is_cls, Lapply (li1, li2) | TyUid (_, s) -> false, lident s + | TyLid (_, s) -> error (loc_of_ctyp t) "invalid module expression" + | t -> error (loc_of_ctyp t) "invalid module expression" +;; + +let ctyp_long_id t = + match t with + TyAcc (_, m, TyLid (_, s)) -> + let (is_cls, li) = ctyp_long_id_prefix m in is_cls, ldot li s + | TyAcc (_, m, (TyUid (_, s) as t)) -> + error (loc_of_ctyp t) "invalid type name" + | TyApp (_, m1, m2) -> error (loc_of_ctyp t) "invalid type name" + | TyUid (_, s) -> error (loc_of_ctyp t) "invalid type name" | TyLid (_, s) -> false, lident s | TyCls (loc, sl) -> true, long_id_of_string_list loc sl - | t -> error (loc_of_ctyp t) "incorrect type" + | t -> error (loc_of_ctyp t) "invalid type" ;; let rec ctyp = @@ -151,7 +169,7 @@ let rec ctyp = match t1, t2 with t, TyQuo (_, s) -> t, s | TyQuo (_, s), t -> t, s - | _ -> error loc "incorrect alias type" + | _ -> error loc "invalid alias type" in mktyp loc (Ptyp_alias (ctyp t, i)) | TyAny loc -> mktyp loc Ptyp_any @@ -178,7 +196,7 @@ let rec ctyp = | TyRec (loc, _, _) -> error loc "record type not allowed here" | TySum (loc, _, _) -> error loc "sum type not allowed here" | TyTup (loc, tl) -> mktyp loc (Ptyp_tuple (List.map ctyp tl)) - | TyUid (loc, s) -> mktyp loc (Ptyp_constr (lident s, [])) + | TyUid (loc, s) as t -> error (loc_of_ctyp t) "invalid type" | TyVrn (loc, catl, ool) -> let catl = List.map @@ -391,7 +409,7 @@ let rec patt = match p1, p2 with p, PaLid (_, s) -> p, s | PaLid (_, s), p -> p, s - | _ -> error loc "incorrect alias pattern" + | _ -> error loc "invalid alias pattern" in mkpat loc (Ppat_alias (patt p, i)) | PaAnt (_, p) -> patt p @@ -623,6 +641,14 @@ let rec expr = mkexp loc (Pexp_letmodule (i, module_expr me, expr e)) | ExMat (loc, e, pel) -> mkexp loc (Pexp_match (expr e, List.map mkpwe pel)) | ExNew (loc, id) -> mkexp loc (Pexp_new (long_id_of_string_list loc id)) + | ExObj (loc, po, cfl) -> + let p = + match po with + Some p -> p + | None -> PaAny loc + in + let cil = List.fold_right class_str_item cfl [] in + mkexp loc (Pexp_object (patt p, cil)) | ExOlb (loc, _, _) -> error loc "labeled expression not allowed here" | ExOvr (loc, iel) -> mkexp loc (Pexp_override (List.map mkideexp iel)) | ExRec (loc, lel, eo) -> diff --git a/camlp4/ocaml_src/camlp4/ast2pt.mli b/camlp4/ocaml_src/camlp4/ast2pt.mli index d64fb6e370..c6aeab292b 100644 --- a/camlp4/ocaml_src/camlp4/ast2pt.mli +++ b/camlp4/ocaml_src/camlp4/ast2pt.mli @@ -14,8 +14,8 @@ val fast : bool ref;; val no_constructors_arity : bool ref;; -val mkloc : int * int -> Location.t;; -val long_id_of_string_list : int * int -> string list -> Longident.t;; +val mkloc : MLast.loc -> Location.t;; +val long_id_of_string_list : MLast.loc -> string list -> Longident.t;; val str_item : MLast.str_item -> Parsetree.structure -> Parsetree.structure;; val interf : MLast.sig_item list -> Parsetree.signature;; diff --git a/camlp4/ocaml_src/camlp4/mLast.mli b/camlp4/ocaml_src/camlp4/mLast.mli index 54a66b9c65..5dc63a296e 100644 --- a/camlp4/ocaml_src/camlp4/mLast.mli +++ b/camlp4/ocaml_src/camlp4/mLast.mli @@ -19,7 +19,7 @@ these values in concrete syntax (see the Camlp4 documentation). See also the file q_MLast.ml in Camlp4 sources. *) -type loc = int * int;; +type loc = Lexing.position * Lexing.position;; type ctyp = TyAcc of loc * ctyp * ctyp @@ -104,6 +104,7 @@ and expr = | ExLmd of loc * string * module_expr * expr | ExMat of loc * expr * (patt * expr option * expr) list | ExNew of loc * string list + | ExObj of loc * patt option * class_str_item list | ExOlb of loc * string * expr option | ExOvr of loc * (string * expr) list | ExRec of loc * (patt * expr) list * expr option diff --git a/camlp4/ocaml_src/camlp4/pcaml.ml b/camlp4/ocaml_src/camlp4/pcaml.ml index 7258fa070e..7d29cdad8b 100644 --- a/camlp4/ocaml_src/camlp4/pcaml.ml +++ b/camlp4/ocaml_src/camlp4/pcaml.ml @@ -20,7 +20,7 @@ let gram = Grammar.gcreate {Token.tok_func = (fun _ -> failwith "no loaded parsing module"); Token.tok_using = (fun _ -> ()); Token.tok_removing = (fun _ -> ()); - Token.tok_match = (fun _ -> raise (Match_failure ("pcaml.ml", 23, 23))); + Token.tok_match = (fun _ -> raise (Match_failure ("", 23, 23))); Token.tok_text = (fun _ -> ""); Token.tok_comm = None} ;; @@ -58,7 +58,11 @@ let input_file = ref "";; let output_file = ref None;; let warning_default_function (bp, ep) txt = - Printf.eprintf "<W> loc %d %d: %s\n" bp ep txt; flush stderr + let c1 = bp.Lexing.pos_cnum - bp.Lexing.pos_bol in + let c2 = ep.Lexing.pos_cnum - bp.Lexing.pos_bol in + Printf.eprintf "<W> File \"%s\", line %d, chars %d-%d: %s\n" + bp.Lexing.pos_fname bp.Lexing.pos_lnum c1 c2 txt; + flush stderr ;; let warning = ref warning_default_function;; @@ -78,7 +82,7 @@ let quotation_dump_file = ref (None : string option);; type err_ctx = Finding | Expanding - | ParsingResult of (int * int) * string + | ParsingResult of MLast.loc * string | Locating ;; exception Qerror of string * err_ctx * exn;; @@ -86,14 +90,16 @@ exception Qerror of string * err_ctx * exn;; let expand_quotation loc expander shift name str = let new_warning = let warn = !warning in - fun (bp, ep) txt -> warn (shift + bp, shift + ep) txt + fun (bp, ep) txt -> warn (Reloc.adjust_loc shift (bp, ep)) txt in apply_with_var warning new_warning (fun () -> try expander str with - Stdpp.Exc_located ((p1, p2), exc) -> + Stdpp.Exc_located (loc, exc) -> let exc1 = Qerror (name, Expanding, exc) in - raise (Stdpp.Exc_located ((shift + p1, shift + p2), exc1)) + raise + (Stdpp.Exc_located + (Reloc.adjust_loc shift (Reloc.linearize loc), exc1)) | exc -> let exc1 = Qerror (name, Expanding, exc) in raise (Stdpp.Exc_located (loc, exc1))) @@ -103,7 +109,7 @@ let parse_quotation_result entry loc shift name str = let cs = Stream.of_string str in try Grammar.Entry.parse entry cs with Stdpp.Exc_located (iloc, (Qerror (_, Locating, _) as exc)) -> - raise (Stdpp.Exc_located ((shift + fst iloc, shift + snd iloc), exc)) + raise (Stdpp.Exc_located (Reloc.adjust_loc shift iloc, exc)) | Stdpp.Exc_located (iloc, Qerror (_, Expanding, exc)) -> let ctx = ParsingResult (iloc, str) in let exc1 = Qerror (name, ctx, exc) in @@ -116,18 +122,22 @@ let parse_quotation_result entry loc shift name str = raise (Stdpp.Exc_located (loc, exc1)) ;; +let ghostify (bp, ep) = + let ghost p = {p with Lexing.pos_cnum = 0} in ghost bp, ghost ep +;; + let handle_quotation loc proj in_expr entry reloc (name, str) = let shift = match name with "" -> String.length "<<" | _ -> String.length "<:" + String.length name + String.length "<" in - let shift = fst loc + shift in + let shift = Reloc.shift_pos shift (fst loc) in let expander = try Quotation.find name with exc -> let exc1 = Qerror (name, Finding, exc) in - let loc = fst loc, shift in raise (Stdpp.Exc_located (loc, exc1)) + raise (Stdpp.Exc_located ((fst loc, shift), exc1)) in let ast = match expander with @@ -137,7 +147,13 @@ let handle_quotation loc proj in_expr entry reloc (name, str) = | Quotation.ExAst fe_fp -> expand_quotation loc (proj fe_fp) shift name str in - reloc (fun _ -> loc) shift ast + reloc + (let zero = ref None in + fun _ -> + match !zero with + None -> zero := Some (ghostify loc); loc + | Some x -> x) + shift ast ;; let parse_locate entry shift str = @@ -146,12 +162,12 @@ let parse_locate entry shift str = Stdpp.Exc_located ((p1, p2), exc) -> let ctx = Locating in let exc1 = Qerror (Grammar.Entry.name entry, ctx, exc) in - raise (Stdpp.Exc_located ((shift + p1, shift + p2), exc1)) + raise (Stdpp.Exc_located (Reloc.adjust_loc shift (p1, p2), exc1)) ;; let handle_locate loc entry ast_f (pos, str) = let s = str in - let loc = pos, pos + String.length s in + let loc = pos, Reloc.shift_pos (String.length s) pos in let x = parse_locate entry (fst loc) s in ast_f loc x ;; @@ -165,13 +181,15 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'expr) (loc : int * int) -> (x : 'expr_eoi))]]; + (fun _ (x : 'expr) (loc : Lexing.position * Lexing.position) -> + (x : 'expr_eoi))]]; Grammar.Entry.obj (patt_eoi : 'patt_eoi Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'patt) (loc : int * int) -> (x : 'patt_eoi))]]];; + (fun _ (x : 'patt) (loc : Lexing.position * Lexing.position) -> + (x : 'patt_eoi))]]];; let handle_expr_quotation loc x = handle_quotation loc fst true expr_eoi Reloc.expr x @@ -191,13 +209,8 @@ let patt_reloc = Reloc.patt;; let rename_id = ref (fun x -> x);; let find_line (bp, ep) str = - let rec find i line col = - if i == String.length str then line, 0, col - else if i == bp then line, col, col + ep - bp - else if str.[i] == '\n' then find (succ i) (succ line) 0 - else find (succ i) line (succ col) - in - find 0 1 0 + bp.Lexing.pos_lnum, bp.Lexing.pos_cnum - bp.Lexing.pos_bol, + ep.Lexing.pos_cnum - bp.Lexing.pos_bol ;; let loc_fmt = @@ -332,7 +345,7 @@ let report_error exn = | e -> print_exn exn ;; -let no_constructors_arity = Ast2pt.no_constructors_arity;; +let no_constructors_arity = ref false;; (*value no_assert = ref False;*) let arg_spec_list_ref = ref [];; @@ -360,48 +373,37 @@ and kont = pretty Stream.t ;; let pr_str_item = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 385, 30))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 397, 30))); pr_levels = []} ;; let pr_sig_item = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 386, 30))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 398, 30))); pr_levels = []} ;; let pr_module_type = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 387, 33))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 399, 33))); pr_levels = []} ;; let pr_module_expr = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 388, 33))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 400, 33))); pr_levels = []} ;; let pr_expr = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 389, 26))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 401, 26))); pr_levels = []} ;; let pr_patt = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 390, 26))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 402, 26))); pr_levels = []} ;; let pr_ctyp = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 391, 26))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 403, 26))); pr_levels = []} ;; let pr_class_sig_item = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 392, 36))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 404, 36))); pr_levels = []} ;; let pr_class_str_item = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 393, 36))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 405, 36))); pr_levels = []} ;; let pr_class_type = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 394, 32))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 406, 32))); pr_levels = []} ;; let pr_class_expr = - {pr_fun = (fun _ -> raise (Match_failure ("pcaml.ml", 395, 32))); - pr_levels = []} + {pr_fun = (fun _ -> raise (Match_failure ("", 407, 32))); pr_levels = []} ;; let pr_expr_fun_args = ref Extfun.empty;; diff --git a/camlp4/ocaml_src/camlp4/pcaml.mli b/camlp4/ocaml_src/camlp4/pcaml.mli index 8f8eacaf24..24c2256bed 100644 --- a/camlp4/ocaml_src/camlp4/pcaml.mli +++ b/camlp4/ocaml_src/camlp4/pcaml.mli @@ -83,13 +83,15 @@ val no_constructors_arity : bool ref;; val sync : (char Stream.t -> unit) ref;; val handle_expr_quotation : MLast.loc -> string * string -> MLast.expr;; -val handle_expr_locate : MLast.loc -> int * string -> MLast.expr;; +val handle_expr_locate : MLast.loc -> Lexing.position * string -> MLast.expr;; val handle_patt_quotation : MLast.loc -> string * string -> MLast.patt;; -val handle_patt_locate : MLast.loc -> int * string -> MLast.patt;; +val handle_patt_locate : MLast.loc -> Lexing.position * string -> MLast.patt;; -val expr_reloc : (MLast.loc -> MLast.loc) -> int -> MLast.expr -> MLast.expr;; -val patt_reloc : (MLast.loc -> MLast.loc) -> int -> MLast.patt -> MLast.patt;; +val expr_reloc : + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.expr -> MLast.expr;; +val patt_reloc : + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.patt -> MLast.patt;; (** To possibly rename identifiers; parsers may call this function when generating their identifiers; default = identity *) @@ -99,7 +101,7 @@ val rename_id : (string -> string) ref;; type err_ctx = Finding | Expanding - | ParsingResult of (int * int) * string + | ParsingResult of MLast.loc * string | Locating ;; exception Qerror of string * err_ctx * exn;; @@ -152,7 +154,8 @@ val inter_phrases : string option ref;; (* for system use *) -val warning : (int * int -> string -> unit) ref;; +val warning : (MLast.loc -> string -> unit) ref;; val expr_eoi : MLast.expr Grammar.Entry.e;; val patt_eoi : MLast.patt Grammar.Entry.e;; val arg_spec_list : unit -> (string * Arg.spec * string) list;; +val no_constructors_arity : bool ref;; diff --git a/camlp4/ocaml_src/camlp4/reloc.ml b/camlp4/ocaml_src/camlp4/reloc.ml index 980d6ce786..1e22fee939 100644 --- a/camlp4/ocaml_src/camlp4/reloc.ml +++ b/camlp4/ocaml_src/camlp4/reloc.ml @@ -63,150 +63,268 @@ let class_infos a floc sh x = ciExp = a floc sh x.ciExp} ;; +(* Debugging positions and locations *) +let eprint_pos msg p = + Printf.eprintf "%s: fname=%s; lnum=%d; bol=%d; cnum=%d\n%!" msg + p.Lexing.pos_fname p.Lexing.pos_lnum p.Lexing.pos_bol p.Lexing.pos_cnum +;; + +let eprint_loc (bp, ep) = eprint_pos " P1" bp; eprint_pos " P2" ep;; + +let check_position msg p = + let ok = + if p.Lexing.pos_lnum < 0 || p.Lexing.pos_bol < 0 || + p.Lexing.pos_cnum < 0 || p.Lexing.pos_cnum < p.Lexing.pos_bol + then + begin + Printf.eprintf "*** Warning: (%s) strange position ***\n" msg; + eprint_pos msg p; + false + end + else true + in + ok, p +;; + +let check_location msg (bp, ep as loc) = + let ok = + let (ok1, _) = check_position " From: " bp in + let (ok2, _) = check_position " To: " ep in + if not ok1 || not ok2 || bp.Lexing.pos_lnum > ep.Lexing.pos_lnum || + bp.Lexing.pos_bol > ep.Lexing.pos_bol || + bp.Lexing.pos_cnum > ep.Lexing.pos_cnum + then + begin + Printf.eprintf "*** Warning: (%s) strange location ***\n" msg; + eprint_loc loc; + false + end + else true + in + ok, loc +;; + +(* Change a location into linear positions *) +let linearize (bp, ep) = + {bp with Lexing.pos_lnum = 1; Lexing.pos_bol = 0}, + {ep with Lexing.pos_lnum = 1; Lexing.pos_bol = 0} +;; + +let shift_pos n p = {p with Lexing.pos_cnum = p.Lexing.pos_cnum + n};; + +let zero_loc = + {(Lexing.dummy_pos) with Lexing.pos_cnum = 0; Lexing.pos_lnum = 0} +;; + + +let adjust_pos globpos local_pos = + {Lexing.pos_fname = globpos.Lexing.pos_fname; + Lexing.pos_lnum = globpos.Lexing.pos_lnum + local_pos.Lexing.pos_lnum - 1; + Lexing.pos_bol = + if local_pos.Lexing.pos_lnum <= 1 then globpos.Lexing.pos_bol + else local_pos.Lexing.pos_bol + globpos.Lexing.pos_cnum; + Lexing.pos_cnum = local_pos.Lexing.pos_cnum + globpos.Lexing.pos_cnum} +;; + +let adjust_loc gpos (p1, p2) = adjust_pos gpos p1, adjust_pos gpos p2;; + +(* Note: in the following, the "let nloc = floc loc in" is necessary + in order to force evaluation order: the "floc" function has a side-effect + that changes all locations produced but the first one into ghost locations *) + let rec patt floc sh = let rec self = function - PaAcc (loc, x1, x2) -> PaAcc (floc loc, self x1, self x2) - | PaAli (loc, x1, x2) -> PaAli (floc loc, self x1, self x2) + PaAcc (loc, x1, x2) -> + let nloc = floc loc in PaAcc (nloc, self x1, self x2) + | PaAli (loc, x1, x2) -> + let nloc = floc loc in PaAli (nloc, self x1, self x2) | PaAnt (loc, x1) -> - patt (fun (p1, p2) -> sh + fst loc + p1, sh + fst loc + p2) 0 x1 - | PaAny loc -> PaAny (floc loc) - | PaApp (loc, x1, x2) -> PaApp (floc loc, self x1, self x2) - | PaArr (loc, x1) -> PaArr (floc loc, List.map self x1) - | PaChr (loc, x1) -> PaChr (floc loc, x1) - | PaInt (loc, x1) -> PaInt (floc loc, x1) - | PaInt32 (loc, x1) -> PaInt32 (floc loc, x1) - | PaInt64 (loc, x1) -> PaInt64 (floc loc, x1) - | PaNativeInt (loc, x1) -> PaNativeInt (floc loc, x1) - | PaFlo (loc, x1) -> PaFlo (floc loc, x1) - | PaLab (loc, x1, x2) -> PaLab (floc loc, x1, option_map self x2) - | PaLid (loc, x1) -> PaLid (floc loc, x1) + patt + (fun lloc -> adjust_loc (adjust_pos sh (fst loc)) (linearize lloc)) + zero_loc x1 + | PaAny loc -> let nloc = floc loc in PaAny nloc + | PaApp (loc, x1, x2) -> + let nloc = floc loc in PaApp (nloc, self x1, self x2) + | PaArr (loc, x1) -> let nloc = floc loc in PaArr (nloc, List.map self x1) + | PaChr (loc, x1) -> let nloc = floc loc in PaChr (nloc, x1) + | PaInt (loc, x1) -> let nloc = floc loc in PaInt (nloc, x1) + | PaInt32 (loc, x1) -> let nloc = floc loc in PaInt32 (nloc, x1) + | PaInt64 (loc, x1) -> let nloc = floc loc in PaInt64 (nloc, x1) + | PaNativeInt (loc, x1) -> let nloc = floc loc in PaNativeInt (nloc, x1) + | PaFlo (loc, x1) -> let nloc = floc loc in PaFlo (nloc, x1) + | PaLab (loc, x1, x2) -> + let nloc = floc loc in PaLab (nloc, x1, option_map self x2) + | PaLid (loc, x1) -> let nloc = floc loc in PaLid (nloc, x1) | PaOlb (loc, x1, x2) -> + let nloc = floc loc in PaOlb - (floc loc, x1, + (nloc, x1, option_map (fun (x1, x2) -> self x1, option_map (expr floc sh) x2) x2) - | PaOrp (loc, x1, x2) -> PaOrp (floc loc, self x1, self x2) - | PaRng (loc, x1, x2) -> PaRng (floc loc, self x1, self x2) + | PaOrp (loc, x1, x2) -> + let nloc = floc loc in PaOrp (nloc, self x1, self x2) + | PaRng (loc, x1, x2) -> + let nloc = floc loc in PaRng (nloc, self x1, self x2) | PaRec (loc, x1) -> - PaRec (floc loc, List.map (fun (x1, x2) -> self x1, self x2) x1) - | PaStr (loc, x1) -> PaStr (floc loc, x1) - | PaTup (loc, x1) -> PaTup (floc loc, List.map self x1) - | PaTyc (loc, x1, x2) -> PaTyc (floc loc, self x1, ctyp floc sh x2) - | PaTyp (loc, x1) -> PaTyp (floc loc, x1) - | PaUid (loc, x1) -> PaUid (floc loc, x1) - | PaVrn (loc, x1) -> PaVrn (floc loc, x1) + let nloc = floc loc in + PaRec (nloc, List.map (fun (x1, x2) -> self x1, self x2) x1) + | PaStr (loc, x1) -> let nloc = floc loc in PaStr (nloc, x1) + | PaTup (loc, x1) -> let nloc = floc loc in PaTup (nloc, List.map self x1) + | PaTyc (loc, x1, x2) -> + let nloc = floc loc in PaTyc (nloc, self x1, ctyp floc sh x2) + | PaTyp (loc, x1) -> let nloc = floc loc in PaTyp (nloc, x1) + | PaUid (loc, x1) -> let nloc = floc loc in PaUid (nloc, x1) + | PaVrn (loc, x1) -> let nloc = floc loc in PaVrn (nloc, x1) in self and expr floc sh = let rec self = function - ExAcc (loc, x1, x2) -> ExAcc (floc loc, self x1, self x2) + ExAcc (loc, x1, x2) -> + let nloc = floc loc in ExAcc (nloc, self x1, self x2) | ExAnt (loc, x1) -> - expr (fun (p1, p2) -> sh + fst loc + p1, sh + fst loc + p2) 0 x1 - | ExApp (loc, x1, x2) -> ExApp (floc loc, self x1, self x2) - | ExAre (loc, x1, x2) -> ExAre (floc loc, self x1, self x2) - | ExArr (loc, x1) -> ExArr (floc loc, List.map self x1) - | ExAsf loc -> ExAsf (floc loc) - | ExAsr (loc, x1) -> ExAsr (floc loc, self x1) - | ExAss (loc, x1, x2) -> ExAss (floc loc, self x1, self x2) - | ExChr (loc, x1) -> ExChr (floc loc, x1) + expr + (fun lloc -> adjust_loc (adjust_pos sh (fst loc)) (linearize lloc)) + zero_loc x1 + | ExApp (loc, x1, x2) -> + let nloc = floc loc in ExApp (nloc, self x1, self x2) + | ExAre (loc, x1, x2) -> + let nloc = floc loc in ExAre (nloc, self x1, self x2) + | ExArr (loc, x1) -> let nloc = floc loc in ExArr (nloc, List.map self x1) + | ExAsf loc -> let nloc = floc loc in ExAsf nloc + | ExAsr (loc, x1) -> let nloc = floc loc in ExAsr (nloc, self x1) + | ExAss (loc, x1, x2) -> + let nloc = floc loc in ExAss (nloc, self x1, self x2) + | ExChr (loc, x1) -> let nloc = floc loc in ExChr (nloc, x1) | ExCoe (loc, x1, x2, x3) -> - ExCoe - (floc loc, self x1, option_map (ctyp floc sh) x2, ctyp floc sh x3) - | ExFlo (loc, x1) -> ExFlo (floc loc, x1) + let nloc = floc loc in + ExCoe (nloc, self x1, option_map (ctyp floc sh) x2, ctyp floc sh x3) + | ExFlo (loc, x1) -> let nloc = floc loc in ExFlo (nloc, x1) | ExFor (loc, x1, x2, x3, x4, x5) -> - ExFor (floc loc, x1, self x2, self x3, x4, List.map self x5) + let nloc = floc loc in + ExFor (nloc, x1, self x2, self x3, x4, List.map self x5) | ExFun (loc, x1) -> + let nloc = floc loc in ExFun - (floc loc, + (nloc, List.map (fun (x1, x2, x3) -> patt floc sh x1, option_map self x2, self x3) x1) - | ExIfe (loc, x1, x2, x3) -> ExIfe (floc loc, self x1, self x2, self x3) - | ExInt (loc, x1) -> ExInt (floc loc, x1) - | ExInt32 (loc, x1) -> ExInt32 (floc loc, x1) - | ExInt64 (loc, x1) -> ExInt64 (floc loc, x1) - | ExNativeInt (loc, x1) -> ExNativeInt (floc loc, x1) - | ExLab (loc, x1, x2) -> ExLab (floc loc, x1, option_map self x2) - | ExLaz (loc, x1) -> ExLaz (floc loc, self x1) + | ExIfe (loc, x1, x2, x3) -> + let nloc = floc loc in ExIfe (nloc, self x1, self x2, self x3) + | ExInt (loc, x1) -> let nloc = floc loc in ExInt (nloc, x1) + | ExInt32 (loc, x1) -> let nloc = floc loc in ExInt32 (nloc, x1) + | ExInt64 (loc, x1) -> let nloc = floc loc in ExInt64 (nloc, x1) + | ExNativeInt (loc, x1) -> let nloc = floc loc in ExNativeInt (nloc, x1) + | ExLab (loc, x1, x2) -> + let nloc = floc loc in ExLab (nloc, x1, option_map self x2) + | ExLaz (loc, x1) -> let nloc = floc loc in ExLaz (nloc, self x1) | ExLet (loc, x1, x2, x3) -> + let nloc = floc loc in ExLet - (floc loc, x1, - List.map (fun (x1, x2) -> patt floc sh x1, self x2) x2, self x3) - | ExLid (loc, x1) -> ExLid (floc loc, x1) + (nloc, x1, List.map (fun (x1, x2) -> patt floc sh x1, self x2) x2, + self x3) + | ExLid (loc, x1) -> let nloc = floc loc in ExLid (nloc, x1) | ExLmd (loc, x1, x2, x3) -> - ExLmd (floc loc, x1, module_expr floc sh x2, self x3) + let nloc = floc loc in + ExLmd (nloc, x1, module_expr floc sh x2, self x3) | ExMat (loc, x1, x2) -> + let nloc = floc loc in ExMat - (floc loc, self x1, + (nloc, self x1, List.map (fun (x1, x2, x3) -> patt floc sh x1, option_map self x2, self x3) x2) - | ExNew (loc, x1) -> ExNew (floc loc, x1) - | ExOlb (loc, x1, x2) -> ExOlb (floc loc, x1, option_map self x2) + | ExNew (loc, x1) -> let nloc = floc loc in ExNew (nloc, x1) + | ExObj (loc, x1, x2) -> + let nloc = floc loc in + ExObj + (nloc, option_map (patt floc sh) x1, + List.map (class_str_item floc sh) x2) + | ExOlb (loc, x1, x2) -> + let nloc = floc loc in ExOlb (nloc, x1, option_map self x2) | ExOvr (loc, x1) -> - ExOvr (floc loc, List.map (fun (x1, x2) -> x1, self x2) x1) + let nloc = floc loc in + ExOvr (nloc, List.map (fun (x1, x2) -> x1, self x2) x1) | ExRec (loc, x1, x2) -> + let nloc = floc loc in ExRec - (floc loc, List.map (fun (x1, x2) -> patt floc sh x1, self x2) x1, + (nloc, List.map (fun (x1, x2) -> patt floc sh x1, self x2) x1, option_map self x2) - | ExSeq (loc, x1) -> ExSeq (floc loc, List.map self x1) - | ExSnd (loc, x1, x2) -> ExSnd (floc loc, self x1, x2) - | ExSte (loc, x1, x2) -> ExSte (floc loc, self x1, self x2) - | ExStr (loc, x1) -> ExStr (floc loc, x1) + | ExSeq (loc, x1) -> let nloc = floc loc in ExSeq (nloc, List.map self x1) + | ExSnd (loc, x1, x2) -> let nloc = floc loc in ExSnd (nloc, self x1, x2) + | ExSte (loc, x1, x2) -> + let nloc = floc loc in ExSte (nloc, self x1, self x2) + | ExStr (loc, x1) -> let nloc = floc loc in ExStr (nloc, x1) | ExTry (loc, x1, x2) -> + let nloc = floc loc in ExTry - (floc loc, self x1, + (nloc, self x1, List.map (fun (x1, x2, x3) -> patt floc sh x1, option_map self x2, self x3) x2) - | ExTup (loc, x1) -> ExTup (floc loc, List.map self x1) - | ExTyc (loc, x1, x2) -> ExTyc (floc loc, self x1, ctyp floc sh x2) - | ExUid (loc, x1) -> ExUid (floc loc, x1) - | ExVrn (loc, x1) -> ExVrn (floc loc, x1) - | ExWhi (loc, x1, x2) -> ExWhi (floc loc, self x1, List.map self x2) + | ExTup (loc, x1) -> let nloc = floc loc in ExTup (nloc, List.map self x1) + | ExTyc (loc, x1, x2) -> + let nloc = floc loc in ExTyc (nloc, self x1, ctyp floc sh x2) + | ExUid (loc, x1) -> let nloc = floc loc in ExUid (nloc, x1) + | ExVrn (loc, x1) -> let nloc = floc loc in ExVrn (nloc, x1) + | ExWhi (loc, x1, x2) -> + let nloc = floc loc in ExWhi (nloc, self x1, List.map self x2) in self and module_type floc sh = let rec self = function - MtAcc (loc, x1, x2) -> MtAcc (floc loc, self x1, self x2) - | MtApp (loc, x1, x2) -> MtApp (floc loc, self x1, self x2) - | MtFun (loc, x1, x2, x3) -> MtFun (floc loc, x1, self x2, self x3) - | MtLid (loc, x1) -> MtLid (floc loc, x1) - | MtQuo (loc, x1) -> MtQuo (floc loc, x1) - | MtSig (loc, x1) -> MtSig (floc loc, List.map (sig_item floc sh) x1) - | MtUid (loc, x1) -> MtUid (floc loc, x1) + MtAcc (loc, x1, x2) -> + let nloc = floc loc in MtAcc (nloc, self x1, self x2) + | MtApp (loc, x1, x2) -> + let nloc = floc loc in MtApp (nloc, self x1, self x2) + | MtFun (loc, x1, x2, x3) -> + let nloc = floc loc in MtFun (nloc, x1, self x2, self x3) + | MtLid (loc, x1) -> let nloc = floc loc in MtLid (nloc, x1) + | MtQuo (loc, x1) -> let nloc = floc loc in MtQuo (nloc, x1) + | MtSig (loc, x1) -> + let nloc = floc loc in MtSig (nloc, List.map (sig_item floc sh) x1) + | MtUid (loc, x1) -> let nloc = floc loc in MtUid (nloc, x1) | MtWit (loc, x1, x2) -> - MtWit (floc loc, self x1, List.map (with_constr floc sh) x2) + let nloc = floc loc in + MtWit (nloc, self x1, List.map (with_constr floc sh) x2) in self and sig_item floc sh = let rec self = function SgCls (loc, x1) -> - SgCls (floc loc, List.map (class_infos class_type floc sh) x1) + let nloc = floc loc in + SgCls (nloc, List.map (class_infos class_type floc sh) x1) | SgClt (loc, x1) -> - SgClt (floc loc, List.map (class_infos class_type floc sh) x1) - | SgDcl (loc, x1) -> SgDcl (floc loc, List.map self x1) - | SgDir (loc, x1, x2) -> SgDir (floc loc, x1, x2) - | SgExc (loc, x1, x2) -> SgExc (floc loc, x1, List.map (ctyp floc sh) x2) - | SgExt (loc, x1, x2, x3) -> SgExt (floc loc, x1, ctyp floc sh x2, x3) - | SgInc (loc, x1) -> SgInc (floc loc, module_type floc sh x1) - | SgMod (loc, x1, x2) -> SgMod (floc loc, x1, module_type floc sh x2) + let nloc = floc loc in + SgClt (nloc, List.map (class_infos class_type floc sh) x1) + | SgDcl (loc, x1) -> let nloc = floc loc in SgDcl (nloc, List.map self x1) + | SgDir (loc, x1, x2) -> let nloc = floc loc in SgDir (nloc, x1, x2) + | SgExc (loc, x1, x2) -> + let nloc = floc loc in SgExc (nloc, x1, List.map (ctyp floc sh) x2) + | SgExt (loc, x1, x2, x3) -> + let nloc = floc loc in SgExt (nloc, x1, ctyp floc sh x2, x3) + | SgInc (loc, x1) -> + let nloc = floc loc in SgInc (nloc, module_type floc sh x1) + | SgMod (loc, x1, x2) -> + let nloc = floc loc in SgMod (nloc, x1, module_type floc sh x2) | SgRecMod (loc, xxs) -> + let nloc = floc loc in SgRecMod - (floc loc, - List.map (fun (x1, x2) -> x1, module_type floc sh x2) xxs) - | SgMty (loc, x1, x2) -> SgMty (floc loc, x1, module_type floc sh x2) - | SgOpn (loc, x1) -> SgOpn (floc loc, x1) + (nloc, List.map (fun (x1, x2) -> x1, module_type floc sh x2) xxs) + | SgMty (loc, x1, x2) -> + let nloc = floc loc in SgMty (nloc, x1, module_type floc sh x2) + | SgOpn (loc, x1) -> let nloc = floc loc in SgOpn (nloc, x1) | SgTyp (loc, x1) -> + let nloc = floc loc in SgTyp - (floc loc, + (nloc, List.map (fun ((loc, x1), x2, x3, x4) -> (floc loc, x1), x2, ctyp floc sh x3, @@ -214,55 +332,72 @@ and sig_item floc sh = x4) x1) | SgUse (loc, x1, x2) -> SgUse (loc, x1, x2) - | SgVal (loc, x1, x2) -> SgVal (floc loc, x1, ctyp floc sh x2) + | SgVal (loc, x1, x2) -> + let nloc = floc loc in SgVal (nloc, x1, ctyp floc sh x2) in self and with_constr floc sh = let rec self = function - WcTyp (loc, x1, x2, x3) -> WcTyp (floc loc, x1, x2, ctyp floc sh x3) - | WcMod (loc, x1, x2) -> WcMod (floc loc, x1, module_expr floc sh x2) + WcTyp (loc, x1, x2, x3) -> + let nloc = floc loc in WcTyp (nloc, x1, x2, ctyp floc sh x3) + | WcMod (loc, x1, x2) -> + let nloc = floc loc in WcMod (nloc, x1, module_expr floc sh x2) in self and module_expr floc sh = let rec self = function - MeAcc (loc, x1, x2) -> MeAcc (floc loc, self x1, self x2) - | MeApp (loc, x1, x2) -> MeApp (floc loc, self x1, self x2) + MeAcc (loc, x1, x2) -> + let nloc = floc loc in MeAcc (nloc, self x1, self x2) + | MeApp (loc, x1, x2) -> + let nloc = floc loc in MeApp (nloc, self x1, self x2) | MeFun (loc, x1, x2, x3) -> - MeFun (floc loc, x1, module_type floc sh x2, self x3) - | MeStr (loc, x1) -> MeStr (floc loc, List.map (str_item floc sh) x1) - | MeTyc (loc, x1, x2) -> MeTyc (floc loc, self x1, module_type floc sh x2) - | MeUid (loc, x1) -> MeUid (floc loc, x1) + let nloc = floc loc in + MeFun (nloc, x1, module_type floc sh x2, self x3) + | MeStr (loc, x1) -> + let nloc = floc loc in MeStr (nloc, List.map (str_item floc sh) x1) + | MeTyc (loc, x1, x2) -> + let nloc = floc loc in MeTyc (nloc, self x1, module_type floc sh x2) + | MeUid (loc, x1) -> let nloc = floc loc in MeUid (nloc, x1) in self and str_item floc sh = let rec self = function StCls (loc, x1) -> - StCls (floc loc, List.map (class_infos class_expr floc sh) x1) + let nloc = floc loc in + StCls (nloc, List.map (class_infos class_expr floc sh) x1) | StClt (loc, x1) -> - StClt (floc loc, List.map (class_infos class_type floc sh) x1) - | StDcl (loc, x1) -> StDcl (floc loc, List.map self x1) - | StDir (loc, x1, x2) -> StDir (floc loc, x1, x2) + let nloc = floc loc in + StClt (nloc, List.map (class_infos class_type floc sh) x1) + | StDcl (loc, x1) -> let nloc = floc loc in StDcl (nloc, List.map self x1) + | StDir (loc, x1, x2) -> let nloc = floc loc in StDir (nloc, x1, x2) | StExc (loc, x1, x2, x3) -> - StExc (floc loc, x1, List.map (ctyp floc sh) x2, x3) - | StExp (loc, x1) -> StExp (floc loc, expr floc sh x1) - | StExt (loc, x1, x2, x3) -> StExt (floc loc, x1, ctyp floc sh x2, x3) - | StInc (loc, x1) -> StInc (floc loc, module_expr floc sh x1) - | StMod (loc, x1, x2) -> StMod (floc loc, x1, module_expr floc sh x2) + let nloc = floc loc in + StExc (nloc, x1, List.map (ctyp floc sh) x2, x3) + | StExp (loc, x1) -> let nloc = floc loc in StExp (nloc, expr floc sh x1) + | StExt (loc, x1, x2, x3) -> + let nloc = floc loc in StExt (nloc, x1, ctyp floc sh x2, x3) + | StInc (loc, x1) -> + let nloc = floc loc in StInc (nloc, module_expr floc sh x1) + | StMod (loc, x1, x2) -> + let nloc = floc loc in StMod (nloc, x1, module_expr floc sh x2) | StRecMod (loc, nmtmes) -> + let nloc = floc loc in StRecMod - (floc loc, + (nloc, List.map (fun (n, mt, me) -> n, module_type floc sh mt, module_expr floc sh me) nmtmes) - | StMty (loc, x1, x2) -> StMty (floc loc, x1, module_type floc sh x2) - | StOpn (loc, x1) -> StOpn (floc loc, x1) + | StMty (loc, x1, x2) -> + let nloc = floc loc in StMty (nloc, x1, module_type floc sh x2) + | StOpn (loc, x1) -> let nloc = floc loc in StOpn (nloc, x1) | StTyp (loc, x1) -> + let nloc = floc loc in StTyp - (floc loc, + (nloc, List.map (fun ((loc, x1), x2, x3, x4) -> (floc loc, x1), x2, ctyp floc sh x3, @@ -271,19 +406,23 @@ and str_item floc sh = x1) | StUse (loc, x1, x2) -> StUse (loc, x1, x2) | StVal (loc, x1, x2) -> + let nloc = floc loc in StVal - (floc loc, x1, + (nloc, x1, List.map (fun (x1, x2) -> patt floc sh x1, expr floc sh x2) x2) in self and class_type floc sh = let rec self = function - CtCon (loc, x1, x2) -> CtCon (floc loc, x1, List.map (ctyp floc sh) x2) - | CtFun (loc, x1, x2) -> CtFun (floc loc, ctyp floc sh x1, self x2) + CtCon (loc, x1, x2) -> + let nloc = floc loc in CtCon (nloc, x1, List.map (ctyp floc sh) x2) + | CtFun (loc, x1, x2) -> + let nloc = floc loc in CtFun (nloc, ctyp floc sh x1, self x2) | CtSig (loc, x1, x2) -> + let nloc = floc loc in CtSig - (floc loc, option_map (ctyp floc sh) x1, + (nloc, option_map (ctyp floc sh) x1, List.map (class_sig_item floc sh) x2) in self @@ -291,47 +430,62 @@ and class_sig_item floc sh = let rec self = function CgCtr (loc, x1, x2) -> - CgCtr (floc loc, ctyp floc sh x1, ctyp floc sh x2) + let nloc = floc loc in CgCtr (nloc, ctyp floc sh x1, ctyp floc sh x2) | CgDcl (loc, x1) -> - CgDcl (floc loc, List.map (class_sig_item floc sh) x1) - | CgInh (loc, x1) -> CgInh (floc loc, class_type floc sh x1) - | CgMth (loc, x1, x2, x3) -> CgMth (floc loc, x1, x2, ctyp floc sh x3) - | CgVal (loc, x1, x2, x3) -> CgVal (floc loc, x1, x2, ctyp floc sh x3) - | CgVir (loc, x1, x2, x3) -> CgVir (floc loc, x1, x2, ctyp floc sh x3) + let nloc = floc loc in + CgDcl (nloc, List.map (class_sig_item floc sh) x1) + | CgInh (loc, x1) -> + let nloc = floc loc in CgInh (nloc, class_type floc sh x1) + | CgMth (loc, x1, x2, x3) -> + let nloc = floc loc in CgMth (nloc, x1, x2, ctyp floc sh x3) + | CgVal (loc, x1, x2, x3) -> + let nloc = floc loc in CgVal (nloc, x1, x2, ctyp floc sh x3) + | CgVir (loc, x1, x2, x3) -> + let nloc = floc loc in CgVir (nloc, x1, x2, ctyp floc sh x3) in self and class_expr floc sh = let rec self = function - CeApp (loc, x1, x2) -> CeApp (floc loc, self x1, expr floc sh x2) - | CeCon (loc, x1, x2) -> CeCon (floc loc, x1, List.map (ctyp floc sh) x2) - | CeFun (loc, x1, x2) -> CeFun (floc loc, patt floc sh x1, self x2) + CeApp (loc, x1, x2) -> + let nloc = floc loc in CeApp (nloc, self x1, expr floc sh x2) + | CeCon (loc, x1, x2) -> + let nloc = floc loc in CeCon (nloc, x1, List.map (ctyp floc sh) x2) + | CeFun (loc, x1, x2) -> + let nloc = floc loc in CeFun (nloc, patt floc sh x1, self x2) | CeLet (loc, x1, x2, x3) -> + let nloc = floc loc in CeLet - (floc loc, x1, + (nloc, x1, List.map (fun (x1, x2) -> patt floc sh x1, expr floc sh x2) x2, self x3) | CeStr (loc, x1, x2) -> + let nloc = floc loc in CeStr - (floc loc, option_map (patt floc sh) x1, + (nloc, option_map (patt floc sh) x1, List.map (class_str_item floc sh) x2) - | CeTyc (loc, x1, x2) -> CeTyc (floc loc, self x1, class_type floc sh x2) + | CeTyc (loc, x1, x2) -> + let nloc = floc loc in CeTyc (nloc, self x1, class_type floc sh x2) in self and class_str_item floc sh = let rec self = function CrCtr (loc, x1, x2) -> - CrCtr (floc loc, ctyp floc sh x1, ctyp floc sh x2) + let nloc = floc loc in CrCtr (nloc, ctyp floc sh x1, ctyp floc sh x2) | CrDcl (loc, x1) -> - CrDcl (floc loc, List.map (class_str_item floc sh) x1) - | CrInh (loc, x1, x2) -> CrInh (floc loc, class_expr floc sh x1, x2) - | CrIni (loc, x1) -> CrIni (floc loc, expr floc sh x1) + let nloc = floc loc in + CrDcl (nloc, List.map (class_str_item floc sh) x1) + | CrInh (loc, x1, x2) -> + let nloc = floc loc in CrInh (nloc, class_expr floc sh x1, x2) + | CrIni (loc, x1) -> let nloc = floc loc in CrIni (nloc, expr floc sh x1) | CrMth (loc, x1, x2, x3, x4) -> - CrMth - (floc loc, x1, x2, expr floc sh x3, option_map (ctyp floc sh) x4) - | CrVal (loc, x1, x2, x3) -> CrVal (floc loc, x1, x2, expr floc sh x3) - | CrVir (loc, x1, x2, x3) -> CrVir (floc loc, x1, x2, ctyp floc sh x3) + let nloc = floc loc in + CrMth (nloc, x1, x2, expr floc sh x3, option_map (ctyp floc sh) x4) + | CrVal (loc, x1, x2, x3) -> + let nloc = floc loc in CrVal (nloc, x1, x2, expr floc sh x3) + | CrVir (loc, x1, x2, x3) -> + let nloc = floc loc in CrVir (nloc, x1, x2, ctyp floc sh x3) in self ;; diff --git a/camlp4/ocaml_src/camlp4/reloc.mli b/camlp4/ocaml_src/camlp4/reloc.mli index 21018b52af..7d4f2bcb6a 100644 --- a/camlp4/ocaml_src/camlp4/reloc.mli +++ b/camlp4/ocaml_src/camlp4/reloc.mli @@ -12,5 +12,11 @@ (* This file has been generated by program: do not edit! *) -val patt : (MLast.loc -> MLast.loc) -> int -> MLast.patt -> MLast.patt;; -val expr : (MLast.loc -> MLast.loc) -> int -> MLast.expr -> MLast.expr;; +val zero_loc : Lexing.position;; +val shift_pos : int -> Lexing.position -> Lexing.position;; +val adjust_loc : Lexing.position -> MLast.loc -> MLast.loc;; +val linearize : MLast.loc -> MLast.loc;; +val patt : + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.patt -> MLast.patt;; +val expr : + (MLast.loc -> MLast.loc) -> Lexing.position -> MLast.expr -> MLast.expr;; diff --git a/camlp4/ocaml_src/lib/.depend b/camlp4/ocaml_src/lib/.depend index 0d5adc691f..d7afaebeb2 100644 --- a/camlp4/ocaml_src/lib/.depend +++ b/camlp4/ocaml_src/lib/.depend @@ -2,6 +2,7 @@ extfold.cmi: gramext.cmi gramext.cmi: token.cmi grammar.cmi: gramext.cmi token.cmi plexer.cmi: token.cmi +stdpp.cmi: token.cmi extfold.cmo: gramext.cmi grammar.cmi extfold.cmi extfold.cmx: gramext.cmx grammar.cmx extfold.cmi extfun.cmo: extfun.cmi @@ -14,7 +15,7 @@ grammar.cmo: gramext.cmi stdpp.cmi token.cmi grammar.cmi grammar.cmx: gramext.cmx stdpp.cmx token.cmx grammar.cmi plexer.cmo: stdpp.cmi token.cmi plexer.cmi plexer.cmx: stdpp.cmx token.cmx plexer.cmi -stdpp.cmo: stdpp.cmi -stdpp.cmx: stdpp.cmi +stdpp.cmo: token.cmi stdpp.cmi +stdpp.cmx: token.cmx stdpp.cmi token.cmo: token.cmi token.cmx: token.cmi diff --git a/camlp4/ocaml_src/lib/Makefile b/camlp4/ocaml_src/lib/Makefile index e19e52052b..9119b7aa96 100644 --- a/camlp4/ocaml_src/lib/Makefile +++ b/camlp4/ocaml_src/lib/Makefile @@ -43,6 +43,6 @@ install: installopt: cp $(TARGET:.cma=.cmxa) *.cmx "$(LIBDIR)/camlp4/." - tar cf - $(TARGET:.cma=.$(A)) | (cd "$(LIBDIR)/camlp4/."; tar xf -) + TARG=`echo "$(TARGET)" | sed -e "s/\.cma\$$/.$(A)/g"` && tar cf - $$TARG | (cd "$(LIBDIR)/camlp4/." && tar xf -) include .depend diff --git a/camlp4/ocaml_src/lib/grammar.ml b/camlp4/ocaml_src/lib/grammar.ml index 196a6b954a..3501976d1a 100644 --- a/camlp4/ocaml_src/lib/grammar.ml +++ b/camlp4/ocaml_src/lib/grammar.ml @@ -194,11 +194,13 @@ external grammar_obj : g -> Token.t grammar = "%identity";; let floc = ref (fun _ -> failwith "internal error when computing location");; let loc_of_token_interval bp ep = if bp == ep then - if bp == 0 then 0, 1 else let a = snd (!floc (bp - 1)) in a, a + 1 + if bp == 0 then Token.nowhere, Token.succ_pos Token.nowhere + else let a = snd (!floc (bp - 1)) in a, Token.succ_pos a else let (bp1, bp2) = !floc bp in let (ep1, ep2) = !floc (pred ep) in - (if bp1 < ep1 then bp1 else ep1), (if bp2 > ep2 then bp2 else ep2) + (if Token.lt_pos bp1 ep1 then bp1 else ep1), + (if Token.lt_pos ep2 bp2 then bp2 else ep2) ;; let rec name_of_symbol entry = @@ -805,7 +807,7 @@ let parse_parsable entry efun (cs, (ts, fun_loc)) = if !token_count - 1 <= cnt then loc else fst loc, snd (fun_loc (!token_count - 1)) with - _ -> Stream.count cs, Stream.count cs + 1 + _ -> Token.nowhere, Token.succ_pos Token.nowhere in floc := fun_loc; token_count := 0; @@ -817,7 +819,7 @@ let parse_parsable entry efun (cs, (ts, fun_loc)) = | Stream.Error _ as exc -> let loc = get_loc () in restore (); raise_with_loc loc exc | exc -> - let loc = Stream.count cs, Stream.count cs + 1 in + let loc = Token.nowhere, Token.succ_pos Token.nowhere in restore (); raise_with_loc loc exc ;; @@ -1060,7 +1062,7 @@ module type ReinitType = sig val reinit_gram : g -> Token.lexer -> unit;; end module GGMake (R : ReinitType) (L : GLexerType) = struct type te = L.te;; - type parsable = char Stream.t * (te Stream.t * Token.location_function);; + type parsable = char Stream.t * (te Stream.t * Token.flocation_function);; let gram = gcreate L.lexer;; let parsable cs = cs, L.lexer.Token.tok_func cs;; let tokens = tokens gram;; diff --git a/camlp4/ocaml_src/lib/grammar.mli b/camlp4/ocaml_src/lib/grammar.mli index d38b449f95..34dee1b3eb 100644 --- a/camlp4/ocaml_src/lib/grammar.mli +++ b/camlp4/ocaml_src/lib/grammar.mli @@ -183,7 +183,7 @@ val create : Token.lexer -> g;; (*** For system use *) -val loc_of_token_interval : int -> int -> int * int;; +val loc_of_token_interval : int -> int -> Token.flocation;; val extend : ('te Gramext.g_entry * Gramext.position option * (string option * Gramext.g_assoc option * diff --git a/camlp4/ocaml_src/lib/plexer.ml b/camlp4/ocaml_src/lib/plexer.ml index 4b5dcca151..43d5c8d95a 100644 --- a/camlp4/ocaml_src/lib/plexer.ml +++ b/camlp4/ocaml_src/lib/plexer.ml @@ -92,6 +92,9 @@ and digits_under kind len (strm__ : _ Stream.t) = | _ -> match Stream.peek strm__ with Some '_' -> Stream.junk strm__; digits_under kind len strm__ + | Some 'l' -> Stream.junk strm__; "INT32", get_buff len + | Some 'L' -> Stream.junk strm__; "INT64", get_buff len + | Some 'n' -> Stream.junk strm__; "NATIVEINT", get_buff len | _ -> "INT", get_buff len and octal (strm__ : _ Stream.t) = match Stream.peek strm__ with @@ -145,371 +148,85 @@ and end_exponent_part_under len (strm__ : _ Stream.t) = let error_on_unknown_keywords = ref false;; let err loc msg = raise_with_loc loc (Token.Error msg);; -(* -value next_token_fun dfa find_kwd = - let keyword_or_error loc s = - try (("", find_kwd s), loc) with - [ Not_found -> - if error_on_unknown_keywords.val then err loc ("illegal token: " ^ s) - else (("", s), loc) ] - in - let rec next_token = - parser bp - [ [: `' ' | '\010' | '\013' | '\t' | '\026' | '\012'; s :] -> - next_token s - | [: `'('; s :] -> left_paren bp s - | [: `'#'; s :] -> do { spaces_tabs s; linenum bp s } - | [: `('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c); s :] -> - let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in - (try ("", find_kwd id) with [ Not_found -> ("UIDENT", id) ], loc) - | [: `('a'..'z' | '\223'..'\246' | '\248'..'\255' | '_' as c); s :] -> - let id = get_buff (ident (store 0 c) s) in - let loc = (bp, Stream.count s) in - (try ("", find_kwd id) with [ Not_found -> ("LIDENT", id) ], loc) - | [: `('1'..'9' as c); s :] -> - let tok = number (store 0 c) s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'0'; s :] -> - let tok = base_number (store 0 '0') s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'''; s :] -> - match Stream.npeek 3 s with - [ [_; '''; _] | ['\\'; _; _] | ['\x0D'; '\x0A'; '''] -> - let tok = ("CHAR", get_buff (char bp 0 s)) in - let loc = (bp, Stream.count s) in - (tok, loc) - | _ -> keyword_or_error (bp, Stream.count s) "'" ] - | [: `'"'; s :] -> - let tok = ("STRING", get_buff (string bp 0 s)) in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `'$'; s :] -> - let tok = dollar bp 0 s in - let loc = (bp, Stream.count s) in - (tok, loc) - | [: `('!' | '=' | '@' | '^' | '&' | '+' | '-' | '*' | '/' | '%' as c); - s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id - | [: `('~' as c); - a = - parser - [ [: `('a'..'z' as c); len = ident (store 0 c) :] ep -> - (("TILDEIDENT", get_buff len), (bp, ep)) - | [: s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id ] :] -> - a - | [: `('?' as c); - a = - parser - [ [: `('a'..'z' as c); len = ident (store 0 c) :] ep -> - (("QUESTIONIDENT", get_buff len), (bp, ep)) - | [: s :] -> - let id = get_buff (ident2 (store 0 c) s) in - keyword_or_error (bp, Stream.count s) id ] :] -> - a - | [: `'<'; s :] -> less bp s - | [: `(':' as c1); - len = - parser - [ [: `(']' | ':' | '=' | '>' as c2) :] -> store (store 0 c1) c2 - | [: :] -> store 0 c1 ] :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `('>' | '|' as c1); - len = - parser - [ [: `(']' | '}' as c2) :] -> store (store 0 c1) c2 - | [: a = ident2 (store 0 c1) :] -> a ] :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `('[' | '{' as c1); s :] -> - let len = - match Stream.npeek 2 s with - [ ['<'; '<' | ':'] -> store 0 c1 - | _ -> - match s with parser - [ [: `('|' | '<' | ':' as c2) :] -> store (store 0 c1) c2 - | [: :] -> store 0 c1 ] ] - in - let ep = Stream.count s in - let id = get_buff len in - keyword_or_error (bp, ep) id - | [: `'.'; - id = - parser - [ [: `'.' :] -> ".." - | [: :] -> if ssd && after_space then " ." else "." ] :] ep -> - keyword_or_error (bp, ep) id - | [: `';'; - id = - parser - [ [: `';' :] -> ";;" - | [: :] -> ";" ] :] ep -> - keyword_or_error (bp, ep) id - | [: `'\\'; s :] ep -> (("LIDENT", get_buff (ident3 0 s)), (bp, ep)) - | [: `c :] ep -> keyword_or_error (bp, ep) (String.make 1 c) - | [: _ = Stream.empty :] -> (("EOI", ""), (bp, succ bp)) ] - and less bp strm = - if no_quotations.val then - match strm with parser - [ [: len = ident2 (store 0 '<') :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id ] - else - match strm with parser - [ [: `'<'; len = quotation bp 0 :] ep -> - (("QUOTATION", ":" ^ get_buff len), (bp, ep)) - | [: `':'; i = parser [: len = ident 0 :] -> get_buff len; - `'<' ? "character '<' expected"; len = quotation bp 0 :] ep -> - (("QUOTATION", i ^ ":" ^ get_buff len), (bp, ep)) - | [: len = ident2 (store 0 '<') :] ep -> - let id = get_buff len in - keyword_or_error (bp, ep) id ] - and string bp len = - parser - [ [: `'"' :] -> len - | [: `'\\'; `c; s :] -> string bp (store (store len '\\') c) s - | [: `c; s :] -> string bp (store len c) s - | [: :] ep -> err (bp, ep) "string not terminated" ] - and char bp len = - parser - [ [: `'''; s :] -> if len = 0 then char bp (store len ''') s else len - | [: `'\\'; `c; s :] -> char bp (store (store len '\\') c) s - | [: `c; s :] -> char bp (store len c) s - | [: :] ep -> err (bp, ep) "char not terminated" ] - and dollar bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('a'..'z' | 'A'..'Z' as c); s :] -> antiquot bp (store len c) s - | [: `('0'..'9' as c); s :] -> maybe_locate bp (store len c) s - | [: `':'; s :] -> - let k = get_buff len in - ("ANTIQUOT", k ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: s :] -> - if dfa then - match s with parser - [ [: `c :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - else ("", get_buff (ident2 (store 0 '$') s)) ] - and maybe_locate bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('0'..'9' as c); s :] -> maybe_locate bp (store len c) s - | [: `':'; s :] -> - ("LOCATE", get_buff len ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and antiquot bp len = - parser - [ [: `'$' :] -> ("ANTIQUOT", ":" ^ get_buff len) - | [: `('a'..'z' | 'A'..'Z' | '0'..'9' as c); s :] -> - antiquot bp (store len c) s - | [: `':'; s :] -> - let k = get_buff len in - ("ANTIQUOT", k ^ ":" ^ locate_or_antiquot_rest bp 0 s) - | [: `'\\'; `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: `c; s :] -> - ("ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s) - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and locate_or_antiquot_rest bp len = - parser - [ [: `'$' :] -> get_buff len - | [: `'\\'; `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: `c; s :] -> locate_or_antiquot_rest bp (store len c) s - | [: :] ep -> err (bp, ep) "antiquotation not terminated" ] - and quotation bp len = - parser - [ [: `'>'; s :] -> maybe_end_quotation bp len s - | [: `'<'; s :] -> - quotation bp (maybe_nested_quotation bp (store len '<') s) s - | [: `'\\'; - len = - parser - [ [: `('>' | '<' | '\\' as c) :] -> store len c - | [: :] -> store len '\\' ]; - s :] -> - quotation bp len s - | [: `c; s :] -> quotation bp (store len c) s - | [: :] ep -> err (bp, ep) "quotation not terminated" ] - and maybe_nested_quotation bp len = - parser - [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" - | [: `':'; len = ident (store len ':'); - a = - parser - [ [: `'<'; s :] -> mstore (quotation bp (store len '<') s) ">>" - | [: :] -> len ] :] -> - a - | [: :] -> len ] - and maybe_end_quotation bp len = - parser - [ [: `'>' :] -> len - | [: a = quotation bp (store len '>') :] -> a ] - and left_paren bp = - parser - [ [: `'*'; _ = comment bp; a = next_token True :] -> a - | [: :] ep -> keyword_or_error (bp, ep) "(" ] - and comment bp = - parser - [ [: `'('; s :] -> left_paren_in_comment bp s - | [: `'*'; s :] -> star_in_comment bp s - | [: `'"'; _ = string bp 0; s :] -> comment bp s - | [: `'''; s :] -> quote_in_comment bp s - | [: `c; s :] -> comment bp s - | [: :] ep -> err (bp, ep) "comment not terminated" ] - and quote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: `'\013'; s :] -> quote_cr_in_comment bp s - | [: `'\\'; s :] -> quote_antislash_in_comment bp s - | [: `'('; s :] -> quote_left_paren_in_comment bp s - | [: `'*'; s :] -> quote_star_in_comment bp s - | [: `'"'; s :] -> quote_doublequote_in_comment bp s - | [: `_; s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and quote_any_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> comment bp s ] - and quote_cr_in_comment bp = - parser - [ [: `'\010'; s :] -> quote_any_in_comment bp s - | [: s :] -> quote_any_in_comment bp s ] - and quote_left_paren_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> left_paren_in_comment bp s ] - and quote_star_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> star_in_comment bp s ] - and quote_doublequote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: _ = string bp 0; s :] -> comment bp s ] - and quote_antislash_in_comment bp = - parser - [ [: `'''; s :] -> quote_antislash_quote_in_comment bp s - | [: `('\\' | '"' | 'n' | 't' | 'b' | 'r'); s :] -> - quote_any_in_comment bp s - | [: `('0'..'9'); s :] -> quote_antislash_digit_in_comment bp s - | [: `'x'; s :] -> quote_antislash_x_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_quote_in_comment bp = - parser - [ [: `'''; s :] -> comment bp s - | [: s :] -> quote_in_comment bp s ] - and quote_antislash_digit_in_comment bp = - parser - [ [: `('0'..'9'); s :] -> quote_antislash_digit2_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_digit2_in_comment bp = - parser - [ [: `('0'..'9'); s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_x_in_comment bp = - parser - [ [: _ = hexa; s :] -> quote_antislash_x_digit_in_comment bp s - | [: s :] -> comment bp s ] - and quote_antislash_x_digit_in_comment bp = - parser - [ [: _ = hexa; s :] -> quote_any_in_comment bp s - | [: s :] -> comment bp s ] - and left_paren_in_comment bp = - parser - [ [: `'*'; s :] -> do { comment bp s; comment bp s } - | [: a = comment bp :] -> a ] - and star_in_comment bp = - parser - [ [: `')' :] -> () - | [: a = comment bp :] -> a ] - and linedir n s = - match stream_peek_nth n s with - [ Some (' ' | '\t') -> linedir (n + 1) s - | Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> False ] - and linedir_digits n s = - match stream_peek_nth n s with - [ Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> linedir_quote n s ] - and linedir_quote n s = - match stream_peek_nth n s with - [ Some (' ' | '\t') -> linedir_quote (n + 1) s - | Some '"' -> True - | _ -> False ] - and any_to_nl = - parser - [ [: `'\013' | '\010' :] ep -> bolpos.val := ep - | [: `_; s :] -> any_to_nl s - | [: :] -> () ] +(* Debugging positions and locations *) +let eprint_pos msg p = + Printf.eprintf "%s: fname=%s; lnum=%d; bol=%d; cnum=%d\n%!" msg + p.Lexing.pos_fname p.Lexing.pos_lnum p.Lexing.pos_bol p.Lexing.pos_cnum +;; + +let eprint_loc (bp, ep) = eprint_pos "P1" bp; eprint_pos "P2" ep;; + +let check_location msg (bp, ep as loc) = + let ok = + if bp.Lexing.pos_lnum > ep.Lexing.pos_lnum || + bp.Lexing.pos_bol > ep.Lexing.pos_bol || + bp.Lexing.pos_cnum > ep.Lexing.pos_cnum || bp.Lexing.pos_lnum < 0 || + ep.Lexing.pos_lnum < 0 || bp.Lexing.pos_bol < 0 || + ep.Lexing.pos_bol < 0 || bp.Lexing.pos_cnum < 0 || + ep.Lexing.pos_cnum < 0 + then + begin + Printf.eprintf "*** Warning: (%s) strange positions ***\n" msg; + eprint_loc loc; + false + end + else true in - fun cstrm -> - try - let glex = glexr.val in - let comm_bp = Stream.count cstrm in - let r = next_token False cstrm in - do { - match glex.tok_comm with - [ Some list -> - if fst (snd r) > comm_bp then - let comm_loc = (comm_bp, fst (snd r)) in - glex.tok_comm := Some [comm_loc :: list] - else () - | None -> () ]; - r - } - with - [ Stream.Error str -> - err (Stream.count cstrm, Stream.count cstrm + 1) str ] -; -*) + ok, loc +;; -let next_token_fun dfa ssd find_kwd bolpos glexr = - let keyword_or_error loc s = +let next_token_fun dfa ssd find_kwd fname lnum bolpos glexr = + let make_pos p = + {Lexing.pos_fname = !fname; Lexing.pos_lnum = !lnum; + Lexing.pos_bol = !bolpos; Lexing.pos_cnum = p} + in + let mkloc (bp, ep) = make_pos bp, make_pos ep in + let keyword_or_error (bp, ep) s = + let loc = mkloc (bp, ep) in try ("", find_kwd s), loc with Not_found -> if !error_on_unknown_keywords then err loc ("illegal token: " ^ s) else ("", s), loc in - let error_if_keyword ((_, id), loc as a) = + let error_if_keyword ((_, id as a), bep) = + let loc = mkloc bep in try ignore (find_kwd id); err loc ("illegal use of a keyword as a label: " ^ id) with - Not_found -> a + Not_found -> a, loc in let rec next_token after_space (strm__ : _ Stream.t) = let bp = Stream.count strm__ in match Stream.peek strm__ with - Some ('\010' | '\013') -> + Some '\010' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in + bolpos := ep; incr lnum; next_token true s + | Some '\013' -> Stream.junk strm__; let s = strm__ in - let ep = Stream.count strm__ in bolpos := ep; next_token true s + let ep = Stream.count strm__ in + let ep = + match Stream.peek s with + Some '\010' -> Stream.junk s; ep + 1 + | _ -> ep + in + bolpos := ep; incr lnum; next_token true s | Some (' ' | '\t' | '\026' | '\012') -> Stream.junk strm__; next_token true strm__ | Some '#' when bp = !bolpos -> Stream.junk strm__; let s = strm__ in - if linedir 1 s then begin any_to_nl s; next_token true s end + if linedir 1 s then begin line_directive s; next_token true s end else keyword_or_error (bp, bp + 1) "#" | Some '(' -> Stream.junk strm__; left_paren bp strm__ | Some ('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c) -> Stream.junk strm__; let s = strm__ in let id = get_buff (ident (store 0 c) s) in - let loc = bp, Stream.count s in + let loc = mkloc (bp, Stream.count s) in (try "", find_kwd id with Not_found -> "UIDENT", id), loc @@ -517,35 +234,35 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = Stream.junk strm__; let s = strm__ in let id = get_buff (ident (store 0 c) s) in - let loc = bp, Stream.count s in + let loc = mkloc (bp, Stream.count s) in (try "", find_kwd id with Not_found -> "LIDENT", id), loc | Some ('1'..'9' as c) -> Stream.junk strm__; let tok = number (store 0 c) strm__ in - let loc = bp, Stream.count strm__ in tok, loc + let loc = mkloc (bp, Stream.count strm__) in tok, loc | Some '0' -> Stream.junk strm__; let tok = base_number (store 0 '0') strm__ in - let loc = bp, Stream.count strm__ in tok, loc + let loc = mkloc (bp, Stream.count strm__) in tok, loc | Some '\'' -> Stream.junk strm__; let s = strm__ in begin match Stream.npeek 2 s with [_; '\''] | ['\\'; _] -> let tok = "CHAR", get_buff (char bp 0 s) in - let loc = bp, Stream.count s in tok, loc + let loc = mkloc (bp, Stream.count s) in tok, loc | _ -> keyword_or_error (bp, Stream.count s) "'" end | Some '\"' -> Stream.junk strm__; let tok = "STRING", get_buff (string bp 0 strm__) in - let loc = bp, Stream.count strm__ in tok, loc + let loc = mkloc (bp, Stream.count strm__) in tok, loc | Some '$' -> Stream.junk strm__; let tok = dollar bp 0 strm__ in - let loc = bp, Stream.count strm__ in tok, loc + let loc = mkloc (bp, Stream.count strm__) in tok, loc | Some ('!' | '=' | '@' | '^' | '&' | '+' | '-' | '*' | '/' | '%' as c) -> Stream.junk strm__; let id = get_buff (ident2 (store 0 c) strm__) in @@ -671,12 +388,12 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = | Some '\\' -> Stream.junk strm__; let ep = Stream.count strm__ in - ("LIDENT", get_buff (ident3 0 strm__)), (bp, ep) + ("LIDENT", get_buff (ident3 0 strm__)), mkloc (bp, ep) | Some c -> Stream.junk strm__; let ep = Stream.count strm__ in keyword_or_error (bp, ep) (String.make 1 c) - | _ -> let _ = Stream.empty strm__ in ("EOI", ""), (bp, succ bp) + | _ -> let _ = Stream.empty strm__ in ("EOI", ""), mkloc (bp, succ bp) and less bp strm = if !no_quotations then let (strm__ : _ Stream.t) = strm in @@ -693,7 +410,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = Stream.Failure -> raise (Stream.Error "") in let ep = Stream.count strm__ in - ("QUOTATION", ":" ^ get_buff len), (bp, ep) + ("QUOTATION", ":" ^ get_buff len), mkloc (bp, ep) | Some ':' -> Stream.junk strm__; let i = @@ -708,7 +425,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = Stream.Failure -> raise (Stream.Error "") in let ep = Stream.count strm__ in - ("QUOTATION", i ^ ":" ^ get_buff len), (bp, ep) + ("QUOTATION", i ^ ":" ^ get_buff len), mkloc (bp, ep) | _ -> raise (Stream.Error "character '<' expected") end | _ -> @@ -727,9 +444,26 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = string bp (store (store len '\\') c) strm__ | _ -> raise (Stream.Error "") end + | Some '\010' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in + bolpos := ep; incr lnum; string bp len s + | Some '\013' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in + let (len, ep) = + match Stream.peek s with + Some '\010' -> + Stream.junk s; store (store len '\013') '\010', ep + 1 + | _ -> store len '\013', ep + in + bolpos := ep; incr lnum; string bp len s | Some c -> Stream.junk strm__; string bp (store len c) strm__ | _ -> - let ep = Stream.count strm__ in err (bp, ep) "string not terminated" + let ep = Stream.count strm__ in + err (mkloc (bp, ep)) "string not terminated" and char bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '\'' -> @@ -742,8 +476,23 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = Stream.junk strm__; char bp (store (store len '\\') c) strm__ | _ -> raise (Stream.Error "") end + | Some '\010' -> + Stream.junk strm__; + let s = strm__ in + bolpos := bp + 1; incr lnum; char bp (store len '\010') s + | Some '\013' -> + Stream.junk strm__; + let s = strm__ in + let bol = + match Stream.peek s with + Some '\010' -> Stream.junk s; bp + 2 + | _ -> bp + 1 + in + bolpos := bol; incr lnum; char bp (store len '\013') s | Some c -> Stream.junk strm__; char bp (store len c) strm__ - | _ -> let ep = Stream.count strm__ in err (bp, ep) "char not terminated" + | _ -> + let ep = Stream.count strm__ in + err (mkloc (bp, ep)) "char not terminated" and dollar bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '$' -> Stream.junk strm__; "ANTIQUOT", ":" ^ get_buff len @@ -773,7 +522,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = "ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) s | _ -> let ep = Stream.count strm__ in - err (bp, ep) "antiquotation not terminated" + err (mkloc (bp, ep)) "antiquotation not terminated" else "", get_buff (ident2 (store 0 '$') s) and maybe_locate bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with @@ -796,7 +545,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = "ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) strm__ | _ -> let ep = Stream.count strm__ in - err (bp, ep) "antiquotation not terminated" + err (mkloc (bp, ep)) "antiquotation not terminated" and antiquot bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '$' -> Stream.junk strm__; "ANTIQUOT", ":" ^ get_buff len @@ -819,7 +568,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = "ANTIQUOT", ":" ^ locate_or_antiquot_rest bp (store len c) strm__ | _ -> let ep = Stream.count strm__ in - err (bp, ep) "antiquotation not terminated" + err (mkloc (bp, ep)) "antiquotation not terminated" and locate_or_antiquot_rest bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '$' -> Stream.junk strm__; get_buff len @@ -835,7 +584,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = Stream.junk strm__; locate_or_antiquot_rest bp (store len c) strm__ | _ -> let ep = Stream.count strm__ in - err (bp, ep) "antiquotation not terminated" + err (mkloc (bp, ep)) "antiquotation not terminated" and quotation bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '>' -> Stream.junk strm__; maybe_end_quotation bp len strm__ @@ -856,7 +605,7 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = | Some c -> Stream.junk strm__; quotation bp (store len c) strm__ | _ -> let ep = Stream.count strm__ in - err (bp, ep) "quotation not terminated" + err (mkloc (bp, ep)) "quotation not terminated" and maybe_nested_quotation bp len (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '<' -> @@ -905,9 +654,24 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = in comment bp strm__ | Some '\'' -> Stream.junk strm__; quote_in_comment bp strm__ + | Some '\010' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in bolpos := ep; incr lnum; comment bp s + | Some '\013' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in + let ep = + match Stream.peek s with + Some '\010' -> Stream.junk s; ep + 1 + | _ -> ep + in + bolpos := ep; incr lnum; comment bp s | Some c -> Stream.junk strm__; comment bp strm__ | _ -> - let ep = Stream.count strm__ in err (bp, ep) "comment not terminated" + let ep = Stream.count strm__ in + err (mkloc (bp, ep)) "comment not terminated" and quote_in_comment bp (strm__ : _ Stream.t) = match Stream.peek strm__ with Some '\'' -> Stream.junk strm__; comment bp strm__ @@ -915,7 +679,19 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = | _ -> let s = strm__ in begin match Stream.npeek 2 s with - [_; '\''] -> Stream.junk s; Stream.junk s + ['\013' | '\010'; '\''] -> + bolpos := bp + 1; incr lnum; Stream.junk s; Stream.junk s + | ['\013'; '\010'] -> + begin match Stream.npeek 3 s with + [_; _; '\''] -> + bolpos := bp + 2; + incr lnum; + Stream.junk s; + Stream.junk s; + Stream.junk s + | _ -> () + end + | [_; '\''] -> Stream.junk s; Stream.junk s | _ -> () end; comment bp s @@ -952,23 +728,73 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = and linedir n s = match stream_peek_nth n s with Some (' ' | '\t') -> linedir (n + 1) s - | Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> false - and linedir_digits n s = - match stream_peek_nth n s with - Some ('0'..'9') -> linedir_digits (n + 1) s - | _ -> linedir_quote n s - and linedir_quote n s = - match stream_peek_nth n s with - Some (' ' | '\t') -> linedir_quote (n + 1) s - | Some '\"' -> true + | Some ('0'..'9') -> true | _ -> false and any_to_nl (strm__ : _ Stream.t) = match Stream.peek strm__ with - Some ('\013' | '\010') -> - Stream.junk strm__; let ep = Stream.count strm__ in bolpos := ep + Some '\010' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in bolpos := ep; incr lnum + | Some '\013' -> + Stream.junk strm__; + let s = strm__ in + let ep = Stream.count strm__ in + let ep = + match Stream.peek s with + Some '\010' -> Stream.junk s; ep + 1 + | _ -> ep + in + bolpos := ep; incr lnum | Some _ -> Stream.junk strm__; any_to_nl strm__ | _ -> () + and line_directive (strm__ : _ Stream.t) = + let _ = skip_spaces strm__ in + let n = + try line_directive_number 0 strm__ with + Stream.Failure -> raise (Stream.Error "") + in + let _ = + try skip_spaces strm__ with + Stream.Failure -> raise (Stream.Error "") + in + let _ = + try line_directive_string strm__ with + Stream.Failure -> raise (Stream.Error "") + in + let _ = + try any_to_nl strm__ with + Stream.Failure -> raise (Stream.Error "") + in + let ep = Stream.count strm__ in bolpos := ep; lnum := n + and skip_spaces (strm__ : _ Stream.t) = + match Stream.peek strm__ with + Some (' ' | '\t') -> Stream.junk strm__; skip_spaces strm__ + | _ -> () + and line_directive_number n (strm__ : _ Stream.t) = + match Stream.peek strm__ with + Some ('0'..'9' as c) -> + Stream.junk strm__; + line_directive_number (10 * n + (Char.code c - Char.code '0')) strm__ + | _ -> n + and line_directive_string (strm__ : _ Stream.t) = + match Stream.peek strm__ with + Some '\"' -> + Stream.junk strm__; + let _ = + try line_directive_string_contents 0 strm__ with + Stream.Failure -> raise (Stream.Error "") + in + () + | _ -> () + and line_directive_string_contents len (strm__ : _ Stream.t) = + match Stream.peek strm__ with + Some ('\010' | '\013') -> Stream.junk strm__; () + | Some '\"' -> Stream.junk strm__; fname := get_buff len + | Some c -> + Stream.junk strm__; + line_directive_string_contents (store len c) strm__ + | _ -> raise Stream.Failure in fun cstrm -> try @@ -977,14 +803,16 @@ let next_token_fun dfa ssd find_kwd bolpos glexr = let r = next_token false cstrm in begin match glex.tok_comm with Some list -> - if fst (snd r) > comm_bp then - let comm_loc = comm_bp, fst (snd r) in + let next_bp = (fst (snd r)).Lexing.pos_cnum in + if next_bp > comm_bp then + let comm_loc = mkloc (comm_bp, next_bp) in glex.tok_comm <- Some (comm_loc :: list) | None -> () end; r with - Stream.Error str -> err (Stream.count cstrm, Stream.count cstrm + 1) str + Stream.Error str -> + err (mkloc (Stream.count cstrm, Stream.count cstrm + 1)) str ;; @@ -993,10 +821,13 @@ let specific_space_dot = ref false;; let func kwd_table glexr = let bolpos = ref 0 in + let lnum = ref 1 in + let fname = ref "" in let find = Hashtbl.find kwd_table in let dfa = !dollar_for_antiquotation in let ssd = !specific_space_dot in - Token.lexer_func_of_parser (next_token_fun dfa ssd find bolpos glexr) + Token.lexer_func_of_parser + (next_token_fun dfa ssd find fname lnum bolpos glexr) ;; let rec check_keyword_stream (strm__ : _ Stream.t) = @@ -1211,11 +1042,11 @@ let gmake () = let id_table = Hashtbl.create 301 in let glexr = ref - {tok_func = (fun _ -> raise (Match_failure ("plexer.ml", 972, 17))); - tok_using = (fun _ -> raise (Match_failure ("plexer.ml", 972, 37))); - tok_removing = (fun _ -> raise (Match_failure ("plexer.ml", 972, 60))); - tok_match = (fun _ -> raise (Match_failure ("plexer.ml", 973, 18))); - tok_text = (fun _ -> raise (Match_failure ("plexer.ml", 973, 37))); + {tok_func = (fun _ -> raise (Match_failure ("", 741, 17))); + tok_using = (fun _ -> raise (Match_failure ("", 741, 37))); + tok_removing = (fun _ -> raise (Match_failure ("", 741, 60))); + tok_match = (fun _ -> raise (Match_failure ("", 742, 18))); + tok_text = (fun _ -> raise (Match_failure ("", 742, 37))); tok_comm = None} in let glex = @@ -1245,12 +1076,11 @@ let make () = let id_table = Hashtbl.create 301 in let glexr = ref - {tok_func = (fun _ -> raise (Match_failure ("plexer.ml", 1001, 17))); - tok_using = (fun _ -> raise (Match_failure ("plexer.ml", 1001, 37))); - tok_removing = - (fun _ -> raise (Match_failure ("plexer.ml", 1001, 60))); - tok_match = (fun _ -> raise (Match_failure ("plexer.ml", 1002, 18))); - tok_text = (fun _ -> raise (Match_failure ("plexer.ml", 1002, 37))); + {tok_func = (fun _ -> raise (Match_failure ("", 770, 17))); + tok_using = (fun _ -> raise (Match_failure ("", 770, 37))); + tok_removing = (fun _ -> raise (Match_failure ("", 770, 60))); + tok_match = (fun _ -> raise (Match_failure ("", 771, 18))); + tok_text = (fun _ -> raise (Match_failure ("", 771, 37))); tok_comm = None} in {func = func kwd_table glexr; using = using_token kwd_table id_table; diff --git a/camlp4/ocaml_src/lib/stdpp.ml b/camlp4/ocaml_src/lib/stdpp.ml index d91ee78c07..ab80b24a99 100644 --- a/camlp4/ocaml_src/lib/stdpp.ml +++ b/camlp4/ocaml_src/lib/stdpp.ml @@ -12,7 +12,7 @@ (* This file has been generated by program: do not edit! *) -exception Exc_located of (int * int) * exn;; +exception Exc_located of Token.flocation * exn;; let raise_with_loc loc exc = match exc with @@ -21,79 +21,67 @@ let raise_with_loc loc exc = ;; let line_of_loc fname (bp, ep) = + bp.Lexing.pos_fname, bp.Lexing.pos_lnum, + bp.Lexing.pos_cnum - bp.Lexing.pos_bol, + ep.Lexing.pos_cnum - bp.Lexing.pos_bol +;; + +(* +value line_of_loc fname (bp, ep) = try let ic = open_in_bin fname in let strm = Stream.of_channel ic in let rec loop fname lin = - let rec not_a_line_dir col (strm__ : _ Stream.t) = - let cnt = Stream.count strm__ in - match Stream.peek strm__ with - Some c -> - Stream.junk strm__; - let s = strm__ in + let rec not_a_line_dir col = + parser cnt + [: `c; s :] -> if cnt < bp then if c = '\n' then loop fname (lin + 1) else not_a_line_dir (col + 1) s - else let col = col - (cnt - bp) in fname, lin, col, col + ep - bp - | _ -> raise Stream.Failure + else + let col = col - (cnt - bp) in + (fname, lin, col, col + ep - bp) in - let rec a_line_dir str n col (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some '\n' -> Stream.junk strm__; loop str n - | Some _ -> Stream.junk strm__; a_line_dir str n (col + 1) strm__ - | _ -> raise Stream.Failure + let rec a_line_dir str n col = + parser + [ [: `'\n' :] -> loop str n + | [: `_; s :] -> a_line_dir str n (col + 1) s ] in - let rec spaces col (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some ' ' -> Stream.junk strm__; spaces (col + 1) strm__ - | _ -> col + let rec spaces col = + parser + [ [: `' '; s :] -> spaces (col + 1) s + | [: :] -> col ] in - let rec check_string str n col (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some '\"' -> - Stream.junk strm__; - let col = - try spaces (col + 1) strm__ with - Stream.Failure -> raise (Stream.Error "") - in - a_line_dir str n col strm__ - | Some c when c <> '\n' -> - Stream.junk strm__; - check_string (str ^ String.make 1 c) n (col + 1) strm__ - | _ -> not_a_line_dir col strm__ + let rec check_string str n col = + parser + [ [: `'"'; col = spaces (col + 1); s :] -> a_line_dir str n col s + | [: `c when c <> '\n'; s :] -> + check_string (str ^ String.make 1 c) n (col + 1) s + | [: a = not_a_line_dir col :] -> a ] in - let check_quote n col (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some '\"' -> Stream.junk strm__; check_string "" n (col + 1) strm__ - | _ -> not_a_line_dir col strm__ + let check_quote n col = + parser + [ [: `'"'; s :] -> check_string "" n (col + 1) s + | [: a = not_a_line_dir col :] -> a ] in - let rec check_num n col (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some ('0'..'9' as c) -> - Stream.junk strm__; - check_num (10 * n + Char.code c - Char.code '0') (col + 1) strm__ - | _ -> let col = spaces col strm__ in check_quote n col strm__ + let rec check_num n col = + parser + [ [: `('0'..'9' as c); s :] -> + check_num (10 * n + Char.code c - Char.code '0') (col + 1) s + | [: col = spaces col; s :] -> check_quote n col s ] in - let begin_line (strm__ : _ Stream.t) = - match Stream.peek strm__ with - Some '#' -> - Stream.junk strm__; - let col = - try spaces 1 strm__ with - Stream.Failure -> raise (Stream.Error "") - in - check_num 0 col strm__ - | _ -> not_a_line_dir 0 strm__ + let begin_line = + parser + [ [: `'#'; col = spaces 1; s :] -> check_num 0 col s + | [: a = not_a_line_dir 0 :] -> a ] in begin_line strm in - let r = - try loop fname 1 with - Stream.Failure -> fname, 1, bp, ep - in - close_in ic; r + let r = try loop fname 1 with [ Stream.Failure -> (fname, 1, bp, ep) ] in + do { close_in ic; r } with - Sys_error _ -> fname, 1, bp, ep -;; + [ Sys_error _ -> (fname, 1, bp, ep) ] +; +*) let loc_name = ref "loc";; diff --git a/camlp4/ocaml_src/lib/stdpp.mli b/camlp4/ocaml_src/lib/stdpp.mli index 68c0cb6ada..e966ee9aa2 100644 --- a/camlp4/ocaml_src/lib/stdpp.mli +++ b/camlp4/ocaml_src/lib/stdpp.mli @@ -14,18 +14,18 @@ (** Standard definitions. *) -exception Exc_located of (int * int) * exn;; +exception Exc_located of Token.flocation * exn;; (** [Exc_located loc e] is an encapsulation of the exception [e] with the input location [loc]. To be used in quotation expanders and in grammars to specify some input location for an error. Do not raise this exception directly: rather use the following function [raise_with_loc]. *) -val raise_with_loc : int * int -> exn -> 'a;; +val raise_with_loc : Token.flocation -> exn -> 'a;; (** [raise_with_loc loc e], if [e] is already the exception [Exc_located], re-raise it, else raise the exception [Exc_located loc e]. *) -val line_of_loc : string -> int * int -> string * int * int * int;; +val line_of_loc : string -> Token.flocation -> string * int * int * int;; (** [line_of_loc fname loc] reads the file [fname] up to the location [loc] and returns the real input file, the line number and the characters location in the line; the real input file diff --git a/camlp4/ocaml_src/lib/token.ml b/camlp4/ocaml_src/lib/token.ml index bc8faeac3e..9eea60aa62 100644 --- a/camlp4/ocaml_src/lib/token.ml +++ b/camlp4/ocaml_src/lib/token.ml @@ -17,9 +17,22 @@ type pattern = string * string;; exception Error of string;; -type location = int * int;; -type location_function = int -> int * int;; -type 'te lexer_func = char Stream.t -> 'te Stream.t * location_function;; +let make_loc (bp, ep) = + {(Lexing.dummy_pos) with Lexing.pos_cnum = bp; Lexing.pos_lnum = 1}, + {(Lexing.dummy_pos) with Lexing.pos_cnum = ep; Lexing.pos_lnum = 1} +;; + +let nowhere = {(Lexing.dummy_pos) with Lexing.pos_cnum = 0};; + +let dummy_loc = Lexing.dummy_pos, Lexing.dummy_pos;; + +let succ_pos p = {p with Lexing.pos_cnum = p.Lexing.pos_cnum + 1};; +let lt_pos p1 p2 = p1.Lexing.pos_cnum < p2.Lexing.pos_cnum;; + +type flocation = Lexing.position * Lexing.position;; + +type flocation_function = int -> flocation;; +type 'te lexer_func = char Stream.t -> 'te Stream.t * flocation_function;; type 'te glexer = { tok_func : 'te lexer_func; @@ -27,7 +40,7 @@ type 'te glexer = tok_removing : pattern -> unit; tok_match : pattern -> 'te -> string; tok_text : pattern -> string; - mutable tok_comm : location list option } + mutable tok_comm : flocation list option } ;; type lexer = { func : t lexer_func; @@ -43,29 +56,39 @@ let lexer_text (con, prm) = else con ^ " '" ^ prm ^ "'" ;; -let locerr () = invalid_arg "Lexer: location function";; -let loct_create () = ref (Array.create 1024 None), ref false;; +let locerr () = invalid_arg "Lexer: flocation function";; + +let tsz = 256;; (* up to 2^29 entries on a 32-bit machine, 2^61 on 64-bit *) + +let loct_create () = ref [| |], ref false;; + let loct_func (loct, ov) i = match - if i < 0 || i >= Array.length !loct then if !ov then Some (0, 0) else None - else Array.unsafe_get !loct i + if i < 0 || i / tsz >= Array.length !loct then None + else if !loct.(i / tsz) = [| |] then + if !ov then Some (nowhere, nowhere) else None + else Array.unsafe_get (Array.unsafe_get !loct (i / tsz)) (i mod tsz) with Some loc -> loc | _ -> locerr () ;; + let loct_add (loct, ov) i loc = - if i >= Array.length !loct then - let new_tmax = Array.length !loct * 2 in + while i / tsz >= Array.length !loct && not !ov do + let new_tmax = Array.length !loct * 2 + 1 in if new_tmax < Sys.max_array_length then - let new_loct = Array.create new_tmax None in - Array.blit !loct 0 new_loct 0 (Array.length !loct); - loct := new_loct; - !loct.(i) <- Some loc + let new_loct = Array.make new_tmax [| |] in + Array.blit !loct 0 new_loct 0 (Array.length !loct); loct := new_loct else ov := true - else !loct.(i) <- Some loc + done; + if not !ov then + begin + if !loct.(i / tsz) = [| |] then !loct.(i / tsz) <- Array.make tsz None; + !loct.(i / tsz).(i mod tsz) <- Some loc + end ;; -let make_stream_and_location next_token_loc = +let make_stream_and_flocation next_token_loc = let loct = loct_create () in let ts = Stream.from @@ -76,7 +99,7 @@ let make_stream_and_location next_token_loc = ;; let lexer_func_of_parser next_token_loc cs = - make_stream_and_location (fun () -> next_token_loc cs) + make_stream_and_flocation (fun () -> next_token_loc cs) ;; let lexer_func_of_ocamllex lexfun cs = @@ -88,9 +111,9 @@ let lexer_func_of_ocamllex lexfun cs = in let next_token_loc _ = let tok = lexfun lb in - let loc = Lexing.lexeme_start lb, Lexing.lexeme_end lb in tok, loc + let loc = Lexing.lexeme_start_p lb, Lexing.lexeme_end_p lb in tok, loc in - make_stream_and_location next_token_loc + make_stream_and_flocation next_token_loc ;; (* Char and string tokens to real chars and string *) @@ -201,7 +224,7 @@ let eval_string (bp, ep) s = try let (c, i) = backslash s i in store len c, i with Not_found -> Printf.eprintf "Warning: char %d, Invalid backslash escape in string\n%!" - (bp + i + 1); + (bp.Lexing.pos_cnum + i + 1); store (store len '\\') c, i + 1 else store len s.[i], i + 1 in diff --git a/camlp4/ocaml_src/lib/token.mli b/camlp4/ocaml_src/lib/token.mli index 9ddb41069b..715170bd8a 100644 --- a/camlp4/ocaml_src/lib/token.mli +++ b/camlp4/ocaml_src/lib/token.mli @@ -33,11 +33,19 @@ exception Error of string;; (** {6 Lexer type} *) -type location = int * int;; -type location_function = int -> location;; +type flocation = Lexing.position * Lexing.position;; + +val nowhere : Lexing.position;; +val dummy_loc : flocation;; + +val make_loc : int * int -> flocation;; +val succ_pos : Lexing.position -> Lexing.position;; +val lt_pos : Lexing.position -> Lexing.position -> bool;; + +type flocation_function = int -> flocation;; (** The type for a function associating a number of a token in a stream (starting from 0) to its source location. *) -type 'te lexer_func = char Stream.t -> 'te Stream.t * location_function;; +type 'te lexer_func = char Stream.t -> 'te Stream.t * flocation_function;; (** The type for a lexer function. The character stream is the input stream to be lexed. The result is a pair of a token stream and a location function for this tokens stream. *) @@ -48,7 +56,7 @@ type 'te glexer = tok_removing : pattern -> unit; tok_match : pattern -> 'te -> string; tok_text : pattern -> string; - mutable tok_comm : location list option } + mutable tok_comm : flocation list option } ;; (** The type for a lexer used by Camlp4 grammars. - The field [tok_func] is the main lexer function. See [lexer_func] @@ -96,14 +104,14 @@ val default_match : pattern -> string * string -> string;; as well. *) val lexer_func_of_parser : - (char Stream.t -> 'te * location) -> 'te lexer_func;; + (char Stream.t -> 'te * flocation) -> 'te lexer_func;; (** A lexer function from a lexer written as a char stream parser returning the next token and its location. *) val lexer_func_of_ocamllex : (Lexing.lexbuf -> 'te) -> 'te lexer_func;; (** A lexer function from a lexer created by [ocamllex] *) -val make_stream_and_location : - (unit -> 'te * location) -> 'te Stream.t * location_function;; +val make_stream_and_flocation : + (unit -> 'te * flocation) -> 'te Stream.t * flocation_function;; (** General function *) (** {6 Useful functions} *) @@ -114,7 +122,7 @@ val eval_char : string -> char;; incorrect backslash sequence is found; [Token.eval_char (Char.escaped c)] returns [c] *) -val eval_string : location -> string -> string;; +val eval_string : flocation -> string -> string;; (** Convert a string token, where the escape sequences (backslashes) remain to be interpreted; issue a warning if an incorrect backslash sequence is found; diff --git a/camlp4/ocaml_src/meta/.depend b/camlp4/ocaml_src/meta/.depend index 737ea5ec6b..7c8bcbfbea 100644 --- a/camlp4/ocaml_src/meta/.depend +++ b/camlp4/ocaml_src/meta/.depend @@ -1,5 +1,5 @@ -pa_extend.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi -pa_extend.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx +pa_extend.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/reloc.cmi +pa_extend.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/reloc.cmx pa_extend_m.cmo: pa_extend.cmo pa_extend_m.cmx: pa_extend.cmx pa_ifdef.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi @@ -12,5 +12,7 @@ pa_rp.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi pa_rp.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx pr_dump.cmo: ../camlp4/ast2pt.cmi $(OTOP)/utils/config.cmi ../camlp4/pcaml.cmi pr_dump.cmx: ../camlp4/ast2pt.cmx $(OTOP)/utils/config.cmx ../camlp4/pcaml.cmx -q_MLast.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/quotation.cmi -q_MLast.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/quotation.cmx +q_MLast.cmo: ../camlp4/mLast.cmi ../camlp4/pcaml.cmi ../camlp4/quotation.cmi \ + ../camlp4/reloc.cmi +q_MLast.cmx: ../camlp4/mLast.cmi ../camlp4/pcaml.cmx ../camlp4/quotation.cmx \ + ../camlp4/reloc.cmx diff --git a/camlp4/ocaml_src/meta/Makefile b/camlp4/ocaml_src/meta/Makefile index 3b01659358..d0b3cd519c 100644 --- a/camlp4/ocaml_src/meta/Makefile +++ b/camlp4/ocaml_src/meta/Makefile @@ -49,11 +49,7 @@ install: cp camlp4r$(EXE) "$(BINDIR)/." if test -f camlp4r.opt; then \ cp camlp4r.opt "$(BINDIR)/camlp4r.opt$(EXE)" ;\ - for target in $(OBJSX) $(OBJSX:.cmx=.$(O)) ; do \ - if test -f $$target; then \ - cp $$target "$(LIBDIR)/camlp4/."; \ - fi; \ - done; \ + cp $(OBJSX) $(OBJSX:.cmx=.$(O)) "$(LIBDIR)/camlp4/."; \ fi include .depend diff --git a/camlp4/ocaml_src/meta/pa_extend.ml b/camlp4/ocaml_src/meta/pa_extend.ml index d68baf8d59..2258b96250 100644 --- a/camlp4/ocaml_src/meta/pa_extend.ml +++ b/camlp4/ocaml_src/meta/pa_extend.ml @@ -22,9 +22,9 @@ Pcaml.add_option "-split_ext" (Arg.Set split_ext) Pcaml.add_option "-split_gext" (Arg.Set split_ext) "Old name for the option -split_ext.";; -type loc = int * int;; +type loc = Lexing.position * Lexing.position;; -type 'e name = { expr : 'e; tvar : string; loc : int * int };; +type 'e name = { expr : 'e; tvar : string; loc : loc };; type styp = STlid of loc * string @@ -161,7 +161,12 @@ module MetaAction = in failwith (f ^ ", not impl: " ^ desc) ;; - let loc = 0, 0;; + let loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0} + in + nowhere, nowhere + ;; let rec mlist mf = function [] -> MLast.ExUid (loc, "[]") @@ -181,7 +186,26 @@ module MetaAction = | true -> MLast.ExUid (loc, "True") ;; let mloc = - MLast.ExTup (loc, [MLast.ExInt (loc, "0"); MLast.ExInt (loc, "0")]) + MLast.ExLet + (loc, false, + [MLast.PaLid (loc, "nowhere"), + MLast.ExRec + (loc, + [MLast.PaAcc + (loc, MLast.PaUid (loc, "Lexing"), + MLast.PaLid (loc, "pos_lnum")), + MLast.ExInt (loc, "1"); + MLast.PaAcc + (loc, MLast.PaUid (loc, "Lexing"), + MLast.PaLid (loc, "pos_cnum")), + MLast.ExInt (loc, "0")], + Some + (MLast.ExAcc + (loc, MLast.ExUid (loc, "Lexing"), + MLast.ExLid (loc, "dummy_pos"))))], + MLast.ExTup + (loc, + [MLast.ExLid (loc, "nowhere"); MLast.ExLid (loc, "nowhere")])) ;; let rec mexpr = function @@ -809,7 +833,13 @@ let quotify_action psl act = (fun e ps -> match ps.pattern with Some (MLast.PaTup (_, pl)) -> - let loc = 0, 0 in + let loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; + Lexing.pos_cnum = 0} + in + nowhere, nowhere + in let pname = pname_of_ptuple pl in let (pl1, el1) = let (l, _) = @@ -1040,7 +1070,13 @@ let text_of_action loc psl rtvar act tvar = [MLast.PaTyc (loc, locid, MLast.TyTup - (loc, [MLast.TyLid (loc, "int"); MLast.TyLid (loc, "int")])), + (loc, + [MLast.TyAcc + (loc, MLast.TyUid (loc, "Lexing"), + MLast.TyLid (loc, "position")); + MLast.TyAcc + (loc, MLast.TyUid (loc, "Lexing"), + MLast.TyLid (loc, "position"))])), None, MLast.ExTyc (loc, act, MLast.TyQuo (loc, rtvar))]) in let txt = @@ -1459,6 +1495,8 @@ let text_of_functorial_extend loc gmod gl el = let_in_of_extend loc gmod true gl el args ;; +let zero_loc = {(Lexing.dummy_pos) with Lexing.pos_cnum = 0};; + open Pcaml;; let symbol = Grammar.Entry.create gram "symbol";; let semi_sep = @@ -1518,26 +1556,34 @@ Grammar.extend (gdelete_rule_body : 'gdelete_rule_body Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (e : 'gdelete_rule_body) _ (loc : int * int) -> (e : 'expr)); + (fun _ (e : 'gdelete_rule_body) _ + (loc : Lexing.position * Lexing.position) -> + (e : 'expr)); [Gramext.Stoken ("", "DELETE_RULE"); Gramext.Snterm (Grammar.Entry.obj (delete_rule_body : 'delete_rule_body Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (e : 'delete_rule_body) _ (loc : int * int) -> (e : 'expr)); + (fun _ (e : 'delete_rule_body) _ + (loc : Lexing.position * Lexing.position) -> + (e : 'expr)); [Gramext.Stoken ("", "GEXTEND"); Gramext.Snterm (Grammar.Entry.obj (gextend_body : 'gextend_body Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (e : 'gextend_body) _ (loc : int * int) -> (e : 'expr)); + (fun _ (e : 'gextend_body) _ + (loc : Lexing.position * Lexing.position) -> + (e : 'expr)); [Gramext.Stoken ("", "EXTEND"); Gramext.Snterm (Grammar.Entry.obj (extend_body : 'extend_body Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (e : 'extend_body) _ (loc : int * int) -> (e : 'expr))]]; + (fun _ (e : 'extend_body) _ + (loc : Lexing.position * Lexing.position) -> + (e : 'expr))]]; Grammar.Entry.obj (extend_body : 'extend_body Grammar.Entry.e), None, [None, None, [[Gramext.Snterm @@ -1552,10 +1598,12 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e))], Gramext.action - (fun _ (e : 'entry) (loc : int * int) -> (e : 'e__1))])], + (fun _ (e : 'entry) + (loc : Lexing.position * Lexing.position) -> + (e : 'e__1))])], Gramext.action (fun (el : 'e__1 list) (sl : 'global option) (f : 'efunction) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (text_of_extend loc "Grammar" sl el f : 'extend_body))]]; Grammar.Entry.obj (gextend_body : 'gextend_body Grammar.Entry.e), None, [None, None, @@ -1570,10 +1618,12 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e))], Gramext.action - (fun _ (e : 'entry) (loc : int * int) -> (e : 'e__2))])], + (fun _ (e : 'entry) + (loc : Lexing.position * Lexing.position) -> + (e : 'e__2))])], Gramext.action (fun (el : 'e__2 list) (sl : 'global option) (g : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (text_of_functorial_extend loc g sl el : 'gextend_body))]]; Grammar.Entry.obj (delete_rule_body : 'delete_rule_body Grammar.Entry.e), None, @@ -1586,7 +1636,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e)))], Gramext.action - (fun (sl : 'symbol list) _ (n : 'name) (loc : int * int) -> + (fun (sl : 'symbol list) _ (n : 'name) + (loc : Lexing.position * Lexing.position) -> (let (e, b) = expr_of_delete_rule loc "Grammar" n sl in MLast.ExApp (loc, @@ -1612,7 +1663,7 @@ Grammar.extend (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e)))], Gramext.action (fun (sl : 'symbol list) _ (n : 'name) (g : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (let (e, b) = expr_of_delete_rule loc g n sl in MLast.ExApp (loc, @@ -1628,7 +1679,7 @@ Grammar.extend [None, None, [[], Gramext.action - (fun (loc : int * int) -> + (fun (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Grammar"), MLast.ExLid (loc, "extend")) : @@ -1638,7 +1689,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e))], Gramext.action - (fun _ (f : 'qualid) _ _ (loc : int * int) -> (f : 'efunction))]]; + (fun _ (f : 'qualid) _ _ (loc : Lexing.position * Lexing.position) -> + (f : 'efunction))]]; Grammar.Entry.obj (global : 'global Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "GLOBAL"); Gramext.Stoken ("", ":"); @@ -1647,7 +1699,9 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e))], Gramext.action - (fun _ (sl : 'name list) _ _ (loc : int * int) -> (sl : 'global))]]; + (fun _ (sl : 'name list) _ _ + (loc : Lexing.position * Lexing.position) -> + (sl : 'global))]]; Grammar.Entry.obj (entry : 'entry Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (name : 'name Grammar.Entry.e)); @@ -1659,14 +1713,14 @@ Grammar.extend (Grammar.Entry.obj (level_list : 'level_list Grammar.Entry.e))], Gramext.action (fun (ll : 'level_list) (pos : 'position option) _ (n : 'name) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> ({name = n; pos = pos; levels = ll} : 'entry))]]; Grammar.Entry.obj (position : 'position Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "LEVEL"); Gramext.Snterm (Grammar.Entry.obj (string : 'string Grammar.Entry.e))], Gramext.action - (fun (n : 'string) _ (loc : int * int) -> + (fun (n : 'string) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExAcc @@ -1677,7 +1731,7 @@ Grammar.extend [Gramext.Stoken ("UIDENT", "AFTER"); Gramext.Snterm (Grammar.Entry.obj (string : 'string Grammar.Entry.e))], Gramext.action - (fun (n : 'string) _ (loc : int * int) -> + (fun (n : 'string) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExAcc @@ -1688,7 +1742,7 @@ Grammar.extend [Gramext.Stoken ("UIDENT", "BEFORE"); Gramext.Snterm (Grammar.Entry.obj (string : 'string Grammar.Entry.e))], Gramext.action - (fun (n : 'string) _ (loc : int * int) -> + (fun (n : 'string) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExAcc @@ -1698,13 +1752,13 @@ Grammar.extend 'position)); [Gramext.Stoken ("UIDENT", "LAST")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Gramext"), MLast.ExUid (loc, "Last")) : 'position)); [Gramext.Stoken ("UIDENT", "FIRST")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Gramext"), MLast.ExUid (loc, "First")) : @@ -1717,7 +1771,8 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (ll : 'level list) _ (loc : int * int) -> + (fun _ (ll : 'level list) _ + (loc : Lexing.position * Lexing.position) -> (ll : 'level_list))]]; Grammar.Entry.obj (level : 'level Grammar.Entry.e), None, [None, None, @@ -1729,26 +1784,26 @@ Grammar.extend (Grammar.Entry.obj (rule_list : 'rule_list Grammar.Entry.e))], Gramext.action (fun (rules : 'rule_list) (ass : 'assoc option) (lab : string option) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> ({label = lab; assoc = ass; rules = rules} : 'level))]]; Grammar.Entry.obj (assoc : 'assoc Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "NONA")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Gramext"), MLast.ExUid (loc, "NonA")) : 'assoc)); [Gramext.Stoken ("UIDENT", "RIGHTA")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Gramext"), MLast.ExUid (loc, "RightA")) : 'assoc)); [Gramext.Stoken ("UIDENT", "LEFTA")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, MLast.ExUid (loc, "Gramext"), MLast.ExUid (loc, "LeftA")) : @@ -1761,10 +1816,13 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rules : 'rule list) _ (loc : int * int) -> + (fun _ (rules : 'rule list) _ + (loc : Lexing.position * Lexing.position) -> (retype_rule_list_without_patterns loc rules : 'rule_list)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "]")], - Gramext.action (fun _ _ (loc : int * int) -> ([] : 'rule_list))]]; + Gramext.action + (fun _ _ (loc : Lexing.position * Lexing.position) -> + ([] : 'rule_list))]]; Grammar.Entry.obj (rule : 'rule Grammar.Entry.e), None, [None, None, [[Gramext.Slist0sep @@ -1773,7 +1831,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (semi_sep : 'semi_sep Grammar.Entry.e)))], Gramext.action - (fun (psl : 'psymbol list) (loc : int * int) -> + (fun (psl : 'psymbol list) + (loc : Lexing.position * Lexing.position) -> ({prod = psl; action = None} : 'rule)); [Gramext.Slist0sep (Gramext.Snterm @@ -1783,20 +1842,22 @@ Grammar.extend Gramext.Stoken ("", "->"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (act : 'expr) _ (psl : 'psymbol list) (loc : int * int) -> + (fun (act : 'expr) _ (psl : 'psymbol list) + (loc : Lexing.position * Lexing.position) -> ({prod = psl; action = Some act} : 'rule))]]; Grammar.Entry.obj (psymbol : 'psymbol Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (s : 'symbol) (loc : int * int) -> + (fun (s : 'symbol) (loc : Lexing.position * Lexing.position) -> ({pattern = None; symbol = s} : 'psymbol)); [Gramext.Snterm (Grammar.Entry.obj (pattern : 'pattern Grammar.Entry.e)); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (s : 'symbol) _ (p : 'pattern) (loc : int * int) -> + (fun (s : 'symbol) _ (p : 'pattern) + (loc : Lexing.position * Lexing.position) -> ({pattern = Some p; symbol = s} : 'psymbol)); [Gramext.Stoken ("LIDENT", ""); Gramext.Sopt @@ -1804,9 +1865,12 @@ Grammar.extend [[Gramext.Stoken ("UIDENT", "LEVEL"); Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> (s : 'e__3))])], + (fun (s : string) _ + (loc : Lexing.position * Lexing.position) -> + (s : 'e__3))])], Gramext.action - (fun (lev : 'e__3 option) (i : string) (loc : int * int) -> + (fun (lev : 'e__3 option) (i : string) + (loc : Lexing.position * Lexing.position) -> (let name = mk_name loc (MLast.ExLid (loc, i)) in let text = TXnterm (loc, name, lev) in let styp = STquo (loc, i) in @@ -1816,14 +1880,15 @@ Grammar.extend [Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (s : 'symbol) _ (p : string) (loc : int * int) -> + (fun (s : 'symbol) _ (p : string) + (loc : Lexing.position * Lexing.position) -> ({pattern = Some (MLast.PaLid (loc, p)); symbol = s} : 'psymbol))]]; Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e), None, [Some "top", Some Gramext.NonA, [[Gramext.Stoken ("UIDENT", "OPT"); Gramext.Sself], Gramext.action - (fun (s : 'symbol) _ (loc : int * int) -> + (fun (s : 'symbol) _ (loc : Lexing.position * Lexing.position) -> (if !quotify then ssopt loc s else let styp = STapp (loc, STlid (loc, "option"), s.styp) in @@ -1837,9 +1902,12 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (t : 'symbol) _ (loc : int * int) -> (t : 'e__5))])], + (fun (t : 'symbol) _ + (loc : Lexing.position * Lexing.position) -> + (t : 'e__5))])], Gramext.action - (fun (sep : 'e__5 option) (s : 'symbol) _ (loc : int * int) -> + (fun (sep : 'e__5 option) (s : 'symbol) _ + (loc : Lexing.position * Lexing.position) -> (if !quotify then sslist loc true sep s else let used = @@ -1858,9 +1926,12 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (t : 'symbol) _ (loc : int * int) -> (t : 'e__4))])], + (fun (t : 'symbol) _ + (loc : Lexing.position * Lexing.position) -> + (t : 'e__4))])], Gramext.action - (fun (sep : 'e__4 option) (s : 'symbol) _ (loc : int * int) -> + (fun (sep : 'e__4 option) (s : 'symbol) _ + (loc : Lexing.position * Lexing.position) -> (if !quotify then sslist loc false sep s else let used = @@ -1875,16 +1946,20 @@ Grammar.extend None, None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (s_t : 'symbol) _ (loc : int * int) -> (s_t : 'symbol)); + (fun _ (s_t : 'symbol) _ (loc : Lexing.position * Lexing.position) -> + (s_t : 'symbol)); [Gramext.Snterm (Grammar.Entry.obj (name : 'name Grammar.Entry.e)); Gramext.Sopt (Gramext.srules [[Gramext.Stoken ("UIDENT", "LEVEL"); Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> (s : 'e__7))])], + (fun (s : string) _ + (loc : Lexing.position * Lexing.position) -> + (s : 'e__7))])], Gramext.action - (fun (lev : 'e__7 option) (n : 'name) (loc : int * int) -> + (fun (lev : 'e__7 option) (n : 'name) + (loc : Lexing.position * Lexing.position) -> ({used = [n.tvar]; text = TXnterm (loc, n, lev); styp = STquo (loc, n.tvar)} : 'symbol)); @@ -1895,10 +1970,12 @@ Grammar.extend [[Gramext.Stoken ("UIDENT", "LEVEL"); Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> (s : 'e__6))])], + (fun (s : string) _ + (loc : Lexing.position * Lexing.position) -> + (s : 'e__6))])], Gramext.action (fun (lev : 'e__6 option) (e : 'qualid) _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (let n = mk_name loc (MLast.ExAcc (loc, MLast.ExUid (loc, i), e)) in @@ -1907,20 +1984,21 @@ Grammar.extend 'symbol)); [Gramext.Snterm (Grammar.Entry.obj (string : 'string Grammar.Entry.e))], Gramext.action - (fun (e : 'string) (loc : int * int) -> + (fun (e : 'string) (loc : Lexing.position * Lexing.position) -> (let text = TXtok (loc, "", e) in {used = []; text = text; styp = STlid (loc, "string")} : 'symbol)); [Gramext.Stoken ("UIDENT", ""); Gramext.Snterm (Grammar.Entry.obj (string : 'string Grammar.Entry.e))], Gramext.action - (fun (e : 'string) (x : string) (loc : int * int) -> + (fun (e : 'string) (x : string) + (loc : Lexing.position * Lexing.position) -> (let text = TXtok (loc, x, e) in {used = []; text = text; styp = STlid (loc, "string")} : 'symbol)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) (loc : Lexing.position * Lexing.position) -> (let text = if !quotify then sstoken loc x else TXtok (loc, x, MLast.ExStr (loc, "")) @@ -1933,7 +2011,8 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rl : 'rule list) _ (loc : int * int) -> + (fun _ (rl : 'rule list) _ + (loc : Lexing.position * Lexing.position) -> (let rl = retype_rule_list_without_patterns loc rl in let t = new_type_var () in {used = used_of_rule_list rl; @@ -1942,12 +2021,12 @@ Grammar.extend 'symbol)); [Gramext.Stoken ("UIDENT", "NEXT")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> ({used = []; text = TXnext loc; styp = STself (loc, "NEXT")} : 'symbol)); [Gramext.Stoken ("UIDENT", "SELF")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> ({used = []; text = TXself loc; styp = STself (loc, "SELF")} : 'symbol))]]; Grammar.Entry.obj (pattern : 'pattern Grammar.Entry.e), None, @@ -1958,17 +2037,20 @@ Grammar.extend (patterns_comma : 'patterns_comma Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'patterns_comma) _ (p : 'pattern) _ (loc : int * int) -> + (fun _ (pl : 'patterns_comma) _ (p : 'pattern) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTup (loc, (p :: pl)) : 'pattern)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p : 'pattern) _ (loc : int * int) -> (p : 'pattern)); + (fun _ (p : 'pattern) _ (loc : Lexing.position * Lexing.position) -> + (p : 'pattern)); [Gramext.Stoken ("", "_")], Gramext.action - (fun _ (loc : int * int) -> (MLast.PaAny loc : 'pattern)); + (fun _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaAny loc : 'pattern)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLid (loc, i) : 'pattern))]]; Grammar.Entry.obj (patterns_comma : 'patterns_comma Grammar.Entry.e), None, @@ -1977,49 +2059,54 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (pattern : 'pattern Grammar.Entry.e))], Gramext.action - (fun (p : 'pattern) _ (pl : 'patterns_comma) (loc : int * int) -> + (fun (p : 'pattern) _ (pl : 'patterns_comma) + (loc : Lexing.position * Lexing.position) -> (pl @ [p] : 'patterns_comma))]; None, None, [[Gramext.Snterm (Grammar.Entry.obj (pattern : 'pattern Grammar.Entry.e))], Gramext.action - (fun (p : 'pattern) (loc : int * int) -> ([p] : 'patterns_comma))]]; + (fun (p : 'pattern) (loc : Lexing.position * Lexing.position) -> + ([p] : 'patterns_comma))]]; Grammar.Entry.obj (name : 'name Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (qualid : 'qualid Grammar.Entry.e))], Gramext.action - (fun (e : 'qualid) (loc : int * int) -> (mk_name loc e : 'name))]]; + (fun (e : 'qualid) (loc : Lexing.position * Lexing.position) -> + (mk_name loc e : 'name))]]; Grammar.Entry.obj (qualid : 'qualid Grammar.Entry.e), None, [None, None, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (e2 : 'qualid) _ (e1 : 'qualid) (loc : int * int) -> + (fun (e2 : 'qualid) _ (e1 : 'qualid) + (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, e1, e2) : 'qualid))]; None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExLid (loc, i) : 'qualid)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExUid (loc, i) : 'qualid))]]; Grammar.Entry.obj (string : 'string Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> - (let shift = fst loc + String.length "$" in + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (let shift = Reloc.shift_pos (String.length "$") (fst loc) in let e = try Grammar.Entry.parse Pcaml.expr_eoi (Stream.of_string i) with Exc_located ((bp, ep), exc) -> - raise_with_loc (shift + bp, shift + ep) exc + raise_with_loc (Reloc.adjust_loc shift (bp, ep)) exc in - Pcaml.expr_reloc (fun (bp, ep) -> shift + bp, shift + ep) 0 e : + Pcaml.expr_reloc (fun (bp, ep) -> Reloc.adjust_loc shift (bp, ep)) + zero_loc e : 'string)); [Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExStr (loc, s) : 'string))]]]);; Pcaml.add_option "-quotify" (Arg.Set quotify) "Generate code for quotations";; diff --git a/camlp4/ocaml_src/meta/pa_extend_m.ml b/camlp4/ocaml_src/meta/pa_extend_m.ml index 11fd07f58a..c6da0eb8af 100644 --- a/camlp4/ocaml_src/meta/pa_extend_m.ml +++ b/camlp4/ocaml_src/meta/pa_extend_m.ml @@ -20,12 +20,17 @@ Grammar.extend [None, Some Gramext.NonA, [[Gramext.Stoken ("UIDENT", "SOPT"); Gramext.Sself], Gramext.action - (fun (s : 'symbol) _ (loc : int * int) -> (ssopt loc s : 'symbol)); + (fun (s : 'symbol) _ (loc : Lexing.position * Lexing.position) -> + (ssopt loc s : 'symbol)); [Gramext.srules [[Gramext.Stoken ("UIDENT", "SLIST1")], - Gramext.action (fun _ (loc : int * int) -> (true : 'e__1)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (true : 'e__1)); [Gramext.Stoken ("UIDENT", "SLIST0")], - Gramext.action (fun _ (loc : int * int) -> (false : 'e__1))]; + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (false : 'e__1))]; Gramext.Sself; Gramext.Sopt (Gramext.srules @@ -33,8 +38,10 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (symbol : 'symbol Grammar.Entry.e))], Gramext.action - (fun (t : 'symbol) _ (loc : int * int) -> (t : 'e__2))])], + (fun (t : 'symbol) _ + (loc : Lexing.position * Lexing.position) -> + (t : 'e__2))])], Gramext.action (fun (sep : 'e__2 option) (s : 'symbol) (min : 'e__1) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (sslist loc min sep s : 'symbol))]]];; diff --git a/camlp4/ocaml_src/meta/pa_ifdef.ml b/camlp4/ocaml_src/meta/pa_ifdef.ml index 6384d6be1f..f55c647814 100644 --- a/camlp4/ocaml_src/meta/pa_ifdef.ml +++ b/camlp4/ocaml_src/meta/pa_ifdef.ml @@ -40,14 +40,14 @@ Grammar.extend Gramext.Stoken ("", "else"); Gramext.Sself], Gramext.action (fun (e2 : 'Pcaml__expr) _ (e1 : 'Pcaml__expr) _ (c : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e2 else e1 : 'Pcaml__expr)); [Gramext.Stoken ("", "ifdef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); Gramext.Sself; Gramext.Stoken ("", "else"); Gramext.Sself], Gramext.action (fun (e2 : 'Pcaml__expr) _ (e1 : 'Pcaml__expr) _ (c : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e1 else e2 : 'Pcaml__expr))]]; Grammar.Entry.obj (Pcaml.str_item : 'Pcaml__str_item Grammar.Entry.e), Some Gramext.First, @@ -56,7 +56,7 @@ Grammar.extend (Grammar.Entry.obj (def_undef_str : 'def_undef_str Grammar.Entry.e))], Gramext.action - (fun (x : 'def_undef_str) (loc : int * int) -> + (fun (x : 'def_undef_str) (loc : Lexing.position * Lexing.position) -> (match x with SdStr si -> si | SdDef x -> define x; MLast.StDcl (loc, []) @@ -67,17 +67,20 @@ Grammar.extend [None, None, [[Gramext.Stoken ("", "undef"); Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (c : string) _ (loc : int * int) -> (SdUnd c : 'def_undef_str)); + (fun (c : string) _ (loc : Lexing.position * Lexing.position) -> + (SdUnd c : 'def_undef_str)); [Gramext.Stoken ("", "define"); Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (c : string) _ (loc : int * int) -> (SdDef c : 'def_undef_str)); + (fun (c : string) _ (loc : Lexing.position * Lexing.position) -> + (SdDef c : 'def_undef_str)); [Gramext.Stoken ("", "ifndef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); Gramext.Snterm (Grammar.Entry.obj (str_item_def_undef : 'str_item_def_undef Grammar.Entry.e))], Gramext.action - (fun (e1 : 'str_item_def_undef) _ (c : string) _ (loc : int * int) -> + (fun (e1 : 'str_item_def_undef) _ (c : string) _ + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then SdNop else e1 : 'def_undef_str)); [Gramext.Stoken ("", "ifndef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -90,7 +93,7 @@ Grammar.extend (str_item_def_undef : 'str_item_def_undef Grammar.Entry.e))], Gramext.action (fun (e2 : 'str_item_def_undef) _ (e1 : 'str_item_def_undef) _ - (c : string) _ (loc : int * int) -> + (c : string) _ (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e2 else e1 : 'def_undef_str)); [Gramext.Stoken ("", "ifdef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -98,7 +101,8 @@ Grammar.extend (Grammar.Entry.obj (str_item_def_undef : 'str_item_def_undef Grammar.Entry.e))], Gramext.action - (fun (e1 : 'str_item_def_undef) _ (c : string) _ (loc : int * int) -> + (fun (e1 : 'str_item_def_undef) _ (c : string) _ + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e1 else SdNop : 'def_undef_str)); [Gramext.Stoken ("", "ifdef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -111,7 +115,7 @@ Grammar.extend (str_item_def_undef : 'str_item_def_undef Grammar.Entry.e))], Gramext.action (fun (e2 : 'str_item_def_undef) _ (e1 : 'str_item_def_undef) _ - (c : string) _ (loc : int * int) -> + (c : string) _ (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e1 else e2 : 'def_undef_str))]]; Grammar.Entry.obj (str_item_def_undef : 'str_item_def_undef Grammar.Entry.e), @@ -121,13 +125,14 @@ Grammar.extend (Grammar.Entry.obj (Pcaml.str_item : 'Pcaml__str_item Grammar.Entry.e))], Gramext.action - (fun (si : 'Pcaml__str_item) (loc : int * int) -> + (fun (si : 'Pcaml__str_item) + (loc : Lexing.position * Lexing.position) -> (SdStr si : 'str_item_def_undef)); [Gramext.Snterm (Grammar.Entry.obj (def_undef_str : 'def_undef_str Grammar.Entry.e))], Gramext.action - (fun (d : 'def_undef_str) (loc : int * int) -> + (fun (d : 'def_undef_str) (loc : Lexing.position * Lexing.position) -> (d : 'str_item_def_undef))]]; Grammar.Entry.obj (Pcaml.sig_item : 'Pcaml__sig_item Grammar.Entry.e), Some Gramext.First, @@ -136,7 +141,7 @@ Grammar.extend (Grammar.Entry.obj (def_undef_sig : 'def_undef_sig Grammar.Entry.e))], Gramext.action - (fun (x : 'def_undef_sig) (loc : int * int) -> + (fun (x : 'def_undef_sig) (loc : Lexing.position * Lexing.position) -> (match x with SdStr si -> si | SdDef x -> define x; MLast.SgDcl (loc, []) @@ -147,17 +152,20 @@ Grammar.extend [None, None, [[Gramext.Stoken ("", "undef"); Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (c : string) _ (loc : int * int) -> (SdUnd c : 'def_undef_sig)); + (fun (c : string) _ (loc : Lexing.position * Lexing.position) -> + (SdUnd c : 'def_undef_sig)); [Gramext.Stoken ("", "define"); Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (c : string) _ (loc : int * int) -> (SdDef c : 'def_undef_sig)); + (fun (c : string) _ (loc : Lexing.position * Lexing.position) -> + (SdDef c : 'def_undef_sig)); [Gramext.Stoken ("", "ifndef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); Gramext.Snterm (Grammar.Entry.obj (sig_item_def_undef : 'sig_item_def_undef Grammar.Entry.e))], Gramext.action - (fun (e1 : 'sig_item_def_undef) _ (c : string) _ (loc : int * int) -> + (fun (e1 : 'sig_item_def_undef) _ (c : string) _ + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then SdNop else e1 : 'def_undef_sig)); [Gramext.Stoken ("", "ifndef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -170,7 +178,7 @@ Grammar.extend (sig_item_def_undef : 'sig_item_def_undef Grammar.Entry.e))], Gramext.action (fun (e2 : 'sig_item_def_undef) _ (e1 : 'sig_item_def_undef) _ - (c : string) _ (loc : int * int) -> + (c : string) _ (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e2 else e1 : 'def_undef_sig)); [Gramext.Stoken ("", "ifdef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -178,7 +186,8 @@ Grammar.extend (Grammar.Entry.obj (sig_item_def_undef : 'sig_item_def_undef Grammar.Entry.e))], Gramext.action - (fun (e1 : 'sig_item_def_undef) _ (c : string) _ (loc : int * int) -> + (fun (e1 : 'sig_item_def_undef) _ (c : string) _ + (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e1 else SdNop : 'def_undef_sig)); [Gramext.Stoken ("", "ifdef"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "then"); @@ -191,7 +200,7 @@ Grammar.extend (sig_item_def_undef : 'sig_item_def_undef Grammar.Entry.e))], Gramext.action (fun (e2 : 'sig_item_def_undef) _ (e1 : 'sig_item_def_undef) _ - (c : string) _ (loc : int * int) -> + (c : string) _ (loc : Lexing.position * Lexing.position) -> (if List.mem c !defined then e1 else e2 : 'def_undef_sig))]]; Grammar.Entry.obj (sig_item_def_undef : 'sig_item_def_undef Grammar.Entry.e), @@ -201,13 +210,14 @@ Grammar.extend (Grammar.Entry.obj (Pcaml.sig_item : 'Pcaml__sig_item Grammar.Entry.e))], Gramext.action - (fun (si : 'Pcaml__sig_item) (loc : int * int) -> + (fun (si : 'Pcaml__sig_item) + (loc : Lexing.position * Lexing.position) -> (SdStr si : 'sig_item_def_undef)); [Gramext.Snterm (Grammar.Entry.obj (def_undef_sig : 'def_undef_sig Grammar.Entry.e))], Gramext.action - (fun (d : 'def_undef_sig) (loc : int * int) -> + (fun (d : 'def_undef_sig) (loc : Lexing.position * Lexing.position) -> (d : 'sig_item_def_undef))]]]);; Pcaml.add_option "-D" (Arg.String define) diff --git a/camlp4/ocaml_src/meta/pa_macro.ml b/camlp4/ocaml_src/meta/pa_macro.ml index 599608f9fa..b70f5c6171 100644 --- a/camlp4/ocaml_src/meta/pa_macro.ml +++ b/camlp4/ocaml_src/meta/pa_macro.ml @@ -64,7 +64,12 @@ let defined = ref [];; let is_defined i = List.mem_assoc i !defined;; -let loc = 0, 0;; +let loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0} + in + nowhere, nowhere +;; let subst mloc env = let rec loop = @@ -129,16 +134,16 @@ let define eo x = [None, None, [[Gramext.Stoken ("UIDENT", x)], Gramext.action - (fun _ (loc : int * int) -> - (Pcaml.expr_reloc (fun _ -> loc) 0 e : 'expr))]]; + (fun _ (loc : Lexing.position * Lexing.position) -> + (Pcaml.expr_reloc (fun _ -> loc) (fst loc) e : 'expr))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("UIDENT", x)], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (let p = substp loc [] e in - Pcaml.patt_reloc (fun _ -> loc) 0 p : + Pcaml.patt_reloc (fun _ -> loc) (fst loc) p : 'patt))]]] | Some (sl, e) -> Grammar.extend @@ -147,7 +152,8 @@ let define eo x = [None, None, [[Gramext.Stoken ("UIDENT", x); Gramext.Sself], Gramext.action - (fun (param : 'expr) _ (loc : int * int) -> + (fun (param : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (let el = match param with MLast.ExTup (_, el) -> el @@ -156,7 +162,7 @@ let define eo x = if List.length el = List.length sl then let env = List.combine sl el in let e = subst loc env e in - Pcaml.expr_reloc (fun _ -> loc) 0 e + Pcaml.expr_reloc (fun _ -> loc) (fst loc) e else incorrect_number loc el sl : 'expr))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), @@ -164,7 +170,8 @@ let define eo x = [None, None, [[Gramext.Stoken ("UIDENT", x); Gramext.Sself], Gramext.action - (fun (param : 'patt) _ (loc : int * int) -> + (fun (param : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (let pl = match param with MLast.PaTup (_, pl) -> pl @@ -173,7 +180,7 @@ let define eo x = if List.length pl = List.length sl then let env = List.combine sl pl in let p = substp loc env e in - Pcaml.patt_reloc (fun _ -> loc) 0 p + Pcaml.patt_reloc (fun _ -> loc) (fst loc) p else incorrect_number loc pl sl : 'patt))]]] | None -> () @@ -220,7 +227,7 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (macro_def : 'macro_def Grammar.Entry.e))], Gramext.action - (fun (x : 'macro_def) (loc : int * int) -> + (fun (x : 'macro_def) (loc : Lexing.position * Lexing.position) -> (match x with SdStr [si] -> si | SdStr sil -> MLast.StDcl (loc, sil) @@ -243,7 +250,7 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (d2 : 'str_item_or_macro) _ (d1 : 'str_item_or_macro) _ - (i : 'uident) _ (loc : int * int) -> + (i : 'uident) _ (loc : Lexing.position * Lexing.position) -> (if is_defined i then d2 else d1 : 'macro_def)); [Gramext.Stoken ("", "IFNDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); @@ -253,7 +260,8 @@ Grammar.extend (str_item_or_macro : 'str_item_or_macro Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (d : 'str_item_or_macro) _ (i : 'uident) _ (loc : int * int) -> + (fun _ (d : 'str_item_or_macro) _ (i : 'uident) _ + (loc : Lexing.position * Lexing.position) -> (if is_defined i then SdNop else d : 'macro_def)); [Gramext.Stoken ("", "IFDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); @@ -268,7 +276,7 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (d2 : 'str_item_or_macro) _ (d1 : 'str_item_or_macro) _ - (i : 'uident) _ (loc : int * int) -> + (i : 'uident) _ (loc : Lexing.position * Lexing.position) -> (if is_defined i then d1 else d2 : 'macro_def)); [Gramext.Stoken ("", "IFDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); @@ -278,19 +286,22 @@ Grammar.extend (str_item_or_macro : 'str_item_or_macro Grammar.Entry.e)); Gramext.Stoken ("", "END")], Gramext.action - (fun _ (d : 'str_item_or_macro) _ (i : 'uident) _ (loc : int * int) -> + (fun _ (d : 'str_item_or_macro) _ (i : 'uident) _ + (loc : Lexing.position * Lexing.position) -> (if is_defined i then d else SdNop : 'macro_def)); [Gramext.Stoken ("", "UNDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e))], Gramext.action - (fun (i : 'uident) _ (loc : int * int) -> (SdUnd i : 'macro_def)); + (fun (i : 'uident) _ (loc : Lexing.position * Lexing.position) -> + (SdUnd i : 'macro_def)); [Gramext.Stoken ("", "DEFINE"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); Gramext.Snterm (Grammar.Entry.obj (opt_macro_value : 'opt_macro_value Grammar.Entry.e))], Gramext.action - (fun (def : 'opt_macro_value) (i : 'uident) _ (loc : int * int) -> + (fun (def : 'opt_macro_value) (i : 'uident) _ + (loc : Lexing.position * Lexing.position) -> (SdDef (i, def) : 'macro_def))]]; Grammar.Entry.obj (str_item_or_macro : 'str_item_or_macro Grammar.Entry.e), @@ -300,21 +311,25 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)))], Gramext.action - (fun (si : 'str_item list) (loc : int * int) -> + (fun (si : 'str_item list) + (loc : Lexing.position * Lexing.position) -> (SdStr si : 'str_item_or_macro)); [Gramext.Snterm (Grammar.Entry.obj (macro_def : 'macro_def Grammar.Entry.e))], Gramext.action - (fun (d : 'macro_def) (loc : int * int) -> + (fun (d : 'macro_def) (loc : Lexing.position * Lexing.position) -> (d : 'str_item_or_macro))]]; Grammar.Entry.obj (opt_macro_value : 'opt_macro_value Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (None : 'opt_macro_value)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (None : 'opt_macro_value)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Some ([], e) : 'opt_macro_value)); [Gramext.Stoken ("", "("); Gramext.Slist1sep @@ -322,7 +337,8 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ _ (pl : string list) _ (loc : int * int) -> + (fun (e : 'expr) _ _ (pl : string list) _ + (loc : Lexing.position * Lexing.position) -> (Some (pl, e) : 'opt_macro_value))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "top"), @@ -334,7 +350,7 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (e2 : 'expr) _ (e1 : 'expr) _ (i : 'uident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if is_defined i then e2 else e1 : 'expr)); [Gramext.Stoken ("", "IFDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); @@ -343,22 +359,22 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (e2 : 'expr) _ (e1 : 'expr) _ (i : 'uident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if is_defined i then e1 else e2 : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("LIDENT", "__LOCATION__")], Gramext.action - (fun _ (loc : int * int) -> - (let bp = string_of_int (fst loc) in - let ep = string_of_int (snd loc) in + (fun _ (loc : Lexing.position * Lexing.position) -> + (let bp = string_of_int (fst loc).Lexing.pos_cnum in + let ep = string_of_int (snd loc).Lexing.pos_cnum in MLast.ExTup (loc, [MLast.ExInt (loc, bp); MLast.ExInt (loc, ep)]) : 'expr)); [Gramext.Stoken ("LIDENT", "__FILE__")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (MLast.ExStr (loc, !(Pcaml.input_file)) : 'expr))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), None, [None, None, @@ -369,7 +385,7 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (p2 : 'patt) _ (p1 : 'patt) _ (i : 'uident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if is_defined i then p2 else p1 : 'patt)); [Gramext.Stoken ("", "IFDEF"); Gramext.Snterm (Grammar.Entry.obj (uident : 'uident Grammar.Entry.e)); @@ -378,13 +394,14 @@ Grammar.extend Gramext.Stoken ("", "END")], Gramext.action (fun _ (p2 : 'patt) _ (p1 : 'patt) _ (i : 'uident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (if is_defined i then p1 else p2 : 'patt))]]; Grammar.Entry.obj (uident : 'uident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> (i : 'uident))]]]);; + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (i : 'uident))]]]);; Pcaml.add_option "-D" (Arg.String (define None)) "<string> Define for IFDEF instruction.";; diff --git a/camlp4/ocaml_src/meta/pa_r.ml b/camlp4/ocaml_src/meta/pa_r.ml index 013adfa8d6..b380dbcefc 100644 --- a/camlp4/ocaml_src/meta/pa_r.ml +++ b/camlp4/ocaml_src/meta/pa_r.ml @@ -19,16 +19,7 @@ Pcaml.no_constructors_arity := false;; let help_sequences () = Printf.eprintf "\ -New syntax: - do {e1; e2; ... ; en} - while e do {e1; e2; ... ; en} - for v = v1 to/downto v2 do {e1; e2; ... ; en} -Old (discouraged) syntax: - do e1; e2; ... ; en-1; return en - while e do e1; e2; ... ; en; done - for v = v1 to/downto v2 do e1; e2; ... ; en; done -To avoid compilation warning use the new syntax. -"; +New syntax: do {e1; e2; ... ; en} while e do {e1; e2; ... ; en} for v = v1 to/downto v2 do {e1; e2; ... ; en}Old (discouraged) syntax: do e1; e2; ... ; en-1; return en while e do e1; e2; ... ; en; done for v = v1 to/downto v2 do e1; e2; ... ; en; doneTo avoid compilation warning use the new syntax."; flush stderr; exit 1 ;; @@ -282,6 +273,8 @@ Grammar.extend grammar_entry_create "class_type_declaration" and field_expr : 'field_expr Grammar.Entry.e = grammar_entry_create "field_expr" + and meth_list : 'meth_list Grammar.Entry.e = + grammar_entry_create "meth_list" and field : 'field Grammar.Entry.e = grammar_entry_create "field" and typevar : 'typevar Grammar.Entry.e = grammar_entry_create "typevar" and clty_longident : 'clty_longident Grammar.Entry.e = @@ -312,10 +305,13 @@ Grammar.extend (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'str_item) (loc : int * int) -> (s : 'e__1))]); + (fun _ (s : 'str_item) + (loc : Lexing.position * Lexing.position) -> + (s : 'e__1))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'e__1 list) _ (loc : int * int) -> + (fun _ (st : 'e__1 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.MeStr (loc, st) : 'module_expr)); [Gramext.Stoken ("", "functor"); Gramext.Stoken ("", "("); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", ":"); @@ -324,22 +320,25 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action (fun (me : 'module_expr) _ _ (t : 'module_type) _ (i : string) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MeFun (loc, i, t, me) : 'module_expr))]; None, None, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (me2 : 'module_expr) (me1 : 'module_expr) (loc : int * int) -> + (fun (me2 : 'module_expr) (me1 : 'module_expr) + (loc : Lexing.position * Lexing.position) -> (MLast.MeApp (loc, me1, me2) : 'module_expr))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (me2 : 'module_expr) _ (me1 : 'module_expr) (loc : int * int) -> + (fun (me2 : 'module_expr) _ (me1 : 'module_expr) + (loc : Lexing.position * Lexing.position) -> (MLast.MeAcc (loc, me1, me2) : 'module_expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (me : 'module_expr) _ (loc : int * int) -> + (fun _ (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (me : 'module_expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm @@ -347,17 +346,17 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (mt : 'module_type) _ (me : 'module_expr) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MeTyc (loc, me, mt) : 'module_expr)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.MeUid (loc, i) : 'module_expr))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), None, [Some "top", None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) (loc : int * int) -> + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> (MLast.StExp (loc, e) : 'str_item)); [Gramext.Stoken ("", "value"); Gramext.Sopt (Gramext.Stoken ("", "rec")); @@ -367,7 +366,7 @@ Grammar.extend Gramext.Stoken ("", "and"))], Gramext.action (fun (l : 'let_binding list) (r : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.StVal (loc, o2b r, l) : 'str_item)); [Gramext.Stoken ("", "type"); Gramext.Slist1sep @@ -376,20 +375,22 @@ Grammar.extend (type_declaration : 'type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (tdl : 'type_declaration list) _ (loc : int * int) -> + (fun (tdl : 'type_declaration list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StTyp (loc, tdl) : 'str_item)); [Gramext.Stoken ("", "open"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (i : 'mod_ident) _ (loc : int * int) -> + (fun (i : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.StOpn (loc, i) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "type"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (i : string) _ _ (loc : int * int) -> + (fun (mt : 'module_type) _ (i : string) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.StMty (loc, i, mt) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "rec"); Gramext.Slist1sep @@ -398,20 +399,23 @@ Grammar.extend (module_rec_binding : 'module_rec_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (nmtmes : 'module_rec_binding list) _ _ (loc : int * int) -> + (fun (nmtmes : 'module_rec_binding list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.StRecMod (loc, nmtmes) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("UIDENT", ""); Gramext.Snterm (Grammar.Entry.obj (module_binding : 'module_binding Grammar.Entry.e))], Gramext.action - (fun (mb : 'module_binding) (i : string) _ (loc : int * int) -> + (fun (mb : 'module_binding) (i : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StMod (loc, i, mb) : 'str_item)); [Gramext.Stoken ("", "include"); Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (loc : int * int) -> + (fun (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StInc (loc, me) : 'str_item)); [Gramext.Stoken ("", "external"); Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", ":"); @@ -420,7 +424,7 @@ Grammar.extend Gramext.Slist1 (Gramext.Stoken ("STRING", ""))], Gramext.action (fun (pd : string list) _ (t : 'ctyp) _ (i : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.StExt (loc, i, t, pd) : 'str_item)); [Gramext.Stoken ("", "exception"); Gramext.Snterm @@ -431,7 +435,7 @@ Grammar.extend (Grammar.Entry.obj (rebind_exn : 'rebind_exn Grammar.Entry.e))], Gramext.action (fun (b : 'rebind_exn) (_, c, tl : 'constructor_declaration) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.StExc (loc, c, tl, b) : 'str_item)); [Gramext.Stoken ("", "declare"); Gramext.Slist0 @@ -440,19 +444,25 @@ Grammar.extend (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'str_item) (loc : int * int) -> (s : 'e__2))]); + (fun _ (s : 'str_item) + (loc : Lexing.position * Lexing.position) -> + (s : 'e__2))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'e__2 list) _ (loc : int * int) -> + (fun _ (st : 'e__2 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StDcl (loc, st) : 'str_item))]]; Grammar.Entry.obj (rebind_exn : 'rebind_exn Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> ([] : 'rebind_exn)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> ([] : 'rebind_exn)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (sl : 'mod_ident) _ (loc : int * int) -> (sl : 'rebind_exn))]]; + (fun (sl : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> + (sl : 'rebind_exn))]]; Grammar.Entry.obj (module_binding : 'module_binding Grammar.Entry.e), None, [None, Some Gramext.RightA, @@ -460,7 +470,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (loc : int * int) -> + (fun (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (me : 'module_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm @@ -469,7 +480,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (mt : 'module_type) _ (loc : int * int) -> + (fun (me : 'module_expr) _ (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (MLast.MeTyc (loc, me, mt) : 'module_binding)); [Gramext.Stoken ("", "("); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", ":"); @@ -478,7 +490,7 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Sself], Gramext.action (fun (mb : 'module_binding) _ (mt : 'module_type) _ (m : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MeFun (loc, m, mt, mb) : 'module_binding))]]; Grammar.Entry.obj (module_rec_binding : 'module_rec_binding Grammar.Entry.e), @@ -492,7 +504,7 @@ Grammar.extend (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action (fun (me : 'module_expr) _ (mt : 'module_type) _ (m : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (m, mt, me : 'module_rec_binding))]]; Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e), None, [None, None, @@ -501,7 +513,7 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action (fun (mt : 'module_type) _ _ (t : 'module_type) _ (i : string) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MtFun (loc, i, t, mt) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "with"); @@ -511,7 +523,7 @@ Grammar.extend Gramext.Stoken ("", "and"))], Gramext.action (fun (wcl : 'with_constr list) _ (mt : 'module_type) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MtWit (loc, mt, wcl) : 'module_type))]; None, None, [[Gramext.Stoken ("", "sig"); @@ -521,38 +533,44 @@ Grammar.extend (Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'sig_item) (loc : int * int) -> (s : 'e__3))]); + (fun _ (s : 'sig_item) + (loc : Lexing.position * Lexing.position) -> + (s : 'e__3))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (sg : 'e__3 list) _ (loc : int * int) -> + (fun _ (sg : 'e__3 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.MtSig (loc, sg) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (m2 : 'module_type) (m1 : 'module_type) (loc : int * int) -> + (fun (m2 : 'module_type) (m1 : 'module_type) + (loc : Lexing.position * Lexing.position) -> (MLast.MtApp (loc, m1, m2) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (m2 : 'module_type) _ (m1 : 'module_type) (loc : int * int) -> + (fun (m2 : 'module_type) _ (m1 : 'module_type) + (loc : Lexing.position * Lexing.position) -> (MLast.MtAcc (loc, m1, m2) : 'module_type))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (mt : 'module_type) _ (loc : int * int) -> + (fun _ (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (mt : 'module_type)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.MtQuo (loc, i) : 'module_type)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.MtLid (loc, i) : 'module_type)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.MtUid (loc, i) : 'module_type))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [Some "top", None, @@ -560,7 +578,8 @@ Grammar.extend Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (i : string) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (i : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgVal (loc, i, t) : 'sig_item)); [Gramext.Stoken ("", "type"); Gramext.Slist1sep @@ -569,20 +588,22 @@ Grammar.extend (type_declaration : 'type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (tdl : 'type_declaration list) _ (loc : int * int) -> + (fun (tdl : 'type_declaration list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgTyp (loc, tdl) : 'sig_item)); [Gramext.Stoken ("", "open"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (i : 'mod_ident) _ (loc : int * int) -> + (fun (i : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.SgOpn (loc, i) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "type"); Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (i : string) _ _ (loc : int * int) -> + (fun (mt : 'module_type) _ (i : string) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgMty (loc, i, mt) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "rec"); Gramext.Slist1sep @@ -592,20 +613,23 @@ Grammar.extend 'module_rec_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (mds : 'module_rec_declaration list) _ _ (loc : int * int) -> + (fun (mds : 'module_rec_declaration list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgRecMod (loc, mds) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("UIDENT", ""); Gramext.Snterm (Grammar.Entry.obj (module_declaration : 'module_declaration Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_declaration) (i : string) _ (loc : int * int) -> + (fun (mt : 'module_declaration) (i : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgMod (loc, i, mt) : 'sig_item)); [Gramext.Stoken ("", "include"); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (loc : int * int) -> + (fun (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgInc (loc, mt) : 'sig_item)); [Gramext.Stoken ("", "external"); Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", ":"); @@ -614,7 +638,7 @@ Grammar.extend Gramext.Slist1 (Gramext.Stoken ("STRING", ""))], Gramext.action (fun (pd : string list) _ (t : 'ctyp) _ (i : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.SgExt (loc, i, t, pd) : 'sig_item)); [Gramext.Stoken ("", "exception"); Gramext.Snterm @@ -622,7 +646,8 @@ Grammar.extend (constructor_declaration : 'constructor_declaration Grammar.Entry.e))], Gramext.action - (fun (_, c, tl : 'constructor_declaration) _ (loc : int * int) -> + (fun (_, c, tl : 'constructor_declaration) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgExc (loc, c, tl) : 'sig_item)); [Gramext.Stoken ("", "declare"); Gramext.Slist0 @@ -631,10 +656,13 @@ Grammar.extend (Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'sig_item) (loc : int * int) -> (s : 'e__4))]); + (fun _ (s : 'sig_item) + (loc : Lexing.position * Lexing.position) -> + (s : 'e__4))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'e__4 list) _ (loc : int * int) -> + (fun _ (st : 'e__4 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgDcl (loc, st) : 'sig_item))]]; Grammar.Entry.obj (module_declaration : 'module_declaration Grammar.Entry.e), @@ -647,13 +675,14 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Sself], Gramext.action (fun (mt : 'module_declaration) _ (t : 'module_type) _ (i : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.MtFun (loc, i, t, mt) : 'module_declaration)); [Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (loc : int * int) -> + (fun (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (mt : 'module_declaration))]]; Grammar.Entry.obj (module_rec_declaration : 'module_rec_declaration Grammar.Entry.e), @@ -663,7 +692,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (m : string) (loc : int * int) -> + (fun (mt : 'module_type) _ (m : string) + (loc : Lexing.position * Lexing.position) -> (m, mt : 'module_rec_declaration))]]; Grammar.Entry.obj (with_constr : 'with_constr Grammar.Entry.e), None, [None, None, @@ -674,7 +704,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (i : 'mod_ident) _ (loc : int * int) -> + (fun (me : 'module_expr) _ (i : 'mod_ident) _ + (loc : Lexing.position * Lexing.position) -> (MLast.WcMod (loc, i, me) : 'with_constr)); [Gramext.Stoken ("", "type"); Gramext.Snterm @@ -687,17 +718,31 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (tpl : 'type_parameter list) (i : 'mod_ident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.WcTyp (loc, i, tpl, t) : 'with_constr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), None, [Some "top", Some Gramext.RightA, - [[Gramext.Stoken ("", "while"); Gramext.Sself; Gramext.Stoken ("", "do"); + [[Gramext.Stoken ("", "object"); + Gramext.Sopt + (Gramext.Snterm + (Grammar.Entry.obj + (class_self_patt : 'class_self_patt Grammar.Entry.e))); + Gramext.Snterm + (Grammar.Entry.obj + (class_structure : 'class_structure Grammar.Entry.e)); + Gramext.Stoken ("", "end")], + Gramext.action + (fun _ (cf : 'class_structure) (cspo : 'class_self_patt option) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.ExObj (loc, cspo, cf) : 'expr)); + [Gramext.Stoken ("", "while"); Gramext.Sself; Gramext.Stoken ("", "do"); Gramext.Stoken ("", "{"); Gramext.Snterm (Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e)); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (seq : 'sequence) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (seq : 'sequence) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExWhi (loc, e, seq) : 'expr)); [Gramext.Stoken ("", "for"); Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", "="); Gramext.Sself; @@ -710,25 +755,29 @@ Grammar.extend Gramext.Stoken ("", "}")], Gramext.action (fun _ (seq : 'sequence) _ _ (e2 : 'expr) (df : 'direction_flag) - (e1 : 'expr) _ (i : string) _ (loc : int * int) -> + (e1 : 'expr) _ (i : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExFor (loc, i, e1, e2, df, seq) : 'expr)); [Gramext.Stoken ("", "do"); Gramext.Stoken ("", "{"); Gramext.Snterm (Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e)); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (seq : 'sequence) _ _ (loc : int * int) -> + (fun _ (seq : 'sequence) _ _ + (loc : Lexing.position * Lexing.position) -> (mksequence loc seq : 'expr)); [Gramext.Stoken ("", "if"); Gramext.Sself; Gramext.Stoken ("", "then"); Gramext.Sself; Gramext.Stoken ("", "else"); Gramext.Sself], Gramext.action - (fun (e3 : 'expr) _ (e2 : 'expr) _ (e1 : 'expr) _ (loc : int * int) -> + (fun (e3 : 'expr) _ (e2 : 'expr) _ (e1 : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExIfe (loc, e1, e2, e3) : 'expr)); [Gramext.Stoken ("", "try"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ (loc : int * int) -> + (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTry (loc, e, [p1, None, e1]) : 'expr)); [Gramext.Stoken ("", "try"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Stoken ("", "["); @@ -738,14 +787,16 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'match_case list) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (l : 'match_case list) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTry (loc, e, l) : 'expr)); [Gramext.Stoken ("", "match"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ (loc : int * int) -> + (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExMat (loc, e, [p1, None, e1]) : 'expr)); [Gramext.Stoken ("", "match"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Stoken ("", "["); @@ -755,14 +806,16 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'match_case list) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (l : 'match_case list) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExMat (loc, e, l) : 'expr)); [Gramext.Stoken ("", "fun"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Snterm (Grammar.Entry.obj (fun_def : 'fun_def Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_def) (p : 'ipatt) _ (loc : int * int) -> + (fun (e : 'fun_def) (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExFun (loc, [p, None, e]) : 'expr)); [Gramext.Stoken ("", "fun"); Gramext.Stoken ("", "["); Gramext.Slist0sep @@ -771,7 +824,8 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'match_case list) _ _ (loc : int * int) -> + (fun _ (l : 'match_case list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExFun (loc, l) : 'expr)); [Gramext.Stoken ("", "let"); Gramext.Stoken ("", "module"); Gramext.Stoken ("UIDENT", ""); @@ -781,7 +835,7 @@ Grammar.extend Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (e : 'expr) _ (mb : 'module_binding) (m : string) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.ExLmd (loc, m, mb, e) : 'expr)); [Gramext.Stoken ("", "let"); Gramext.Sopt (Gramext.Stoken ("", "rec")); Gramext.Slist1sep @@ -791,7 +845,7 @@ Grammar.extend Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (x : 'expr) _ (l : 'let_binding list) (r : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.ExLet (loc, o2b r, l, x) : 'expr))]; Some "where", None, [[Gramext.Sself; Gramext.Stoken ("", "where"); @@ -800,252 +854,293 @@ Grammar.extend (Grammar.Entry.obj (let_binding : 'let_binding Grammar.Entry.e))], Gramext.action (fun (lb : 'let_binding) (rf : string option) _ (e : 'expr) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.ExLet (loc, o2b rf, [lb], e) : 'expr))]; Some ":=", Some Gramext.NonA, [[Gramext.Sself; Gramext.Stoken ("", ":="); Gramext.Sself; Gramext.Snterm (Grammar.Entry.obj (dummy : 'dummy Grammar.Entry.e))], Gramext.action - (fun _ (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExAss (loc, e1, e2) : 'expr))]; Some "||", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "||"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "||"), e1), e2) : 'expr))]; Some "&&", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "&&"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "&&"), e1), e2) : 'expr))]; Some "<", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "!="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "!="), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "=="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "=="), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<>"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "<>"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "="), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", ">="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, ">="), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "<="), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", ">"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, ">"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "<"), e1), e2) : 'expr))]; Some "^", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "@"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "@"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "^"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "^"), e1), e2) : 'expr))]; Some "+", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "-."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "-."), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "+."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "+."), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "-"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "-"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "+"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "+"), e1), e2) : 'expr))]; Some "*", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "mod"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "mod"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lxor"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "lxor"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lor"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "lor"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "land"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "land"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "/."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "/."), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "*."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "*."), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "/"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "/"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "*"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "*"), e1), e2) : 'expr))]; Some "**", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "lsr"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "lsr"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lsl"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "lsl"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "asr"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "asr"), e1), e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "**"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExLid (loc, "**"), e1), e2) : 'expr))]; Some "unary minus", Some Gramext.NonA, [[Gramext.Stoken ("", "-."); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (mkumin loc "-." e : 'expr)); + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (mkumin loc "-." e : 'expr)); [Gramext.Stoken ("", "-"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (mkumin loc "-" e : 'expr))]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (mkumin loc "-" e : 'expr))]; Some "apply", Some Gramext.LeftA, [[Gramext.Stoken ("", "lazy"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExLaz (loc, e) : 'expr)); [Gramext.Stoken ("", "assert"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (mkassert loc e : 'expr)); + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (mkassert loc e : 'expr)); [Gramext.Sself; Gramext.Sself], Gramext.action - (fun (e2 : 'expr) (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, e1, e2) : 'expr))]; Some ".", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExAcc (loc, e1, e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Stoken ("", "["); Gramext.Sself; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (e2 : 'expr) _ _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExSte (loc, e1, e2) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (e2 : 'expr) _ _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExAre (loc, e1, e2) : 'expr))]; Some "~-", Some Gramext.NonA, [[Gramext.Stoken ("", "~-."); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExLid (loc, "~-."), e) : 'expr)); [Gramext.Stoken ("", "~-"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExApp (loc, MLast.ExLid (loc, "~-"), e) : 'expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (e : 'expr) _ (loc : int * int) -> (e : 'expr)); + Gramext.action + (fun _ (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.Slist1sep (Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)), Gramext.Stoken ("", ",")); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (el : 'expr list) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (el : 'expr list) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTup (loc, (e :: el)) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTyc (loc, e, t) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> (MLast.ExUid (loc, "()") : 'expr)); + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.ExUid (loc, "()") : 'expr)); [Gramext.Stoken ("", "{"); Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")"); Gramext.Stoken ("", "with"); Gramext.Slist1sep @@ -1055,7 +1150,7 @@ Grammar.extend Gramext.Stoken ("", "}")], Gramext.action (fun _ (lel : 'label_expr list) _ _ (e : 'expr) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.ExRec (loc, lel, Some e) : 'expr)); [Gramext.Stoken ("", "{"); Gramext.Slist1sep @@ -1064,7 +1159,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lel : 'label_expr list) _ (loc : int * int) -> + (fun _ (lel : 'label_expr list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExRec (loc, lel, None) : 'expr)); [Gramext.Stoken ("", "[|"); Gramext.Slist0sep @@ -1072,7 +1168,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (el : 'expr list) _ (loc : int * int) -> + (fun _ (el : 'expr list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExArr (loc, el) : 'expr)); [Gramext.Stoken ("", "["); Gramext.Slist1sep @@ -1083,64 +1180,77 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (last : 'cons_expr_opt) (el : 'expr list) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (mklistexp loc last el : 'expr)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "]")], Gramext.action - (fun _ _ (loc : int * int) -> (MLast.ExUid (loc, "[]") : 'expr)); + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.ExUid (loc, "[]") : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e))], - Gramext.action (fun (i : 'expr_ident) (loc : int * int) -> (i : 'expr)); + Gramext.action + (fun (i : 'expr_ident) (loc : Lexing.position * Lexing.position) -> + (i : 'expr)); [Gramext.Stoken ("CHAR", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExChr (loc, s) : 'expr)); [Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExStr (loc, s) : 'expr)); [Gramext.Stoken ("FLOAT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExFlo (loc, s) : 'expr)); [Gramext.Stoken ("NATIVEINT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExNativeInt (loc, s) : 'expr)); [Gramext.Stoken ("INT64", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExInt64 (loc, s) : 'expr)); [Gramext.Stoken ("INT32", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExInt32 (loc, s) : 'expr)); [Gramext.Stoken ("INT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExInt (loc, s) : 'expr))]]; Grammar.Entry.obj (cons_expr_opt : 'cons_expr_opt Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (None : 'cons_expr_opt)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (None : 'cons_expr_opt)); [Gramext.Stoken ("", "::"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (Some e : 'cons_expr_opt))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (Some e : 'cons_expr_opt))]]; Grammar.Entry.obj (dummy : 'dummy Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (() : 'dummy))]]; + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> (() : 'dummy))]]; Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], - Gramext.action (fun (e : 'expr) (loc : int * int) -> ([e] : 'sequence)); + Gramext.action + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> + ([e] : 'sequence)); [Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> ([e] : 'sequence)); + (fun _ (e : 'expr) (loc : Lexing.position * Lexing.position) -> + ([e] : 'sequence)); [Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";"); Gramext.Sself], Gramext.action - (fun (el : 'sequence) _ (e : 'expr) (loc : int * int) -> + (fun (el : 'sequence) _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> (e :: el : 'sequence)); [Gramext.Stoken ("", "let"); Gramext.Sopt (Gramext.Stoken ("", "rec")); Gramext.Slist1sep @@ -1149,13 +1259,17 @@ Grammar.extend Gramext.Stoken ("", "and")); Gramext.srules [[Gramext.Stoken ("", ";")], - Gramext.action (fun (x : string) (loc : int * int) -> (x : 'e__5)); + Gramext.action + (fun (x : string) (loc : Lexing.position * Lexing.position) -> + (x : 'e__5)); [Gramext.Stoken ("", "in")], - Gramext.action (fun (x : string) (loc : int * int) -> (x : 'e__5))]; + Gramext.action + (fun (x : string) (loc : Lexing.position * Lexing.position) -> + (x : 'e__5))]; Gramext.Sself], Gramext.action (fun (el : 'sequence) _ (l : 'let_binding list) (rf : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> ([MLast.ExLet (loc, o2b rf, l, mksequence loc el)] : 'sequence))]]; Grammar.Entry.obj (let_binding : 'let_binding Grammar.Entry.e), None, [None, None, @@ -1163,7 +1277,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (p, e : 'let_binding))]]; Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e), None, [None, Some Gramext.RightA, @@ -1172,16 +1287,19 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTyc (loc, e, t) : 'fun_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'fun_binding)); + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'fun_binding)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (MLast.ExFun (loc, [p, None, e]) : 'fun_binding))]]; Grammar.Entry.obj (match_case : 'match_case Grammar.Entry.e), None, [None, None, @@ -1194,22 +1312,30 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action (fun (e : 'expr) _ (w : 'when_expr_opt) (aso : 'as_patt_opt) - (p : 'patt) (loc : int * int) -> + (p : 'patt) (loc : Lexing.position * Lexing.position) -> (mkmatchcase loc p aso w e : 'match_case))]]; Grammar.Entry.obj (as_patt_opt : 'as_patt_opt Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (None : 'as_patt_opt)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (None : 'as_patt_opt)); [Gramext.Stoken ("", "as"); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (loc : int * int) -> (Some p : 'as_patt_opt))]]; + (fun (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (Some p : 'as_patt_opt))]]; Grammar.Entry.obj (when_expr_opt : 'when_expr_opt Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (None : 'when_expr_opt)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (None : 'when_expr_opt)); [Gramext.Stoken ("", "when"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (Some e : 'when_expr_opt))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (Some e : 'when_expr_opt))]]; Grammar.Entry.obj (label_expr : 'label_expr Grammar.Entry.e), None, [None, None, [[Gramext.Snterm @@ -1218,81 +1344,98 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_binding) (i : 'patt_label_ident) (loc : int * int) -> + (fun (e : 'fun_binding) (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (i, e : 'label_expr))]]; Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (j : 'expr_ident) _ (i : string) (loc : int * int) -> + (fun (j : 'expr_ident) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (mkexprident loc i j : 'expr_ident)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExUid (loc, i) : 'expr_ident)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExLid (loc, i) : 'expr_ident))]]; Grammar.Entry.obj (fun_def : 'fun_def Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Stoken ("", "->"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], - Gramext.action (fun (e : 'expr) _ (loc : int * int) -> (e : 'fun_def)); + Gramext.action + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'fun_def)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'fun_def) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_def) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (MLast.ExFun (loc, [p, None, e]) : 'fun_def))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), None, [None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "|"); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaOrp (loc, p1, p2) : 'patt))]; None, Some Gramext.NonA, [[Gramext.Sself; Gramext.Stoken ("", ".."); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaRng (loc, p1, p2) : 'patt))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (p2 : 'patt) (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaApp (loc, p1, p2) : 'patt))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaAcc (loc, p1, p2) : 'patt))]; Some "simple", None, [[Gramext.Stoken ("", "_")], - Gramext.action (fun _ (loc : int * int) -> (MLast.PaAny loc : 'patt)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaAny loc : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.Slist1sep (Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)), Gramext.Stoken ("", ",")); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'patt list) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (pl : 'patt list) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTup (loc, (p :: pl)) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p2 : 'patt) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (p2 : 'patt) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaAli (loc, p, p2) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTyc (loc, p, t) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (p : 'patt) _ (loc : int * int) -> (p : 'patt)); + Gramext.action + (fun _ (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'patt)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> (MLast.PaUid (loc, "()") : 'patt)); + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaUid (loc, "()") : 'patt)); [Gramext.Stoken ("", "{"); Gramext.Slist1sep (Gramext.Snterm @@ -1300,7 +1443,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lpl : 'label_patt list) _ (loc : int * int) -> + (fun _ (lpl : 'label_patt list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaRec (loc, lpl) : 'patt)); [Gramext.Stoken ("", "[|"); Gramext.Slist0sep @@ -1308,7 +1452,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (pl : 'patt list) _ (loc : int * int) -> + (fun _ (pl : 'patt list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaArr (loc, pl) : 'patt)); [Gramext.Stoken ("", "["); Gramext.Slist1sep @@ -1319,74 +1464,79 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (last : 'cons_patt_opt) (pl : 'patt list) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (mklistpat loc last pl : 'patt)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "]")], Gramext.action - (fun _ _ (loc : int * int) -> (MLast.PaUid (loc, "[]") : 'patt)); + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaUid (loc, "[]") : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("FLOAT", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> + (fun (s : string) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaFlo (loc, neg_string s) : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("NATIVEINT", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> + (fun (s : string) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaNativeInt (loc, neg_string s) : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("INT64", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> + (fun (s : string) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaInt64 (loc, neg_string s) : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("INT32", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> + (fun (s : string) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaInt32 (loc, neg_string s) : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Stoken ("INT", "")], Gramext.action - (fun (s : string) _ (loc : int * int) -> + (fun (s : string) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaInt (loc, neg_string s) : 'patt)); [Gramext.Stoken ("CHAR", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaChr (loc, s) : 'patt)); [Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaStr (loc, s) : 'patt)); [Gramext.Stoken ("FLOAT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaFlo (loc, s) : 'patt)); [Gramext.Stoken ("NATIVEINT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaNativeInt (loc, s) : 'patt)); [Gramext.Stoken ("INT64", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaInt64 (loc, s) : 'patt)); [Gramext.Stoken ("INT32", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaInt32 (loc, s) : 'patt)); [Gramext.Stoken ("INT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaInt (loc, s) : 'patt)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaUid (loc, s) : 'patt)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLid (loc, s) : 'patt))]]; Grammar.Entry.obj (cons_patt_opt : 'cons_patt_opt Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (None : 'cons_patt_opt)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (None : 'cons_patt_opt)); [Gramext.Stoken ("", "::"); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (loc : int * int) -> (Some p : 'cons_patt_opt))]]; + (fun (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (Some p : 'cons_patt_opt))]]; Grammar.Entry.obj (label_patt : 'label_patt Grammar.Entry.e), None, [None, None, [[Gramext.Snterm @@ -1395,7 +1545,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (i : 'patt_label_ident) (loc : int * int) -> + (fun (p : 'patt) _ (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (i, p : 'label_patt))]]; Grammar.Entry.obj (patt_label_ident : 'patt_label_ident Grammar.Entry.e), None, @@ -1403,24 +1554,26 @@ Grammar.extend [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action (fun (p2 : 'patt_label_ident) _ (p1 : 'patt_label_ident) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaAcc (loc, p1, p2) : 'patt_label_ident))]; Some "simple", Some Gramext.RightA, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLid (loc, i) : 'patt_label_ident)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaUid (loc, i) : 'patt_label_ident))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "_")], - Gramext.action (fun _ (loc : int * int) -> (MLast.PaAny loc : 'ipatt)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaAny loc : 'ipatt)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLid (loc, s) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.Slist1sep @@ -1428,24 +1581,30 @@ Grammar.extend Gramext.Stoken ("", ",")); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'ipatt list) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (pl : 'ipatt list) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTup (loc, (p :: pl)) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p2 : 'ipatt) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (p2 : 'ipatt) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaAli (loc, p, p2) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTyc (loc, p, t) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (p : 'ipatt) _ (loc : int * int) -> (p : 'ipatt)); + Gramext.action + (fun _ (p : 'ipatt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> (MLast.PaUid (loc, "()") : 'ipatt)); + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.PaUid (loc, "()") : 'ipatt)); [Gramext.Stoken ("", "{"); Gramext.Slist1sep (Gramext.Snterm @@ -1453,7 +1612,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lpl : 'label_ipatt list) _ (loc : int * int) -> + (fun _ (lpl : 'label_ipatt list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaRec (loc, lpl) : 'ipatt))]]; Grammar.Entry.obj (label_ipatt : 'label_ipatt Grammar.Entry.e), None, [None, None, @@ -1463,7 +1623,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e))], Gramext.action - (fun (p : 'ipatt) _ (i : 'patt_label_ident) (loc : int * int) -> + (fun (p : 'ipatt) _ (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (i, p : 'label_ipatt))]]; Grammar.Entry.obj (type_declaration : 'type_declaration Grammar.Entry.e), None, @@ -1481,13 +1642,15 @@ Grammar.extend (Grammar.Entry.obj (constrain : 'constrain Grammar.Entry.e)))], Gramext.action (fun (cl : 'constrain list) (tk : 'ctyp) _ - (tpl : 'type_parameter list) (n : 'type_patt) (loc : int * int) -> + (tpl : 'type_parameter list) (n : 'type_patt) + (loc : Lexing.position * Lexing.position) -> (n, tpl, tk, cl : 'type_declaration))]]; Grammar.Entry.obj (type_patt : 'type_patt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (n : string) (loc : int * int) -> (loc, n : 'type_patt))]]; + (fun (n : string) (loc : Lexing.position * Lexing.position) -> + (loc, n : 'type_patt))]]; Grammar.Entry.obj (constrain : 'constrain Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "constraint"); @@ -1495,7 +1658,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (t1, t2 : 'constrain))]]; Grammar.Entry.obj (type_parameter : 'type_parameter Grammar.Entry.e), None, @@ -1503,28 +1667,30 @@ Grammar.extend [[Gramext.Stoken ("", "-"); Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ _ (loc : int * int) -> + (fun (i : 'ident) _ _ (loc : Lexing.position * Lexing.position) -> (i, (false, true) : 'type_parameter)); [Gramext.Stoken ("", "+"); Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ _ (loc : int * int) -> + (fun (i : 'ident) _ _ (loc : Lexing.position * Lexing.position) -> (i, (true, false) : 'type_parameter)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (i, (false, false) : 'type_parameter))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), None, [None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "=="); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (MLast.TyMan (loc, t1, t2) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (MLast.TyAli (loc, t1, t2) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Stoken ("", "!"); @@ -1533,41 +1699,49 @@ Grammar.extend (Grammar.Entry.obj (typevar : 'typevar Grammar.Entry.e))); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (pl : 'typevar list) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (pl : 'typevar list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyPol (loc, pl, t) : 'ctyp))]; Some "arrow", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (MLast.TyArr (loc, t1, t2) : 'ctyp))]; Some "label", Some Gramext.NonA, [[Gramext.Stoken ("OPTLABEL", ""); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) (i : string) (loc : int * int) -> + (fun (t : 'ctyp) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.TyOlb (loc, i, t) : 'ctyp)); [Gramext.Stoken ("QUESTIONIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (i : string) (loc : int * int) -> + (fun (t : 'ctyp) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.TyOlb (loc, i, t) : 'ctyp)); [Gramext.Stoken ("LABEL", ""); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) (i : string) (loc : int * int) -> + (fun (t : 'ctyp) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.TyLab (loc, i, t) : 'ctyp)); [Gramext.Stoken ("TILDEIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (i : string) (loc : int * int) -> + (fun (t : 'ctyp) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.TyLab (loc, i, t) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (MLast.TyApp (loc, t1, t2) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (MLast.TyAcc (loc, t1, t2) : 'ctyp))]; Some "simple", None, [[Gramext.Stoken ("", "{"); @@ -1578,7 +1752,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (ldl : 'label_declaration list) _ (loc : int * int) -> + (fun _ (ldl : 'label_declaration list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyRec (loc, false, ldl) : 'ctyp)); [Gramext.Stoken ("", "["); Gramext.Slist0sep @@ -1589,7 +1764,8 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (cdl : 'constructor_declaration list) _ (loc : int * int) -> + (fun _ (cdl : 'constructor_declaration list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.TySum (loc, false, cdl) : 'ctyp)); [Gramext.Stoken ("", "private"); Gramext.Stoken ("", "{"); Gramext.Slist1sep @@ -1599,7 +1775,8 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (ldl : 'label_declaration list) _ _ (loc : int * int) -> + (fun _ (ldl : 'label_declaration list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyRec (loc, true, ldl) : 'ctyp)); [Gramext.Stoken ("", "private"); Gramext.Stoken ("", "["); Gramext.Slist0sep @@ -1610,32 +1787,38 @@ Grammar.extend Gramext.Stoken ("", "|")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (cdl : 'constructor_declaration list) _ _ (loc : int * int) -> + (fun _ (cdl : 'constructor_declaration list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TySum (loc, true, cdl) : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (t : 'ctyp) _ (loc : int * int) -> (t : 'ctyp)); + Gramext.action + (fun _ (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "*"); Gramext.Slist1sep (Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", "*")); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (tl : 'ctyp list) _ (t : 'ctyp) _ (loc : int * int) -> + (fun _ (tl : 'ctyp list) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyTup (loc, (t :: tl)) : 'ctyp)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.TyUid (loc, i) : 'ctyp)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.TyLid (loc, i) : 'ctyp)); [Gramext.Stoken ("", "_")], - Gramext.action (fun _ (loc : int * int) -> (MLast.TyAny loc : 'ctyp)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (MLast.TyAny loc : 'ctyp)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.TyQuo (loc, i) : 'ctyp))]]; Grammar.Entry.obj (constructor_declaration : 'constructor_declaration Grammar.Entry.e), @@ -1643,14 +1826,15 @@ Grammar.extend [None, None, [[Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (ci : string) (loc : int * int) -> + (fun (ci : string) (loc : Lexing.position * Lexing.position) -> (loc, ci, [] : 'constructor_declaration)); [Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "of"); Gramext.Slist1sep (Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (cal : 'ctyp list) _ (ci : string) (loc : int * int) -> + (fun (cal : 'ctyp list) _ (ci : string) + (loc : Lexing.position * Lexing.position) -> (loc, ci, cal : 'constructor_declaration))]]; Grammar.Entry.obj (label_declaration : 'label_declaration Grammar.Entry.e), @@ -1661,27 +1845,34 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) (mf : string option) _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (loc, i, o2b mf, t : 'label_declaration))]]; Grammar.Entry.obj (ident : 'ident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "")], - Gramext.action (fun (i : string) (loc : int * int) -> (i : 'ident)); + Gramext.action + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (i : 'ident)); [Gramext.Stoken ("LIDENT", "")], - Gramext.action (fun (i : string) (loc : int * int) -> (i : 'ident))]]; + Gramext.action + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (i : 'ident))]]; Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (j : 'mod_ident) _ (i : string) (loc : int * int) -> + (fun (j : 'mod_ident) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (i :: j : 'mod_ident)); [Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> ([i] : 'mod_ident)); + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + ([i] : 'mod_ident)); [Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> ([i] : 'mod_ident))]]; + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + ([i] : 'mod_ident))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "class"); Gramext.Stoken ("", "type"); @@ -1692,7 +1883,8 @@ Grammar.extend 'class_type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (ctd : 'class_type_declaration list) _ _ (loc : int * int) -> + (fun (ctd : 'class_type_declaration list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.StClt (loc, ctd) : 'str_item)); [Gramext.Stoken ("", "class"); Gramext.Slist1sep @@ -1701,7 +1893,8 @@ Grammar.extend (class_declaration : 'class_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (cd : 'class_declaration list) _ (loc : int * int) -> + (fun (cd : 'class_declaration list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StCls (loc, cd) : 'str_item))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [None, None, @@ -1713,7 +1906,8 @@ Grammar.extend 'class_type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (ctd : 'class_type_declaration list) _ _ (loc : int * int) -> + (fun (ctd : 'class_type_declaration list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgClt (loc, ctd) : 'sig_item)); [Gramext.Stoken ("", "class"); Gramext.Slist1sep @@ -1722,7 +1916,8 @@ Grammar.extend (class_description : 'class_description Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (cd : 'class_description list) _ (loc : int * int) -> + (fun (cd : 'class_description list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.SgCls (loc, cd) : 'sig_item))]]; Grammar.Entry.obj (class_declaration : 'class_declaration Grammar.Entry.e), @@ -1738,7 +1933,8 @@ Grammar.extend (class_fun_binding : 'class_fun_binding Grammar.Entry.e))], Gramext.action (fun (cfb : 'class_fun_binding) (ctp : 'class_type_parameters) - (i : string) (vf : string option) (loc : int * int) -> + (i : string) (vf : string option) + (loc : Lexing.position * Lexing.position) -> ({MLast.ciLoc = loc; MLast.ciVir = o2b vf; MLast.ciPrm = ctp; MLast.ciNam = i; MLast.ciExp = cfb} : 'class_declaration))]]; @@ -1749,7 +1945,8 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (cfb : 'class_fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (cfb : 'class_fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (MLast.CeFun (loc, p, cfb) : 'class_fun_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm @@ -1758,13 +1955,14 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (ct : 'class_type) _ (loc : int * int) -> + (fun (ce : 'class_expr) _ (ct : 'class_type) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CeTyc (loc, ce, ct) : 'class_fun_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (loc : int * int) -> + (fun (ce : 'class_expr) _ (loc : Lexing.position * Lexing.position) -> (ce : 'class_fun_binding))]]; Grammar.Entry.obj (class_type_parameters : 'class_type_parameters Grammar.Entry.e), @@ -1778,22 +1976,26 @@ Grammar.extend Gramext.Stoken ("", ",")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (tpl : 'type_parameter list) _ (loc : int * int) -> + (fun _ (tpl : 'type_parameter list) _ + (loc : Lexing.position * Lexing.position) -> (loc, tpl : 'class_type_parameters)); [], Gramext.action - (fun (loc : int * int) -> (loc, [] : 'class_type_parameters))]]; + (fun (loc : Lexing.position * Lexing.position) -> + (loc, [] : 'class_type_parameters))]]; Grammar.Entry.obj (class_fun_def : 'class_fun_def Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "->"); Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (loc : int * int) -> (ce : 'class_fun_def)); + (fun (ce : 'class_expr) _ (loc : Lexing.position * Lexing.position) -> + (ce : 'class_fun_def)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (ce : 'class_fun_def) (p : 'ipatt) (loc : int * int) -> + (fun (ce : 'class_fun_def) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (MLast.CeFun (loc, p, ce) : 'class_fun_def))]]; Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e), None, [Some "top", None, @@ -1805,7 +2007,7 @@ Grammar.extend Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (ce : 'class_expr) _ (lb : 'let_binding list) - (rf : string option) _ (loc : int * int) -> + (rf : string option) _ (loc : Lexing.position * Lexing.position) -> (MLast.CeLet (loc, o2b rf, lb, ce) : 'class_expr)); [Gramext.Stoken ("", "fun"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); @@ -1813,25 +2015,30 @@ Grammar.extend (Grammar.Entry.obj (class_fun_def : 'class_fun_def Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_fun_def) (p : 'ipatt) _ (loc : int * int) -> + (fun (ce : 'class_fun_def) (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CeFun (loc, p, ce) : 'class_expr))]; Some "apply", Some Gramext.NonA, [[Gramext.Sself; Gramext.Snterml (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), "label")], Gramext.action - (fun (e : 'expr) (ce : 'class_expr) (loc : int * int) -> + (fun (e : 'expr) (ce : 'class_expr) + (loc : Lexing.position * Lexing.position) -> (MLast.CeApp (loc, ce, e) : 'class_expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (ce : 'class_expr) _ (loc : int * int) -> (ce : 'class_expr)); + (fun _ (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> + (ce : 'class_expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (ct : 'class_type) _ (ce : 'class_expr) _ (loc : int * int) -> + (fun _ (ct : 'class_type) _ (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CeTyc (loc, ce, ct) : 'class_expr)); [Gramext.Stoken ("", "object"); Gramext.Sopt @@ -1844,13 +2051,14 @@ Grammar.extend Gramext.Stoken ("", "end")], Gramext.action (fun _ (cf : 'class_structure) (cspo : 'class_self_patt option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CeStr (loc, cspo, cf) : 'class_expr)); [Gramext.Snterm (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (ci : 'class_longident) (loc : int * int) -> + (fun (ci : 'class_longident) + (loc : Lexing.position * Lexing.position) -> (MLast.CeCon (loc, ci, []) : 'class_expr)); [Gramext.Snterm (Grammar.Entry.obj @@ -1862,7 +2070,7 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (ctcl : 'ctyp list) _ (ci : 'class_longident) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CeCon (loc, ci, ctcl) : 'class_expr))]]; Grammar.Entry.obj (class_structure : 'class_structure Grammar.Entry.e), None, @@ -1874,10 +2082,11 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (cf : 'class_str_item) (loc : int * int) -> + (fun _ (cf : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (cf : 'e__6))])], Gramext.action - (fun (cf : 'e__6 list) (loc : int * int) -> + (fun (cf : 'e__6 list) (loc : Lexing.position * Lexing.position) -> (cf : 'class_structure))]]; Grammar.Entry.obj (class_self_patt : 'class_self_patt Grammar.Entry.e), None, @@ -1888,27 +2097,30 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (MLast.PaTyc (loc, p, t) : 'class_self_patt)); [Gramext.Stoken ("", "("); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p : 'patt) _ (loc : int * int) -> (p : 'class_self_patt))]]; + (fun _ (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'class_self_patt))]]; Grammar.Entry.obj (class_str_item : 'class_str_item Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "initializer"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (se : 'expr) _ (loc : int * int) -> + (fun (se : 'expr) _ (loc : Lexing.position * Lexing.position) -> (MLast.CrIni (loc, se) : 'class_str_item)); [Gramext.Stoken ("", "type"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CrCtr (loc, t1, t2) : 'class_str_item)); [Gramext.Stoken ("", "method"); Gramext.Sopt (Gramext.Stoken ("", "private")); @@ -1920,7 +2132,7 @@ Grammar.extend (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action (fun (e : 'fun_binding) (topt : 'polyt option) (l : 'label) - (pf : string option) _ (loc : int * int) -> + (pf : string option) _ (loc : Lexing.position * Lexing.position) -> (MLast.CrMth (loc, l, o2b pf, e, topt) : 'class_str_item)); [Gramext.Stoken ("", "method"); Gramext.Stoken ("", "virtual"); Gramext.Sopt (Gramext.Stoken ("", "private")); @@ -1929,7 +2141,7 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (l : 'label) (pf : string option) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CrVir (loc, l, o2b pf, t) : 'class_str_item)); [Gramext.Stoken ("", "value"); Gramext.Sopt (Gramext.Stoken ("", "mutable")); @@ -1939,7 +2151,7 @@ Grammar.extend (cvalue_binding : 'cvalue_binding Grammar.Entry.e))], Gramext.action (fun (e : 'cvalue_binding) (lab : 'label) (mf : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CrVal (loc, lab, o2b mf, e) : 'class_str_item)); [Gramext.Stoken ("", "inherit"); Gramext.Snterm @@ -1949,7 +2161,7 @@ Grammar.extend (Grammar.Entry.obj (as_lident : 'as_lident Grammar.Entry.e)))], Gramext.action (fun (pb : 'as_lident option) (ce : 'class_expr) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CrInh (loc, ce, pb) : 'class_str_item)); [Gramext.Stoken ("", "declare"); Gramext.Slist0 @@ -1959,22 +2171,27 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'class_str_item) (loc : int * int) -> + (fun _ (s : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__7))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'e__7 list) _ (loc : int * int) -> + (fun _ (st : 'e__7 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CrDcl (loc, st) : 'class_str_item))]]; Grammar.Entry.obj (as_lident : 'as_lident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "as"); Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) _ (loc : int * int) -> (i : 'as_lident))]]; + (fun (i : string) _ (loc : Lexing.position * Lexing.position) -> + (i : 'as_lident))]]; Grammar.Entry.obj (polyt : 'polyt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], - Gramext.action (fun (t : 'ctyp) _ (loc : int * int) -> (t : 'polyt))]]; + Gramext.action + (fun (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'polyt))]]; Grammar.Entry.obj (cvalue_binding : 'cvalue_binding Grammar.Entry.e), None, [None, None, @@ -1983,7 +2200,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExCoe (loc, e, None, t) : 'cvalue_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); @@ -1992,23 +2210,28 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t2 : 'ctyp) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t2 : 'ctyp) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExCoe (loc, e, Some t, t2) : 'cvalue_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExTyc (loc, e, t) : 'cvalue_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'cvalue_binding))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'cvalue_binding))]]; Grammar.Entry.obj (label : 'label Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], - Gramext.action (fun (i : string) (loc : int * int) -> (i : 'label))]]; + Gramext.action + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (i : 'label))]]; Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "object"); @@ -2023,18 +2246,20 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (csf : 'class_sig_item) (loc : int * int) -> + (fun _ (csf : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (csf : 'e__8))]); Gramext.Stoken ("", "end")], Gramext.action (fun _ (csf : 'e__8 list) (cst : 'class_self_type option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CtSig (loc, cst, csf) : 'class_type)); [Gramext.Snterm (Grammar.Entry.obj (clty_longident : 'clty_longident Grammar.Entry.e))], Gramext.action - (fun (id : 'clty_longident) (loc : int * int) -> + (fun (id : 'clty_longident) + (loc : Lexing.position * Lexing.position) -> (MLast.CtCon (loc, id, []) : 'class_type)); [Gramext.Snterm (Grammar.Entry.obj @@ -2045,13 +2270,15 @@ Grammar.extend Gramext.Stoken ("", ",")); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (tl : 'ctyp list) _ (id : 'clty_longident) (loc : int * int) -> + (fun _ (tl : 'ctyp list) _ (id : 'clty_longident) + (loc : Lexing.position * Lexing.position) -> (MLast.CtCon (loc, id, tl) : 'class_type)); [Gramext.Stoken ("", "["); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", "]"); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (ct : 'class_type) _ _ (t : 'ctyp) _ (loc : int * int) -> + (fun (ct : 'class_type) _ _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CtFun (loc, t, ct) : 'class_type))]]; Grammar.Entry.obj (class_self_type : 'class_self_type Grammar.Entry.e), None, @@ -2060,7 +2287,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (loc : int * int) -> (t : 'class_self_type))]]; + (fun _ (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'class_self_type))]]; Grammar.Entry.obj (class_sig_item : 'class_sig_item Grammar.Entry.e), None, [None, None, @@ -2069,7 +2297,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CgCtr (loc, t1, t2) : 'class_sig_item)); [Gramext.Stoken ("", "method"); Gramext.Sopt (Gramext.Stoken ("", "private")); @@ -2078,7 +2307,7 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (l : 'label) (pf : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CgMth (loc, l, o2b pf, t) : 'class_sig_item)); [Gramext.Stoken ("", "method"); Gramext.Stoken ("", "virtual"); Gramext.Sopt (Gramext.Stoken ("", "private")); @@ -2087,7 +2316,7 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (l : 'label) (pf : string option) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CgVir (loc, l, o2b pf, t) : 'class_sig_item)); [Gramext.Stoken ("", "value"); Gramext.Sopt (Gramext.Stoken ("", "mutable")); @@ -2096,13 +2325,13 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (l : 'label) (mf : string option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.CgVal (loc, l, o2b mf, t) : 'class_sig_item)); [Gramext.Stoken ("", "inherit"); Gramext.Snterm (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action - (fun (cs : 'class_type) _ (loc : int * int) -> + (fun (cs : 'class_type) _ (loc : Lexing.position * Lexing.position) -> (MLast.CgInh (loc, cs) : 'class_sig_item)); [Gramext.Stoken ("", "declare"); Gramext.Slist0 @@ -2112,11 +2341,13 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'class_sig_item) (loc : int * int) -> + (fun _ (s : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__9))]); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'e__9 list) _ (loc : int * int) -> + (fun _ (st : 'e__9 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.CgDcl (loc, st) : 'class_sig_item))]]; Grammar.Entry.obj (class_description : 'class_description Grammar.Entry.e), @@ -2132,7 +2363,7 @@ Grammar.extend (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action (fun (ct : 'class_type) _ (ctp : 'class_type_parameters) (n : string) - (vf : string option) (loc : int * int) -> + (vf : string option) (loc : Lexing.position * Lexing.position) -> ({MLast.ciLoc = loc; MLast.ciVir = o2b vf; MLast.ciPrm = ctp; MLast.ciNam = n; MLast.ciExp = ct} : 'class_description))]]; @@ -2150,7 +2381,7 @@ Grammar.extend (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action (fun (cs : 'class_type) _ (ctp : 'class_type_parameters) (n : string) - (vf : string option) (loc : int * int) -> + (vf : string option) (loc : Lexing.position * Lexing.position) -> ({MLast.ciLoc = loc; MLast.ciVir = o2b vf; MLast.ciPrm = ctp; MLast.ciNam = n; MLast.ciExp = cs} : 'class_type_declaration))]]; @@ -2162,7 +2393,8 @@ Grammar.extend (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (i : 'class_longident) _ (loc : int * int) -> + (fun (i : 'class_longident) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExNew (loc, i) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "."), @@ -2170,7 +2402,8 @@ Grammar.extend [[Gramext.Sself; Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e))], Gramext.action - (fun (lab : 'label) _ (e : 'expr) (loc : int * int) -> + (fun (lab : 'label) _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> (MLast.ExSnd (loc, e, lab) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -2182,13 +2415,15 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", ">}")], Gramext.action - (fun _ (fel : 'field_expr list) _ (loc : int * int) -> + (fun _ (fel : 'field_expr list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExOvr (loc, fel) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":>"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExCoe (loc, e, None, t) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); @@ -2196,7 +2431,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t2 : 'ctyp) _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t2 : 'ctyp) _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExCoe (loc, e, Some t, t2) : 'expr))]]; Grammar.Entry.obj (field_expr : 'field_expr Grammar.Entry.e), None, [None, None, @@ -2204,65 +2440,120 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (l : 'label) (loc : int * int) -> + (fun (e : 'expr) _ (l : 'label) + (loc : Lexing.position * Lexing.position) -> (l, e : 'field_expr))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("", "<"); - Gramext.Slist0sep - (Gramext.Snterm (Grammar.Entry.obj (field : 'field Grammar.Entry.e)), - Gramext.Stoken ("", ";")); - Gramext.Sopt (Gramext.Stoken ("", "..")); Gramext.Stoken ("", ">")], + [[Gramext.Stoken ("", "<"); Gramext.Stoken ("", ">")], + Gramext.action + (fun _ _ (loc : Lexing.position * Lexing.position) -> + (MLast.TyObj (loc, [], false) : 'ctyp)); + [Gramext.Stoken ("", "<"); + Gramext.Snterm + (Grammar.Entry.obj (meth_list : 'meth_list Grammar.Entry.e)); + Gramext.Stoken ("", ">")], Gramext.action - (fun _ (v : string option) (ml : 'field list) _ (loc : int * int) -> - (MLast.TyObj (loc, ml, o2b v) : 'ctyp)); + (fun _ (ml, v : 'meth_list) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.TyObj (loc, ml, v) : 'ctyp)); [Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (id : 'class_longident) _ (loc : int * int) -> + (fun (id : 'class_longident) _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyCls (loc, id) : 'ctyp))]]; + Grammar.Entry.obj (meth_list : 'meth_list Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("", "..")], + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + ([], true : 'meth_list)); + [Gramext.Snterm (Grammar.Entry.obj (field : 'field Grammar.Entry.e))], + Gramext.action + (fun (f : 'field) (loc : Lexing.position * Lexing.position) -> + ([f], false : 'meth_list)); + [Gramext.Snterm (Grammar.Entry.obj (field : 'field Grammar.Entry.e)); + Gramext.Stoken ("", ";")], + Gramext.action + (fun _ (f : 'field) (loc : Lexing.position * Lexing.position) -> + ([f], false : 'meth_list)); + [Gramext.Snterm (Grammar.Entry.obj (field : 'field Grammar.Entry.e)); + Gramext.Stoken ("", ";"); Gramext.Sself], + Gramext.action + (fun (ml, v : 'meth_list) _ (f : 'field) + (loc : Lexing.position * Lexing.position) -> + (f :: ml, v : 'meth_list))]]; Grammar.Entry.obj (field : 'field Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (lab : string) (loc : int * int) -> + (fun (t : 'ctyp) _ (lab : string) + (loc : Lexing.position * Lexing.position) -> (lab, t : 'field))]]; Grammar.Entry.obj (typevar : 'typevar Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> (i : 'typevar))]]; + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> + (i : 'typevar))]]; Grammar.Entry.obj (clty_longident : 'clty_longident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> ([i] : 'clty_longident)); + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + ([i] : 'clty_longident)); [Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (l : 'clty_longident) _ (m : string) (loc : int * int) -> + (fun (l : 'clty_longident) _ (m : string) + (loc : Lexing.position * Lexing.position) -> (m :: l : 'clty_longident))]]; Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> ([i] : 'class_longident)); + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + ([i] : 'class_longident)); [Gramext.Stoken ("UIDENT", ""); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (l : 'class_longident) _ (m : string) (loc : int * int) -> + (fun (l : 'class_longident) _ (m : string) + (loc : Lexing.position * Lexing.position) -> (m :: l : 'class_longident))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); + [[Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", ">"); + Gramext.Slist1 + (Gramext.Snterm + (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e))); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (ntl : 'name_tag list) _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.TyVrn (loc, rfl, Some (Some ntl)) : 'ctyp)); + [Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.TyVrn (loc, rfl, Some (Some [])) : 'ctyp)); + [Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); Gramext.Snterm (Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e)); @@ -2273,7 +2564,7 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (ntl : 'name_tag list) _ (rfl : 'row_field_list) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some (Some ntl)) : 'ctyp)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); Gramext.Snterm @@ -2281,7 +2572,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some (Some [])) : 'ctyp)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", ">"); Gramext.Snterm @@ -2289,7 +2581,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some None) : 'ctyp)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "="); Gramext.Snterm @@ -2297,7 +2590,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, None) : 'ctyp))]]; Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e), None, @@ -2307,13 +2601,15 @@ Grammar.extend (Grammar.Entry.obj (row_field : 'row_field Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (rfl : 'row_field list) (loc : int * int) -> + (fun (rfl : 'row_field list) + (loc : Lexing.position * Lexing.position) -> (rfl : 'row_field_list))]]; Grammar.Entry.obj (row_field : 'row_field Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) (loc : int * int) -> (MLast.RfInh t : 'row_field)); + (fun (t : 'ctyp) (loc : Lexing.position * Lexing.position) -> + (MLast.RfInh t : 'row_field)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e)); Gramext.Stoken ("", "of"); Gramext.Sopt (Gramext.Stoken ("", "&")); @@ -2322,19 +2618,20 @@ Grammar.extend Gramext.Stoken ("", "&"))], Gramext.action (fun (l : 'ctyp list) (ao : string option) _ (i : 'ident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.RfTag (i, o2b ao, l) : 'row_field)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.RfTag (i, true, []) : 'row_field))]]; Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> (i : 'name_tag))]]; + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> + (i : 'name_tag))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, @@ -2347,11 +2644,11 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'patt_tcon) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, "", Some (p, eo)) : 'patt)); [Gramext.Stoken ("QUESTIONIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, None) : 'patt)); [Gramext.Stoken ("OPTLABEL", ""); Gramext.Stoken ("", "("); Gramext.Snterm @@ -2362,7 +2659,7 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'patt_tcon) _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, Some (p, eo)) : 'patt)); [Gramext.Stoken ("QUESTIONIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Stoken ("", "("); @@ -2374,41 +2671,46 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'patt_tcon) _ _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, Some (p, eo)) : 'patt)); [Gramext.Stoken ("TILDEIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, None) : 'patt)); [Gramext.Stoken ("LABEL", ""); Gramext.Sself], Gramext.action - (fun (p : 'patt) (i : string) (loc : int * int) -> + (fun (p : 'patt) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, Some p) : 'patt)); [Gramext.Stoken ("TILDEIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (p : 'patt) _ (i : string) (loc : int * int) -> + (fun (p : 'patt) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, Some p) : 'patt)); [Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (sl : 'mod_ident) _ (loc : int * int) -> + (fun (sl : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaTyp (loc, sl) : 'patt)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (s : 'ident) _ (loc : int * int) -> + (fun (s : 'ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.PaVrn (loc, s) : 'patt))]]; Grammar.Entry.obj (patt_tcon : 'patt_tcon Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], - Gramext.action (fun (p : 'patt) (loc : int * int) -> (p : 'patt_tcon)); + Gramext.action + (fun (p : 'patt) (loc : Lexing.position * Lexing.position) -> + (p : 'patt_tcon)); [Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (p : 'patt) (loc : int * int) -> + (fun (t : 'ctyp) _ (p : 'patt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaTyc (loc, p, t) : 'patt_tcon))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, @@ -2421,11 +2723,11 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'ipatt_tcon) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, "", Some (p, eo)) : 'ipatt)); [Gramext.Stoken ("QUESTIONIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, None) : 'ipatt)); [Gramext.Stoken ("OPTLABEL", ""); Gramext.Stoken ("", "("); Gramext.Snterm @@ -2436,7 +2738,7 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'ipatt_tcon) _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, Some (p, eo)) : 'ipatt)); [Gramext.Stoken ("QUESTIONIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Stoken ("", "("); @@ -2448,66 +2750,75 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'eq_expr option) (p : 'ipatt_tcon) _ _ (i : string) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.PaOlb (loc, i, Some (p, eo)) : 'ipatt)); [Gramext.Stoken ("TILDEIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, None) : 'ipatt)); [Gramext.Stoken ("LABEL", ""); Gramext.Sself], Gramext.action - (fun (p : 'ipatt) (i : string) (loc : int * int) -> + (fun (p : 'ipatt) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, Some p) : 'ipatt)); [Gramext.Stoken ("TILDEIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (p : 'ipatt) _ (i : string) (loc : int * int) -> + (fun (p : 'ipatt) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.PaLab (loc, i, Some p) : 'ipatt))]]; Grammar.Entry.obj (ipatt_tcon : 'ipatt_tcon Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e))], Gramext.action - (fun (p : 'ipatt) (loc : int * int) -> (p : 'ipatt_tcon)); + (fun (p : 'ipatt) (loc : Lexing.position * Lexing.position) -> + (p : 'ipatt_tcon)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (p : 'ipatt) (loc : int * int) -> + (fun (t : 'ctyp) _ (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (MLast.PaTyc (loc, p, t) : 'ipatt_tcon))]]; Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'eq_expr))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'eq_expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.After "apply"), [Some "label", Some Gramext.NonA, [[Gramext.Stoken ("QUESTIONIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExOlb (loc, i, None) : 'expr)); [Gramext.Stoken ("OPTLABEL", ""); Gramext.Sself], Gramext.action - (fun (e : 'expr) (i : string) (loc : int * int) -> + (fun (e : 'expr) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.ExOlb (loc, i, Some e) : 'expr)); [Gramext.Stoken ("QUESTIONIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (i : string) (loc : int * int) -> + (fun (e : 'expr) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.ExOlb (loc, i, Some e) : 'expr)); [Gramext.Stoken ("TILDEIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.ExLab (loc, i, None) : 'expr)); [Gramext.Stoken ("LABEL", ""); Gramext.Sself], Gramext.action - (fun (e : 'expr) (i : string) (loc : int * int) -> + (fun (e : 'expr) (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.ExLab (loc, i, Some e) : 'expr)); [Gramext.Stoken ("TILDEIDENT", ""); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (i : string) (loc : int * int) -> + (fun (e : 'expr) _ (i : string) + (loc : Lexing.position * Lexing.position) -> (MLast.ExLab (loc, i, Some e) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -2515,15 +2826,19 @@ Grammar.extend [[Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (s : 'ident) _ (loc : int * int) -> + (fun (s : 'ident) _ (loc : Lexing.position * Lexing.position) -> (MLast.ExVrn (loc, s) : 'expr))]]; Grammar.Entry.obj (direction_flag : 'direction_flag Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "downto")], - Gramext.action (fun _ (loc : int * int) -> (false : 'direction_flag)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (false : 'direction_flag)); [Gramext.Stoken ("", "to")], - Gramext.action (fun _ (loc : int * int) -> (true : 'direction_flag))]]; + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (true : 'direction_flag))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, @@ -2542,7 +2857,7 @@ Grammar.extend Gramext.Stoken ("", "|]")], Gramext.action (fun _ (ntl : 'name_tag list) _ (rfl : 'row_field_list) _ _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some (Some ntl)) : 'ctyp)); [Gramext.Stoken ("", "[|"); Gramext.Snterm @@ -2554,7 +2869,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some (Some [])) : 'ctyp)); [Gramext.Stoken ("", "[|"); Gramext.Snterm @@ -2566,7 +2882,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, Some None) : 'ctyp)); [Gramext.Stoken ("", "[|"); Gramext.Snterm @@ -2577,14 +2894,16 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (MLast.TyVrn (loc, rfl, None) : 'ctyp))]]; Grammar.Entry.obj (warning_variant : 'warning_variant Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (warn_variant loc : 'warning_variant))]]; + (fun (loc : Lexing.position * Lexing.position) -> + (warn_variant loc : 'warning_variant))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "top"), [None, None, @@ -2595,13 +2914,15 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__12))]); + (fun _ (e : 'expr) (loc : Lexing.position * Lexing.position) -> + (e : 'e__12))]); Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Stoken ("", "done")], Gramext.action - (fun _ _ (seq : 'e__12 list) _ (e : 'expr) _ (loc : int * int) -> + (fun _ _ (seq : 'e__12 list) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExWhi (loc, e, seq) : 'expr)); [Gramext.Stoken ("", "for"); Gramext.Stoken ("LIDENT", ""); Gramext.Stoken ("", "="); Gramext.Sself; @@ -2615,14 +2936,16 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__11))]); + (fun _ (e : 'expr) (loc : Lexing.position * Lexing.position) -> + (e : 'e__11))]); Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Stoken ("", "done")], Gramext.action (fun _ _ (seq : 'e__11 list) _ (e2 : 'expr) (df : 'direction_flag) - (e1 : 'expr) _ (i : string) _ (loc : int * int) -> + (e1 : 'expr) _ (i : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExFor (loc, i, e1, e2, df, seq) : 'expr)); [Gramext.Stoken ("", "do"); Gramext.Slist0 @@ -2631,21 +2954,23 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__10))]); + (fun _ (e : 'expr) (loc : Lexing.position * Lexing.position) -> + (e : 'e__10))]); Gramext.Stoken ("", "return"); Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ _ (seq : 'e__10 list) _ (loc : int * int) -> + (fun (e : 'expr) _ _ (seq : 'e__10 list) _ + (loc : Lexing.position * Lexing.position) -> (MLast.ExSeq (loc, append_elem seq e) : 'expr))]]; Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> + (fun (loc : Lexing.position * Lexing.position) -> (warn_sequence loc : 'warning_sequence))]]]);; Grammar.extend @@ -2666,20 +2991,23 @@ Grammar.extend [Grammar.Entry.obj (interf : 'interf Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("EOI", "")], - Gramext.action (fun _ (loc : int * int) -> ([], false : 'interf)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + ([], false : 'interf)); [Gramext.Snterm (Grammar.Entry.obj (sig_item_semi : 'sig_item_semi Grammar.Entry.e)); Gramext.Sself], Gramext.action (fun (sil, stopped : 'interf) (si : 'sig_item_semi) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (si :: sil, stopped : 'interf)); [Gramext.Stoken ("", "#"); Gramext.Stoken ("LIDENT", ""); Gramext.Sopt (Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (dp : 'expr option) (n : string) _ (loc : int * int) -> + (fun _ (dp : 'expr option) (n : string) _ + (loc : Lexing.position * Lexing.position) -> ([MLast.SgDir (loc, n, dp), loc], true : 'interf))]]; Grammar.Entry.obj (sig_item_semi : 'sig_item_semi Grammar.Entry.e), None, [None, None, @@ -2687,25 +3015,28 @@ Grammar.extend (Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (si : 'sig_item) (loc : int * int) -> + (fun _ (si : 'sig_item) (loc : Lexing.position * Lexing.position) -> (si, loc : 'sig_item_semi))]]; Grammar.Entry.obj (implem : 'implem Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("EOI", "")], - Gramext.action (fun _ (loc : int * int) -> ([], false : 'implem)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + ([], false : 'implem)); [Gramext.Snterm (Grammar.Entry.obj (str_item_semi : 'str_item_semi Grammar.Entry.e)); Gramext.Sself], Gramext.action (fun (sil, stopped : 'implem) (si : 'str_item_semi) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (si :: sil, stopped : 'implem)); [Gramext.Stoken ("", "#"); Gramext.Stoken ("LIDENT", ""); Gramext.Sopt (Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (dp : 'expr option) (n : string) _ (loc : int * int) -> + (fun _ (dp : 'expr option) (n : string) _ + (loc : Lexing.position * Lexing.position) -> ([MLast.StDir (loc, n, dp), loc], true : 'implem))]]; Grammar.Entry.obj (str_item_semi : 'str_item_semi Grammar.Entry.e), None, [None, None, @@ -2713,32 +3044,38 @@ Grammar.extend (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (si : 'str_item) (loc : int * int) -> + (fun _ (si : 'str_item) (loc : Lexing.position * Lexing.position) -> (si, loc : 'str_item_semi))]]; Grammar.Entry.obj (top_phrase : 'top_phrase Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("EOI", "")], - Gramext.action (fun _ (loc : int * int) -> (None : 'top_phrase)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + (None : 'top_phrase)); [Gramext.Snterm (Grammar.Entry.obj (phrase : 'phrase Grammar.Entry.e))], Gramext.action - (fun (ph : 'phrase) (loc : int * int) -> (Some ph : 'top_phrase))]]; + (fun (ph : 'phrase) (loc : Lexing.position * Lexing.position) -> + (Some ph : 'top_phrase))]]; Grammar.Entry.obj (use_file : 'use_file Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("EOI", "")], - Gramext.action (fun _ (loc : int * int) -> ([], false : 'use_file)); + Gramext.action + (fun _ (loc : Lexing.position * Lexing.position) -> + ([], false : 'use_file)); [Gramext.Snterm (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";"); Gramext.Sself], Gramext.action (fun (sil, stopped : 'use_file) _ (si : 'str_item) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (si :: sil, stopped : 'use_file)); [Gramext.Stoken ("", "#"); Gramext.Stoken ("LIDENT", ""); Gramext.Sopt (Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (dp : 'expr option) (n : string) _ (loc : int * int) -> + (fun _ (dp : 'expr option) (n : string) _ + (loc : Lexing.position * Lexing.position) -> ([MLast.StDir (loc, n, dp)], true : 'use_file))]]; Grammar.Entry.obj (phrase : 'phrase Grammar.Entry.e), None, [None, None, @@ -2746,20 +3083,22 @@ Grammar.extend (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (sti : 'str_item) (loc : int * int) -> (sti : 'phrase)); + (fun _ (sti : 'str_item) (loc : Lexing.position * Lexing.position) -> + (sti : 'phrase)); [Gramext.Stoken ("", "#"); Gramext.Stoken ("LIDENT", ""); Gramext.Sopt (Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (dp : 'expr option) (n : string) _ (loc : int * int) -> + (fun _ (dp : 'expr option) (n : string) _ + (loc : Lexing.position * Lexing.position) -> (MLast.StDir (loc, n, dp) : 'phrase))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("QUOTATION", "")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) (loc : Lexing.position * Lexing.position) -> (let x = try let i = String.index x ':' in @@ -2772,14 +3111,16 @@ Grammar.extend 'expr)); [Gramext.Stoken ("LOCATE", "")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) (loc : Lexing.position * Lexing.position) -> (let x = try let i = String.index x ':' in - int_of_string (String.sub x 0 i), + {(Lexing.dummy_pos) with + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1) with - Not_found | Failure _ -> 0, x + Not_found | Failure _ -> + {(Lexing.dummy_pos) with Lexing.pos_cnum = 0}, x in Pcaml.handle_expr_locate loc x : 'expr))]]; @@ -2788,7 +3129,7 @@ Grammar.extend [None, None, [[Gramext.Stoken ("QUOTATION", "")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) (loc : Lexing.position * Lexing.position) -> (let x = try let i = String.index x ':' in @@ -2801,14 +3142,16 @@ Grammar.extend 'patt)); [Gramext.Stoken ("LOCATE", "")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) (loc : Lexing.position * Lexing.position) -> (let x = try let i = String.index x ':' in - int_of_string (String.sub x 0 i), + {(Lexing.dummy_pos) with + Lexing.pos_cnum = int_of_string (String.sub x 0 i)}, String.sub x (i + 1) (String.length x - i - 1) with - Not_found | Failure _ -> 0, x + Not_found | Failure _ -> + {(Lexing.dummy_pos) with Lexing.pos_cnum = 0}, x in Pcaml.handle_patt_locate loc x : 'patt))]]]);; diff --git a/camlp4/ocaml_src/meta/pa_rp.ml b/camlp4/ocaml_src/meta/pa_rp.ml index ad743e8708..80d49d6e16 100644 --- a/camlp4/ocaml_src/meta/pa_rp.ml +++ b/camlp4/ocaml_src/meta/pa_rp.ml @@ -487,7 +487,7 @@ Grammar.extend (Grammar.Entry.obj (parser_case : 'parser_case Grammar.Entry.e))], Gramext.action (fun (pc : 'parser_case) (po : 'ipatt option) _ _ (e : 'expr) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (cparser_match loc e po [pc] : 'expr)); [Gramext.Stoken ("", "match"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Stoken ("", "parser"); @@ -502,7 +502,7 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (pcl : 'parser_case list) _ (po : 'ipatt option) _ _ - (e : 'expr) _ (loc : int * int) -> + (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (cparser_match loc e po pcl : 'expr)); [Gramext.Stoken ("", "parser"); Gramext.Sopt @@ -511,7 +511,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (parser_case : 'parser_case Grammar.Entry.e))], Gramext.action - (fun (pc : 'parser_case) (po : 'ipatt option) _ (loc : int * int) -> + (fun (pc : 'parser_case) (po : 'ipatt option) _ + (loc : Lexing.position * Lexing.position) -> (cparser loc po [pc] : 'expr)); [Gramext.Stoken ("", "parser"); Gramext.Sopt @@ -525,7 +526,7 @@ Grammar.extend Gramext.Stoken ("", "]")], Gramext.action (fun _ (pcl : 'parser_case list) _ (po : 'ipatt option) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (cparser loc po pcl : 'expr))]]; Grammar.Entry.obj (parser_case : 'parser_case Grammar.Entry.e), None, [None, None, @@ -540,11 +541,14 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action (fun (e : 'expr) _ (po : 'ipatt option) _ (sp : 'stream_patt) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (sp, po, e : 'parser_case))]]; Grammar.Entry.obj (stream_patt : 'stream_patt Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> ([] : 'stream_patt)); + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + ([] : 'stream_patt)); [Gramext.Snterm (Grammar.Entry.obj (stream_patt_comp : 'stream_patt_comp Grammar.Entry.e)); @@ -557,13 +561,14 @@ Grammar.extend Gramext.Stoken ("", ";"))], Gramext.action (fun (sp : 'stream_patt_comp_err list) _ (spc : 'stream_patt_comp) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> ((spc, None) :: sp : 'stream_patt)); [Gramext.Snterm (Grammar.Entry.obj (stream_patt_comp : 'stream_patt_comp Grammar.Entry.e))], Gramext.action - (fun (spc : 'stream_patt_comp) (loc : int * int) -> + (fun (spc : 'stream_patt_comp) + (loc : Lexing.position * Lexing.position) -> ([spc, None] : 'stream_patt))]]; Grammar.Entry.obj (stream_patt_comp_err : 'stream_patt_comp_err Grammar.Entry.e), @@ -578,23 +583,25 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'e__1))])], + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'e__1))])], Gramext.action (fun (eo : 'e__1 option) (spc : 'stream_patt_comp) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (spc, eo : 'stream_patt_comp_err))]]; Grammar.Entry.obj (stream_patt_comp : 'stream_patt_comp Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) (loc : int * int) -> + (fun (p : 'patt) (loc : Lexing.position * Lexing.position) -> (SpStr (loc, p) : 'stream_patt_comp)); [Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (p : 'patt) (loc : int * int) -> + (fun (e : 'expr) _ (p : 'patt) + (loc : Lexing.position * Lexing.position) -> (SpNtr (loc, p, e) : 'stream_patt_comp)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); @@ -604,15 +611,17 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'e__2))])], + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'e__2))])], Gramext.action - (fun (eo : 'e__2 option) (p : 'patt) _ (loc : int * int) -> + (fun (eo : 'e__2 option) (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (SpTrm (loc, p, eo) : 'stream_patt_comp))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> + (fun (i : string) (loc : Lexing.position * Lexing.position) -> (MLast.PaLid (loc, i) : 'ipatt))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -625,17 +634,18 @@ Grammar.extend Gramext.Stoken ("", ";")); Gramext.Stoken ("", ":]")], Gramext.action - (fun _ (se : 'stream_expr_comp list) _ (loc : int * int) -> + (fun _ (se : 'stream_expr_comp list) _ + (loc : Lexing.position * Lexing.position) -> (cstream loc se : 'expr))]]; Grammar.Entry.obj (stream_expr_comp : 'stream_expr_comp Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) (loc : int * int) -> + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> (SeNtr (loc, e) : 'stream_expr_comp)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (SeTrm (loc, e) : 'stream_expr_comp))]]]);; diff --git a/camlp4/ocaml_src/meta/q_MLast.ml b/camlp4/ocaml_src/meta/q_MLast.ml index 70540af642..dac10349dd 100644 --- a/camlp4/ocaml_src/meta/q_MLast.ml +++ b/camlp4/ocaml_src/meta/q_MLast.ml @@ -30,7 +30,12 @@ module Qast = | Loc | Antiquot of MLast.loc * string ;; - let loc = 0, 0;; + let loc = + let nowhere = + {(Lexing.dummy_pos) with Lexing.pos_lnum = 1; Lexing.pos_cnum = 0} + in + nowhere, nowhere + ;; let rec to_expr = function Node (n, al) -> @@ -66,7 +71,9 @@ module Qast = let e = try Grammar.Entry.parse Pcaml.expr_eoi (Stream.of_string s) with Stdpp.Exc_located ((bp, ep), exc) -> - raise (Stdpp.Exc_located ((fst loc + bp, fst loc + ep), exc)) + raise + (Stdpp.Exc_located + (Reloc.adjust_loc (fst loc) (bp, ep), exc)) in MLast.ExAnt (loc, e) and to_expr_label (l, a) = @@ -106,7 +113,9 @@ module Qast = let p = try Grammar.Entry.parse Pcaml.patt_eoi (Stream.of_string s) with Stdpp.Exc_located ((bp, ep), exc) -> - raise (Stdpp.Exc_located ((fst loc + bp, fst loc + ep), exc)) + raise + (Stdpp.Exc_located + (Reloc.adjust_loc (fst loc) (bp, ep), exc)) in MLast.PaAnt (loc, p) and to_patt_label (l, a) = @@ -121,7 +130,7 @@ let antiquot k (bp, ep) x = if k = "" then String.length "$" else String.length "$" + String.length k + String.length ":" in - Qast.Antiquot ((shift + bp, shift + ep), x) + Qast.Antiquot ((Reloc.shift_pos shift bp, Reloc.shift_pos (-1) ep), x) ;; let sig_item = Grammar.Entry.create gram "signature item";; @@ -149,6 +158,9 @@ let a_opt = Grammar.Entry.create gram "a_opt";; let a_UIDENT = Grammar.Entry.create gram "a_UIDENT";; let a_LIDENT = Grammar.Entry.create gram "a_LIDENT";; let a_INT = Grammar.Entry.create gram "a_INT";; +let a_INT32 = Grammar.Entry.create gram "a_INT32";; +let a_INT64 = Grammar.Entry.create gram "a_INT64";; +let a_NATIVEINT = Grammar.Entry.create gram "a__NATIVEINT";; let a_FLOAT = Grammar.Entry.create gram "a_FLOAT";; let a_STRING = Grammar.Entry.create gram "a_STRING";; let a_CHAR = Grammar.Entry.create gram "a_CHAR";; @@ -295,7 +307,7 @@ let warn_variant _ = if !not_yet_warned_variant then begin not_yet_warned_variant := false; - !(Pcaml.warning) (0, 1) + !(Pcaml.warning) (Lexing.dummy_pos, Reloc.shift_pos 1 Lexing.dummy_pos) (Printf.sprintf "use of syntax of variants types deprecated since version 3.05") end @@ -306,7 +318,7 @@ let warn_sequence _ = if !not_yet_warned_seq then begin not_yet_warned_seq := false; - !(Pcaml.warning) (0, 1) + !(Pcaml.warning) (Lexing.dummy_pos, Reloc.shift_pos 1 Lexing.dummy_pos) (Printf.sprintf "use of syntax of sequences deprecated since version 3.01.1") end @@ -438,18 +450,20 @@ Grammar.extend (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'str_item) (loc : int * int) -> + (fun _ (s : 'str_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__1))])], Gramext.action - (fun (a : 'e__1 list) (loc : int * int) -> + (fun (a : 'e__1 list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'a_list) _ (loc : int * int) -> + (fun _ (st : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeStr", [Qast.Loc; st]) : 'module_expr)); [Gramext.Stoken ("", "functor"); Gramext.Stoken ("", "("); Gramext.Snterm @@ -460,22 +474,25 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action (fun (me : 'module_expr) _ _ (t : 'module_type) _ (i : 'a_UIDENT) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeFun", [Qast.Loc; i; t; me]) : 'module_expr))]; None, None, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (me2 : 'module_expr) (me1 : 'module_expr) (loc : int * int) -> + (fun (me2 : 'module_expr) (me1 : 'module_expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeApp", [Qast.Loc; me1; me2]) : 'module_expr))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (me2 : 'module_expr) _ (me1 : 'module_expr) (loc : int * int) -> + (fun (me2 : 'module_expr) _ (me1 : 'module_expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeAcc", [Qast.Loc; me1; me2]) : 'module_expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (me : 'module_expr) _ (loc : int * int) -> + (fun _ (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (me : 'module_expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm @@ -483,18 +500,18 @@ Grammar.extend Gramext.Stoken ("", ")")], Gramext.action (fun _ (mt : 'module_type) _ (me : 'module_expr) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeTyc", [Qast.Loc; me; mt]) : 'module_expr)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeUid", [Qast.Loc; i]) : 'module_expr))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), None, [Some "top", None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) (loc : int * int) -> + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StExp", [Qast.Loc; e]) : 'str_item)); [Gramext.Stoken ("", "value"); Gramext.srules @@ -502,15 +519,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "rec")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__3))])], Gramext.action - (fun (a : 'e__3 option) (loc : int * int) -> + (fun (a : 'e__3 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist1sep (Gramext.Snterm @@ -518,14 +538,17 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (l : 'a_list) (r : 'a_opt) _ (loc : int * int) -> + (fun (l : 'a_list) (r : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StVal", [Qast.Loc; o2b r; l]) : 'str_item)); [Gramext.Stoken ("", "type"); Gramext.srules @@ -535,20 +558,22 @@ Grammar.extend (type_declaration : 'type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'type_declaration list) (loc : int * int) -> + (fun (a : 'type_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (tdl : 'a_list) _ (loc : int * int) -> + (fun (tdl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StTyp", [Qast.Loc; tdl]) : 'str_item)); [Gramext.Stoken ("", "open"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (i : 'mod_ident) _ (loc : int * int) -> + (fun (i : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StOpn", [Qast.Loc; i]) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "type"); Gramext.Snterm @@ -557,7 +582,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (i : 'a_UIDENT) _ _ (loc : int * int) -> + (fun (mt : 'module_type) _ (i : 'a_UIDENT) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StMty", [Qast.Loc; i; mt]) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "rec"); Gramext.srules @@ -568,14 +594,17 @@ Grammar.extend 'module_rec_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'module_rec_binding list) (loc : int * int) -> + (fun (a : 'module_rec_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (nmtmes : 'a_list) _ _ (loc : int * int) -> + (fun (nmtmes : 'a_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StRecMod", [Qast.Loc; nmtmes]) : 'str_item)); [Gramext.Stoken ("", "module"); Gramext.Snterm @@ -584,13 +613,15 @@ Grammar.extend (Grammar.Entry.obj (module_binding : 'module_binding Grammar.Entry.e))], Gramext.action - (fun (mb : 'module_binding) (i : 'a_UIDENT) _ (loc : int * int) -> + (fun (mb : 'module_binding) (i : 'a_UIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StMod", [Qast.Loc; i; mb]) : 'str_item)); [Gramext.Stoken ("", "include"); Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (loc : int * int) -> + (fun (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StInc", [Qast.Loc; me]) : 'str_item)); [Gramext.Stoken ("", "external"); Gramext.Snterm @@ -603,15 +634,17 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (a_STRING : 'a_STRING Grammar.Entry.e)))], Gramext.action - (fun (a : 'a_STRING list) (loc : int * int) -> + (fun (a : 'a_STRING list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action (fun (pd : 'a_list) _ (t : 'ctyp) _ (i : 'a_LIDENT) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StExt", [Qast.Loc; i; t; pd]) : 'str_item)); [Gramext.Stoken ("", "exception"); Gramext.Snterm @@ -622,13 +655,11 @@ Grammar.extend (Grammar.Entry.obj (rebind_exn : 'rebind_exn Grammar.Entry.e))], Gramext.action (fun (b : 'rebind_exn) (ctl : 'constructor_declaration) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (let (_, c, tl) = match ctl with Qast.Tuple [xx1; xx2; xx3] -> xx1, xx2, xx3 - | _ -> - match () with - _ -> raise (Match_failure ("q_MLast.ml", 302, 19)) + | _ -> match () with _ -> raise (Match_failure ("", 308, 19)) in Qast.Node ("StExc", [Qast.Loc; c; tl; b]) : 'str_item)); @@ -641,28 +672,33 @@ Grammar.extend (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'str_item) (loc : int * int) -> + (fun _ (s : 'str_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__2))])], Gramext.action - (fun (a : 'e__2 list) (loc : int * int) -> + (fun (a : 'e__2 list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'a_list) _ (loc : int * int) -> + (fun _ (st : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StDcl", [Qast.Loc; st]) : 'str_item))]]; Grammar.Entry.obj (rebind_exn : 'rebind_exn Grammar.Entry.e), None, [None, None, [[], - Gramext.action (fun (loc : int * int) -> (Qast.List [] : 'rebind_exn)); + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.List [] : 'rebind_exn)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (sl : 'mod_ident) _ (loc : int * int) -> (sl : 'rebind_exn))]]; + (fun (sl : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> + (sl : 'rebind_exn))]]; Grammar.Entry.obj (module_binding : 'module_binding Grammar.Entry.e), None, [None, Some Gramext.RightA, @@ -670,7 +706,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (loc : int * int) -> + (fun (me : 'module_expr) _ + (loc : Lexing.position * Lexing.position) -> (me : 'module_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm @@ -679,7 +716,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (mt : 'module_type) _ (loc : int * int) -> + (fun (me : 'module_expr) _ (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeTyc", [Qast.Loc; me; mt]) : 'module_binding)); [Gramext.Stoken ("", "("); Gramext.Snterm @@ -690,7 +728,7 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Sself], Gramext.action (fun (mb : 'module_binding) _ (mt : 'module_type) _ (m : 'a_UIDENT) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MeFun", [Qast.Loc; m; mt; mb]) : 'module_binding))]]; Grammar.Entry.obj (module_rec_binding : 'module_rec_binding Grammar.Entry.e), @@ -706,7 +744,7 @@ Grammar.extend (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action (fun (me : 'module_expr) _ (mt : 'module_type) _ (m : 'a_UIDENT) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [m; me; mt] : 'module_rec_binding))]]; Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e), None, [None, None, @@ -717,7 +755,7 @@ Grammar.extend Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action (fun (mt : 'module_type) _ _ (t : 'module_type) _ (i : 'a_UIDENT) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtFun", [Qast.Loc; i; t; mt]) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "with"); @@ -728,14 +766,17 @@ Grammar.extend (with_constr : 'with_constr Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'with_constr list) (loc : int * int) -> + (fun (a : 'with_constr list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (wcl : 'a_list) _ (mt : 'module_type) (loc : int * int) -> + (fun (wcl : 'a_list) _ (mt : 'module_type) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtWit", [Qast.Loc; mt; wcl]) : 'module_type))]; None, None, [[Gramext.Stoken ("", "sig"); @@ -747,48 +788,53 @@ Grammar.extend (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'sig_item) (loc : int * int) -> + (fun _ (s : 'sig_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__4))])], Gramext.action - (fun (a : 'e__4 list) (loc : int * int) -> + (fun (a : 'e__4 list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (sg : 'a_list) _ (loc : int * int) -> + (fun _ (sg : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtSig", [Qast.Loc; sg]) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (m2 : 'module_type) (m1 : 'module_type) (loc : int * int) -> + (fun (m2 : 'module_type) (m1 : 'module_type) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtApp", [Qast.Loc; m1; m2]) : 'module_type))]; None, None, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (m2 : 'module_type) _ (m1 : 'module_type) (loc : int * int) -> + (fun (m2 : 'module_type) _ (m1 : 'module_type) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtAcc", [Qast.Loc; m1; m2]) : 'module_type))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (mt : 'module_type) _ (loc : int * int) -> + (fun _ (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (mt : 'module_type)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtQuo", [Qast.Loc; i]) : 'module_type)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtLid", [Qast.Loc; i]) : 'module_type)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtUid", [Qast.Loc; i]) : 'module_type))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [Some "top", None, @@ -798,7 +844,8 @@ Grammar.extend Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (i : 'a_LIDENT) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (i : 'a_LIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgVal", [Qast.Loc; i; t]) : 'sig_item)); [Gramext.Stoken ("", "type"); Gramext.srules @@ -808,20 +855,22 @@ Grammar.extend (type_declaration : 'type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'type_declaration list) (loc : int * int) -> + (fun (a : 'type_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (tdl : 'a_list) _ (loc : int * int) -> + (fun (tdl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgTyp", [Qast.Loc; tdl]) : 'sig_item)); [Gramext.Stoken ("", "open"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (i : 'mod_ident) _ (loc : int * int) -> + (fun (i : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgOpn", [Qast.Loc; i]) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "rec"); Gramext.srules @@ -832,14 +881,16 @@ Grammar.extend 'module_rec_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'module_rec_declaration list) (loc : int * int) -> + (fun (a : 'module_rec_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (mds : 'a_list) _ _ (loc : int * int) -> + (fun (mds : 'a_list) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgRecMod", [Qast.Loc; mds]) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Stoken ("", "type"); Gramext.Snterm @@ -848,7 +899,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (i : 'a_UIDENT) _ _ (loc : int * int) -> + (fun (mt : 'module_type) _ (i : 'a_UIDENT) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgMty", [Qast.Loc; i; mt]) : 'sig_item)); [Gramext.Stoken ("", "module"); Gramext.Snterm @@ -857,13 +909,15 @@ Grammar.extend (Grammar.Entry.obj (module_declaration : 'module_declaration Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_declaration) (i : 'a_UIDENT) _ (loc : int * int) -> + (fun (mt : 'module_declaration) (i : 'a_UIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgMod", [Qast.Loc; i; mt]) : 'sig_item)); [Gramext.Stoken ("", "include"); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (loc : int * int) -> + (fun (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgInc", [Qast.Loc; mt]) : 'sig_item)); [Gramext.Stoken ("", "external"); Gramext.Snterm @@ -876,15 +930,17 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (a_STRING : 'a_STRING Grammar.Entry.e)))], Gramext.action - (fun (a : 'a_STRING list) (loc : int * int) -> + (fun (a : 'a_STRING list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action (fun (pd : 'a_list) _ (t : 'ctyp) _ (i : 'a_LIDENT) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgExt", [Qast.Loc; i; t; pd]) : 'sig_item)); [Gramext.Stoken ("", "exception"); Gramext.Snterm @@ -892,13 +948,12 @@ Grammar.extend (constructor_declaration : 'constructor_declaration Grammar.Entry.e))], Gramext.action - (fun (ctl : 'constructor_declaration) _ (loc : int * int) -> + (fun (ctl : 'constructor_declaration) _ + (loc : Lexing.position * Lexing.position) -> (let (_, c, tl) = match ctl with Qast.Tuple [xx1; xx2; xx3] -> xx1, xx2, xx3 - | _ -> - match () with - _ -> raise (Match_failure ("q_MLast.ml", 360, 19)) + | _ -> match () with _ -> raise (Match_failure ("", 366, 19)) in Qast.Node ("SgExc", [Qast.Loc; c; tl]) : 'sig_item)); @@ -911,18 +966,20 @@ Grammar.extend (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'sig_item) (loc : int * int) -> + (fun _ (s : 'sig_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__5))])], Gramext.action - (fun (a : 'e__5 list) (loc : int * int) -> + (fun (a : 'e__5 list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'a_list) _ (loc : int * int) -> + (fun _ (st : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgDcl", [Qast.Loc; st]) : 'sig_item))]]; Grammar.Entry.obj (module_declaration : 'module_declaration Grammar.Entry.e), @@ -937,13 +994,14 @@ Grammar.extend Gramext.Stoken ("", ")"); Gramext.Sself], Gramext.action (fun (mt : 'module_declaration) _ (t : 'module_type) _ (i : 'a_UIDENT) - _ (loc : int * int) -> + _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("MtFun", [Qast.Loc; i; t; mt]) : 'module_declaration)); [Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (loc : int * int) -> + (fun (mt : 'module_type) _ + (loc : Lexing.position * Lexing.position) -> (mt : 'module_declaration))]]; Grammar.Entry.obj (module_rec_declaration : 'module_rec_declaration Grammar.Entry.e), @@ -955,7 +1013,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e))], Gramext.action - (fun (mt : 'module_type) _ (m : 'a_UIDENT) (loc : int * int) -> + (fun (mt : 'module_type) _ (m : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [m; mt] : 'module_rec_declaration))]]; Grammar.Entry.obj (with_constr : 'with_constr Grammar.Entry.e), None, [None, None, @@ -966,7 +1025,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e))], Gramext.action - (fun (me : 'module_expr) _ (i : 'mod_ident) _ (loc : int * int) -> + (fun (me : 'module_expr) _ (i : 'mod_ident) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("WcMod", [Qast.Loc; i; me]) : 'with_constr)); [Gramext.Stoken ("", "type"); Gramext.Snterm @@ -977,17 +1037,19 @@ Grammar.extend (Grammar.Entry.obj (type_parameter : 'type_parameter Grammar.Entry.e)))], Gramext.action - (fun (a : 'type_parameter list) (loc : int * int) -> + (fun (a : 'type_parameter list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action (fun (t : 'ctyp) _ (tpl : 'a_list) (i : 'mod_ident) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("WcTyp", [Qast.Loc; i; tpl; t]) : 'with_constr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), None, [Some "top", Some Gramext.RightA, @@ -997,7 +1059,8 @@ Grammar.extend (Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e)); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (seq : 'sequence) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (seq : 'sequence) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExWhi", [Qast.Loc; e; seq]) : 'expr)); [Gramext.Stoken ("", "for"); Gramext.Snterm @@ -1012,25 +1075,29 @@ Grammar.extend Gramext.Stoken ("", "}")], Gramext.action (fun _ (seq : 'sequence) _ _ (e2 : 'expr) (df : 'direction_flag) - (e1 : 'expr) _ (i : 'a_LIDENT) _ (loc : int * int) -> + (e1 : 'expr) _ (i : 'a_LIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFor", [Qast.Loc; i; e1; e2; df; seq]) : 'expr)); [Gramext.Stoken ("", "do"); Gramext.Stoken ("", "{"); Gramext.Snterm (Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e)); Gramext.Stoken ("", "}")], Gramext.action - (fun _ (seq : 'sequence) _ _ (loc : int * int) -> + (fun _ (seq : 'sequence) _ _ + (loc : Lexing.position * Lexing.position) -> (mksequence Qast.Loc seq : 'expr)); [Gramext.Stoken ("", "if"); Gramext.Sself; Gramext.Stoken ("", "then"); Gramext.Sself; Gramext.Stoken ("", "else"); Gramext.Sself], Gramext.action - (fun (e3 : 'expr) _ (e2 : 'expr) _ (e1 : 'expr) _ (loc : int * int) -> + (fun (e3 : 'expr) _ (e2 : 'expr) _ (e1 : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExIfe", [Qast.Loc; e1; e2; e3]) : 'expr)); [Gramext.Stoken ("", "try"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ (loc : int * int) -> + (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTry", [Qast.Loc; e; @@ -1045,22 +1112,26 @@ Grammar.extend (match_case : 'match_case Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'match_case list) (loc : int * int) -> + (fun (a : 'match_case list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'a_list) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (l : 'a_list) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTry", [Qast.Loc; e; l]) : 'expr)); [Gramext.Stoken ("", "match"); Gramext.Sself; Gramext.Stoken ("", "with"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ (loc : int * int) -> + (fun (e1 : 'expr) _ (p1 : 'ipatt) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExMat", [Qast.Loc; e; @@ -1075,22 +1146,26 @@ Grammar.extend (match_case : 'match_case Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'match_case list) (loc : int * int) -> + (fun (a : 'match_case list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'a_list) _ _ (e : 'expr) _ (loc : int * int) -> + (fun _ (l : 'a_list) _ _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExMat", [Qast.Loc; e; l]) : 'expr)); [Gramext.Stoken ("", "fun"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Snterm (Grammar.Entry.obj (fun_def : 'fun_def Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_def) (p : 'ipatt) _ (loc : int * int) -> + (fun (e : 'fun_def) (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFun", [Qast.Loc; Qast.List [Qast.Tuple [p; Qast.Option None; e]]]) : @@ -1103,15 +1178,17 @@ Grammar.extend (match_case : 'match_case Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'match_case list) (loc : int * int) -> + (fun (a : 'match_case list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (l : 'a_list) _ _ (loc : int * int) -> + (fun _ (l : 'a_list) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFun", [Qast.Loc; l]) : 'expr)); [Gramext.Stoken ("", "let"); Gramext.Stoken ("", "module"); Gramext.Snterm @@ -1122,7 +1199,7 @@ Grammar.extend Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (e : 'expr) _ (mb : 'module_binding) (m : 'a_UIDENT) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLmd", [Qast.Loc; m; mb; e]) : 'expr)); [Gramext.Stoken ("", "let"); Gramext.srules @@ -1130,15 +1207,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "rec")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__6))])], Gramext.action - (fun (a : 'e__6 option) (loc : int * int) -> + (fun (a : 'e__6 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist1sep (Gramext.Snterm @@ -1146,15 +1226,18 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action - (fun (x : 'expr) _ (l : 'a_list) (r : 'a_opt) _ (loc : int * int) -> + (fun (x : 'expr) _ (l : 'a_list) (r : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLet", [Qast.Loc; o2b r; l; x]) : 'expr))]; Some "where", None, [[Gramext.Sself; Gramext.Stoken ("", "where"); @@ -1163,32 +1246,37 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "rec")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__7))])], Gramext.action - (fun (a : 'e__7 option) (loc : int * int) -> + (fun (a : 'e__7 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (let_binding : 'let_binding Grammar.Entry.e))], Gramext.action (fun (lb : 'let_binding) (rf : 'a_opt) _ (e : 'expr) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLet", [Qast.Loc; o2b rf; Qast.List [lb]; e]) : 'expr))]; Some ":=", Some Gramext.NonA, [[Gramext.Sself; Gramext.Stoken ("", ":="); Gramext.Sself; Gramext.Snterm (Grammar.Entry.obj (dummy : 'dummy Grammar.Entry.e))], Gramext.action - (fun _ (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExAss", [Qast.Loc; e1; e2]) : 'expr))]; Some "||", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "||"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1201,7 +1289,8 @@ Grammar.extend Some "&&", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "&&"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1214,7 +1303,8 @@ Grammar.extend Some "<", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "!="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1226,7 +1316,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "=="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1238,7 +1329,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<>"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1250,7 +1342,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1262,7 +1355,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", ">="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1274,7 +1368,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<="); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1286,7 +1381,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", ">"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1298,7 +1394,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "<"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1311,7 +1408,8 @@ Grammar.extend Some "^", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "@"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1323,7 +1421,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "^"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1336,7 +1435,8 @@ Grammar.extend Some "+", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "-."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1348,7 +1448,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "+."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1360,7 +1461,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "-"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1372,7 +1474,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "+"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1385,7 +1488,8 @@ Grammar.extend Some "*", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "mod"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1397,7 +1501,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lxor"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1409,7 +1514,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lor"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1421,7 +1527,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "land"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1433,7 +1540,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "/."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1445,7 +1553,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "*."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1457,7 +1566,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "/"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1469,7 +1579,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "*"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1482,7 +1593,8 @@ Grammar.extend Some "**", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "lsr"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1494,7 +1606,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "lsl"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1506,7 +1619,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "asr"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1518,7 +1632,8 @@ Grammar.extend 'expr)); [Gramext.Sself; Gramext.Stoken ("", "**"); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; @@ -1531,44 +1646,48 @@ Grammar.extend Some "unary minus", Some Gramext.NonA, [[Gramext.Stoken ("", "-."); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (mkumin Qast.Loc (Qast.Str "-.") e : 'expr)); [Gramext.Stoken ("", "-"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (mkumin Qast.Loc (Qast.Str "-") e : 'expr))]; Some "apply", Some Gramext.LeftA, [[Gramext.Stoken ("", "lazy"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLaz", [Qast.Loc; e]) : 'expr)); [Gramext.Stoken ("", "assert"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (mkassert Qast.Loc e : 'expr)); [Gramext.Sself; Gramext.Sself], Gramext.action - (fun (e2 : 'expr) (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; e1; e2]) : 'expr))]; Some ".", Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (e2 : 'expr) _ (e1 : 'expr) (loc : int * int) -> + (fun (e2 : 'expr) _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExAcc", [Qast.Loc; e1; e2]) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Stoken ("", "["); Gramext.Sself; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (e2 : 'expr) _ _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExSte", [Qast.Loc; e1; e2]) : 'expr)); [Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (e2 : 'expr) _ _ (e1 : 'expr) (loc : int * int) -> + (fun _ (e2 : 'expr) _ _ (e1 : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExAre", [Qast.Loc; e1; e2]) : 'expr))]; Some "~-", Some Gramext.NonA, [[Gramext.Stoken ("", "~-."); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; Qast.Node ("ExLid", [Qast.Loc; Qast.Str "~-."]); @@ -1576,7 +1695,7 @@ Grammar.extend 'expr)); [Gramext.Stoken ("", "~-"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExApp", [Qast.Loc; Qast.Node ("ExLid", [Qast.Loc; Qast.Str "~-"]); @@ -1584,7 +1703,9 @@ Grammar.extend 'expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (e : 'expr) _ (loc : int * int) -> (e : 'expr)); + Gramext.action + (fun _ (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules [[Gramext.Slist1sep @@ -1592,25 +1713,28 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'expr list) (loc : int * int) -> + (fun (a : 'expr list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (el : 'a_list) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (el : 'a_list) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTup", [Qast.Loc; Qast.Cons (e, el)]) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTyc", [Qast.Loc; e; t]) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> + (fun _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExUid", [Qast.Loc; Qast.Str "()"]) : 'expr)); [Gramext.Stoken ("", "{"); Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")"); Gramext.Stoken ("", "with"); @@ -1621,15 +1745,18 @@ Grammar.extend (label_expr : 'label_expr Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_expr list) (loc : int * int) -> + (fun (a : 'label_expr list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lel : 'a_list) _ _ (e : 'expr) _ _ (loc : int * int) -> + (fun _ (lel : 'a_list) _ _ (e : 'expr) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExRec", [Qast.Loc; lel; Qast.Option (Some e)]) : 'expr)); [Gramext.Stoken ("", "{"); @@ -1640,15 +1767,17 @@ Grammar.extend (label_expr : 'label_expr Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_expr list) (loc : int * int) -> + (fun (a : 'label_expr list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lel : 'a_list) _ (loc : int * int) -> + (fun _ (lel : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExRec", [Qast.Loc; lel; Qast.Option None]) : 'expr)); [Gramext.Stoken ("", "[|"); Gramext.srules @@ -1657,15 +1786,16 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'expr list) (loc : int * int) -> + (fun (a : 'expr list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (el : 'a_list) _ (loc : int * int) -> + (fun _ (el : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExArr", [Qast.Loc; el]) : 'expr)); [Gramext.Stoken ("", "["); Gramext.srules @@ -1674,69 +1804,94 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'expr list) (loc : int * int) -> + (fun (a : 'expr list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Snterm (Grammar.Entry.obj (cons_expr_opt : 'cons_expr_opt Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (last : 'cons_expr_opt) (el : 'a_list) _ (loc : int * int) -> + (fun _ (last : 'cons_expr_opt) (el : 'a_list) _ + (loc : Lexing.position * Lexing.position) -> (mklistexp Qast.Loc last el : 'expr)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "]")], Gramext.action - (fun _ _ (loc : int * int) -> + (fun _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExUid", [Qast.Loc; Qast.Str "[]"]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e))], - Gramext.action (fun (i : 'expr_ident) (loc : int * int) -> (i : 'expr)); + Gramext.action + (fun (i : 'expr_ident) (loc : Lexing.position * Lexing.position) -> + (i : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_CHAR : 'a_CHAR Grammar.Entry.e))], Gramext.action - (fun (s : 'a_CHAR) (loc : int * int) -> + (fun (s : 'a_CHAR) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExChr", [Qast.Loc; s]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_STRING : 'a_STRING Grammar.Entry.e))], Gramext.action - (fun (s : 'a_STRING) (loc : int * int) -> + (fun (s : 'a_STRING) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExStr", [Qast.Loc; s]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_FLOAT : 'a_FLOAT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_FLOAT) (loc : int * int) -> + (fun (s : 'a_FLOAT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFlo", [Qast.Loc; s]) : 'expr)); + [Gramext.Snterm + (Grammar.Entry.obj (a_NATIVEINT : 'a_NATIVEINT Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_NATIVEINT) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("ExNativeInt", [Qast.Loc; s]) : 'expr)); + [Gramext.Snterm + (Grammar.Entry.obj (a_INT64 : 'a_INT64 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT64) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("ExInt64", [Qast.Loc; s]) : 'expr)); + [Gramext.Snterm + (Grammar.Entry.obj (a_INT32 : 'a_INT32 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT32) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("ExInt32", [Qast.Loc; s]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_INT) (loc : int * int) -> + (fun (s : 'a_INT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExInt", [Qast.Loc; s]) : 'expr))]]; Grammar.Entry.obj (cons_expr_opt : 'cons_expr_opt Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (Qast.Option None : 'cons_expr_opt)); + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.Option None : 'cons_expr_opt)); [Gramext.Stoken ("", "::"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Option (Some e) : 'cons_expr_opt))]]; Grammar.Entry.obj (dummy : 'dummy Grammar.Entry.e), None, [None, None, - [[], Gramext.action (fun (loc : int * int) -> (() : 'dummy))]]; + [[], + Gramext.action + (fun (loc : Lexing.position * Lexing.position) -> (() : 'dummy))]]; Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) (loc : int * int) -> (Qast.List [e] : 'sequence)); + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> + (Qast.List [e] : 'sequence)); [Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (Qast.List [e] : 'sequence)); + (fun _ (e : 'expr) (loc : Lexing.position * Lexing.position) -> + (Qast.List [e] : 'sequence)); [Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";"); Gramext.Sself], Gramext.action - (fun (el : 'sequence) _ (e : 'expr) (loc : int * int) -> + (fun (el : 'sequence) _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Cons (e, el) : 'sequence)); [Gramext.Stoken ("", "let"); Gramext.srules @@ -1744,15 +1899,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "rec")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__8))])], Gramext.action - (fun (a : 'e__8 option) (loc : int * int) -> + (fun (a : 'e__8 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist1sep (Gramext.Snterm @@ -1760,21 +1918,27 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.srules [[Gramext.Stoken ("", ";")], - Gramext.action (fun (x : string) (loc : int * int) -> (x : 'e__9)); + Gramext.action + (fun (x : string) (loc : Lexing.position * Lexing.position) -> + (x : 'e__9)); [Gramext.Stoken ("", "in")], - Gramext.action (fun (x : string) (loc : int * int) -> (x : 'e__9))]; + Gramext.action + (fun (x : string) (loc : Lexing.position * Lexing.position) -> + (x : 'e__9))]; Gramext.Sself], Gramext.action (fun (el : 'sequence) _ (l : 'a_list) (rf : 'a_opt) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.List [Qast.Node ("ExLet", [Qast.Loc; o2b rf; l; mksequence Qast.Loc el])] : @@ -1785,7 +1949,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [p; e] : 'let_binding))]]; Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e), None, [None, Some Gramext.RightA, @@ -1794,16 +1959,19 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTyc", [Qast.Loc; e; t]) : 'fun_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'fun_binding)); + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'fun_binding)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFun", [Qast.Loc; Qast.List [Qast.Tuple [p; Qast.Option None; e]]]) : @@ -1819,27 +1987,29 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action (fun (e : 'expr) _ (w : 'when_expr_opt) (aso : 'as_patt_opt) - (p : 'patt) (loc : int * int) -> + (p : 'patt) (loc : Lexing.position * Lexing.position) -> (mkmatchcase Qast.Loc p aso w e : 'match_case))]]; Grammar.Entry.obj (as_patt_opt : 'as_patt_opt Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (Qast.Option None : 'as_patt_opt)); + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.Option None : 'as_patt_opt)); [Gramext.Stoken ("", "as"); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (loc : int * int) -> + (fun (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> (Qast.Option (Some p) : 'as_patt_opt))]]; Grammar.Entry.obj (when_expr_opt : 'when_expr_opt Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (Qast.Option None : 'when_expr_opt)); + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.Option None : 'when_expr_opt)); [Gramext.Stoken ("", "when"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Option (Some e) : 'when_expr_opt))]]; Grammar.Entry.obj (label_expr : 'label_expr Grammar.Entry.e), None, [None, None, @@ -1849,7 +2019,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action - (fun (e : 'fun_binding) (i : 'patt_label_ident) (loc : int * int) -> + (fun (e : 'fun_binding) (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; e] : 'label_expr))]]; Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e), None, [None, Some Gramext.RightA, @@ -1857,27 +2028,31 @@ Grammar.extend (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e)); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (j : 'expr_ident) _ (i : 'a_UIDENT) (loc : int * int) -> + (fun (j : 'expr_ident) _ (i : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (mkexprident Qast.Loc i j : 'expr_ident)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExUid", [Qast.Loc; i]) : 'expr_ident)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLid", [Qast.Loc; i]) : 'expr_ident))]]; Grammar.Entry.obj (fun_def : 'fun_def Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Stoken ("", "->"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], - Gramext.action (fun (e : 'expr) _ (loc : int * int) -> (e : 'fun_def)); + Gramext.action + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'fun_def)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'fun_def) (p : 'ipatt) (loc : int * int) -> + (fun (e : 'fun_def) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFun", [Qast.Loc; Qast.List [Qast.Tuple [p; Qast.Option None; e]]]) : @@ -1886,27 +2061,31 @@ Grammar.extend [None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "|"); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOrp", [Qast.Loc; p1; p2]) : 'patt))]; None, Some Gramext.NonA, [[Gramext.Sself; Gramext.Stoken ("", ".."); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaRng", [Qast.Loc; p1; p2]) : 'patt))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (p2 : 'patt) (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaApp", [Qast.Loc; p1; p2]) : 'patt))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (p2 : 'patt) _ (p1 : 'patt) (loc : int * int) -> + (fun (p2 : 'patt) _ (p1 : 'patt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAcc", [Qast.Loc; p1; p2]) : 'patt))]; Some "simple", None, [[Gramext.Stoken ("", "_")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAny", [Qast.Loc]) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules @@ -1915,32 +2094,38 @@ Grammar.extend (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'patt list) (loc : int * int) -> + (fun (a : 'patt list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'a_list) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (pl : 'a_list) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTup", [Qast.Loc; Qast.Cons (p, pl)]) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p2 : 'patt) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (p2 : 'patt) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAli", [Qast.Loc; p; p2]) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyc", [Qast.Loc; p; t]) : 'patt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (p : 'patt) _ (loc : int * int) -> (p : 'patt)); + Gramext.action + (fun _ (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'patt)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> + (fun _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaUid", [Qast.Loc; Qast.Str "()"]) : 'patt)); [Gramext.Stoken ("", "{"); Gramext.srules @@ -1950,15 +2135,17 @@ Grammar.extend (label_patt : 'label_patt Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_patt list) (loc : int * int) -> + (fun (a : 'label_patt list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lpl : 'a_list) _ (loc : int * int) -> + (fun _ (lpl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaRec", [Qast.Loc; lpl]) : 'patt)); [Gramext.Stoken ("", "[|"); Gramext.srules @@ -1967,15 +2154,16 @@ Grammar.extend (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'patt list) (loc : int * int) -> + (fun (a : 'patt list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (pl : 'a_list) _ (loc : int * int) -> + (fun _ (pl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaArr", [Qast.Loc; pl]) : 'patt)); [Gramext.Stoken ("", "["); Gramext.srules @@ -1984,70 +2172,106 @@ Grammar.extend (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'patt list) (loc : int * int) -> + (fun (a : 'patt list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Snterm (Grammar.Entry.obj (cons_patt_opt : 'cons_patt_opt Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (last : 'cons_patt_opt) (pl : 'a_list) _ (loc : int * int) -> + (fun _ (last : 'cons_patt_opt) (pl : 'a_list) _ + (loc : Lexing.position * Lexing.position) -> (mklistpat Qast.Loc last pl : 'patt)); [Gramext.Stoken ("", "["); Gramext.Stoken ("", "]")], Gramext.action - (fun _ _ (loc : int * int) -> + (fun _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaUid", [Qast.Loc; Qast.Str "[]"]) : 'patt)); [Gramext.Stoken ("", "-"); Gramext.Snterm (Grammar.Entry.obj (a_FLOAT : 'a_FLOAT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_FLOAT) _ (loc : int * int) -> + (fun (s : 'a_FLOAT) _ (loc : Lexing.position * Lexing.position) -> (mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool false) s : 'patt)); [Gramext.Stoken ("", "-"); + Gramext.Snterm + (Grammar.Entry.obj (a_NATIVEINT : 'a_NATIVEINT Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_NATIVEINT) _ (loc : Lexing.position * Lexing.position) -> + (mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool true) s : 'patt)); + [Gramext.Stoken ("", "-"); + Gramext.Snterm + (Grammar.Entry.obj (a_INT64 : 'a_INT64 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT64) _ (loc : Lexing.position * Lexing.position) -> + (mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool true) s : 'patt)); + [Gramext.Stoken ("", "-"); + Gramext.Snterm + (Grammar.Entry.obj (a_INT32 : 'a_INT32 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT32) _ (loc : Lexing.position * Lexing.position) -> + (mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool true) s : 'patt)); + [Gramext.Stoken ("", "-"); Gramext.Snterm (Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_INT) _ (loc : int * int) -> + (fun (s : 'a_INT) _ (loc : Lexing.position * Lexing.position) -> (mkuminpat Qast.Loc (Qast.Str "-") (Qast.Bool true) s : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_CHAR : 'a_CHAR Grammar.Entry.e))], Gramext.action - (fun (s : 'a_CHAR) (loc : int * int) -> + (fun (s : 'a_CHAR) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaChr", [Qast.Loc; s]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_STRING : 'a_STRING Grammar.Entry.e))], Gramext.action - (fun (s : 'a_STRING) (loc : int * int) -> + (fun (s : 'a_STRING) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaStr", [Qast.Loc; s]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_FLOAT : 'a_FLOAT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_FLOAT) (loc : int * int) -> + (fun (s : 'a_FLOAT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaFlo", [Qast.Loc; s]) : 'patt)); + [Gramext.Snterm + (Grammar.Entry.obj (a_NATIVEINT : 'a_NATIVEINT Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_NATIVEINT) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("PaNativeInt", [Qast.Loc; s]) : 'patt)); + [Gramext.Snterm + (Grammar.Entry.obj (a_INT64 : 'a_INT64 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT64) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("PaInt64", [Qast.Loc; s]) : 'patt)); + [Gramext.Snterm + (Grammar.Entry.obj (a_INT32 : 'a_INT32 Grammar.Entry.e))], + Gramext.action + (fun (s : 'a_INT32) (loc : Lexing.position * Lexing.position) -> + (Qast.Node ("PaInt32", [Qast.Loc; s]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_INT) (loc : int * int) -> + (fun (s : 'a_INT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaInt", [Qast.Loc; s]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_UIDENT) (loc : int * int) -> + (fun (s : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaUid", [Qast.Loc; s]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_LIDENT) (loc : int * int) -> + (fun (s : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLid", [Qast.Loc; s]) : 'patt))]]; Grammar.Entry.obj (cons_patt_opt : 'cons_patt_opt Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (Qast.Option None : 'cons_patt_opt)); + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.Option None : 'cons_patt_opt)); [Gramext.Stoken ("", "::"); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (loc : int * int) -> + (fun (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> (Qast.Option (Some p) : 'cons_patt_opt))]]; Grammar.Entry.obj (label_patt : 'label_patt Grammar.Entry.e), None, [None, None, @@ -2057,7 +2281,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], Gramext.action - (fun (p : 'patt) _ (i : 'patt_label_ident) (loc : int * int) -> + (fun (p : 'patt) _ (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; p] : 'label_patt))]]; Grammar.Entry.obj (patt_label_ident : 'patt_label_ident Grammar.Entry.e), None, @@ -2065,29 +2290,29 @@ Grammar.extend [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action (fun (p2 : 'patt_label_ident) _ (p1 : 'patt_label_ident) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAcc", [Qast.Loc; p1; p2]) : 'patt_label_ident))]; Some "simple", Some Gramext.RightA, [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLid", [Qast.Loc; i]) : 'patt_label_ident)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaUid", [Qast.Loc; i]) : 'patt_label_ident))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "_")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAny", [Qast.Loc]) : 'ipatt)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (s : 'a_LIDENT) (loc : int * int) -> + (fun (s : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLid", [Qast.Loc; s]) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ","); Gramext.srules @@ -2096,32 +2321,39 @@ Grammar.extend (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'ipatt list) (loc : int * int) -> + (fun (a : 'ipatt list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'a_list) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (pl : 'a_list) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTup", [Qast.Loc; Qast.Cons (p, pl)]) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p2 : 'ipatt) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (p2 : 'ipatt) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAli", [Qast.Loc; p; p2]) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'ipatt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyc", [Qast.Loc; p; t]) : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (p : 'ipatt) _ (loc : int * int) -> (p : 'ipatt)); + Gramext.action + (fun _ (p : 'ipatt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'ipatt)); [Gramext.Stoken ("", "("); Gramext.Stoken ("", ")")], Gramext.action - (fun _ _ (loc : int * int) -> + (fun _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaUid", [Qast.Loc; Qast.Str "()"]) : 'ipatt)); [Gramext.Stoken ("", "{"); Gramext.srules @@ -2131,15 +2363,17 @@ Grammar.extend (label_ipatt : 'label_ipatt Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_ipatt list) (loc : int * int) -> + (fun (a : 'label_ipatt list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (lpl : 'a_list) _ (loc : int * int) -> + (fun _ (lpl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaRec", [Qast.Loc; lpl]) : 'ipatt))]]; Grammar.Entry.obj (label_ipatt : 'label_ipatt Grammar.Entry.e), None, [None, None, @@ -2149,7 +2383,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e))], Gramext.action - (fun (p : 'ipatt) _ (i : 'patt_label_ident) (loc : int * int) -> + (fun (p : 'ipatt) _ (i : 'patt_label_ident) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; p] : 'label_ipatt))]]; Grammar.Entry.obj (type_declaration : 'type_declaration Grammar.Entry.e), None, @@ -2162,12 +2397,14 @@ Grammar.extend (Grammar.Entry.obj (type_parameter : 'type_parameter Grammar.Entry.e)))], Gramext.action - (fun (a : 'type_parameter list) (loc : int * int) -> + (fun (a : 'type_parameter list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.srules @@ -2176,22 +2413,24 @@ Grammar.extend (Grammar.Entry.obj (constrain : 'constrain Grammar.Entry.e)))], Gramext.action - (fun (a : 'constrain list) (loc : int * int) -> + (fun (a : 'constrain list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action (fun (cl : 'a_list) (tk : 'ctyp) _ (tpl : 'a_list) (n : 'type_patt) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [n; tpl; tk; cl] : 'type_declaration))]]; Grammar.Entry.obj (type_patt : 'type_patt Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (n : 'a_LIDENT) (loc : int * int) -> + (fun (n : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; n] : 'type_patt))]]; Grammar.Entry.obj (constrain : 'constrain Grammar.Entry.e), None, [None, None, @@ -2200,7 +2439,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [t1; t2] : 'constrain))]]; Grammar.Entry.obj (type_parameter : 'type_parameter Grammar.Entry.e), None, @@ -2208,31 +2448,33 @@ Grammar.extend [[Gramext.Stoken ("", "-"); Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ _ (loc : int * int) -> + (fun (i : 'ident) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; Qast.Tuple [Qast.Bool false; Qast.Bool true]] : 'type_parameter)); [Gramext.Stoken ("", "+"); Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ _ (loc : int * int) -> + (fun (i : 'ident) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; Qast.Tuple [Qast.Bool true; Qast.Bool false]] : 'type_parameter)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [i; Qast.Tuple [Qast.Bool false; Qast.Bool false]] : 'type_parameter))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), None, [None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "=="); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyMan", [Qast.Loc; t1; t2]) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "as"); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyAli", [Qast.Loc; t1; t2]) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Stoken ("", "!"); @@ -2241,56 +2483,66 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (typevar : 'typevar Grammar.Entry.e)))], Gramext.action - (fun (a : 'typevar list) (loc : int * int) -> + (fun (a : 'typevar list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (pl : 'a_list) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (pl : 'a_list) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyPol", [Qast.Loc; pl; t]) : 'ctyp))]; Some "arrow", Some Gramext.RightA, [[Gramext.Sself; Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyArr", [Qast.Loc; t1; t2]) : 'ctyp))]; Some "label", Some Gramext.NonA, [[Gramext.Snterm (Grammar.Entry.obj (a_OPTLABEL : 'a_OPTLABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) (i : 'a_OPTLABEL) (loc : int * int) -> + (fun (t : 'ctyp) (i : 'a_OPTLABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyOlb", [Qast.Loc; i; t]) : 'ctyp)); [Gramext.Snterm (Grammar.Entry.obj (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (i : 'a_QUESTIONIDENT) (loc : int * int) -> + (fun (t : 'ctyp) _ (i : 'a_QUESTIONIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyOlb", [Qast.Loc; i; t]) : 'ctyp)); [Gramext.Snterm (Grammar.Entry.obj (a_LABEL : 'a_LABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) (i : 'a_LABEL) (loc : int * int) -> + (fun (t : 'ctyp) (i : 'a_LABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyLab", [Qast.Loc; i; t]) : 'ctyp)); [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (t : 'ctyp) _ (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (t : 'ctyp) _ (i : 'a_TILDEIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyLab", [Qast.Loc; i; t]) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyApp", [Qast.Loc; t1; t2]) : 'ctyp))]; None, Some Gramext.LeftA, [[Gramext.Sself; Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyAcc", [Qast.Loc; t1; t2]) : 'ctyp))]; Some "simple", None, [[Gramext.Stoken ("", "{"); @@ -2301,15 +2553,17 @@ Grammar.extend (label_declaration : 'label_declaration Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_declaration list) (loc : int * int) -> + (fun (a : 'label_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (ldl : 'a_list) _ (loc : int * int) -> + (fun _ (ldl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyRec", [Qast.Loc; Qast.Bool false; ldl]) : 'ctyp)); [Gramext.Stoken ("", "["); Gramext.srules @@ -2320,15 +2574,17 @@ Grammar.extend 'constructor_declaration Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'constructor_declaration list) (loc : int * int) -> + (fun (a : 'constructor_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (cdl : 'a_list) _ (loc : int * int) -> + (fun _ (cdl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TySum", [Qast.Loc; Qast.Bool false; cdl]) : 'ctyp)); [Gramext.Stoken ("", "private"); Gramext.Stoken ("", "{"); Gramext.srules @@ -2338,15 +2594,18 @@ Grammar.extend (label_declaration : 'label_declaration Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'label_declaration list) (loc : int * int) -> + (fun (a : 'label_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "}")], Gramext.action - (fun _ (ldl : 'a_list) _ _ (loc : int * int) -> + (fun _ (ldl : 'a_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyRec", [Qast.Loc; Qast.Bool true; ldl]) : 'ctyp)); [Gramext.Stoken ("", "private"); Gramext.Stoken ("", "["); Gramext.srules @@ -2357,18 +2616,23 @@ Grammar.extend 'constructor_declaration Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'constructor_declaration list) (loc : int * int) -> + (fun (a : 'constructor_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (cdl : 'a_list) _ _ (loc : int * int) -> + (fun _ (cdl : 'a_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TySum", [Qast.Loc; Qast.Bool true; cdl]) : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], - Gramext.action (fun _ (t : 'ctyp) _ (loc : int * int) -> (t : 'ctyp)); + Gramext.action + (fun _ (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'ctyp)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", "*"); Gramext.srules [[Gramext.Slist1sep @@ -2376,34 +2640,36 @@ Grammar.extend (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", "*"))], Gramext.action - (fun (a : 'ctyp list) (loc : int * int) -> + (fun (a : 'ctyp list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (tl : 'a_list) _ (t : 'ctyp) _ (loc : int * int) -> + (fun _ (tl : 'a_list) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyTup", [Qast.Loc; Qast.Cons (t, tl)]) : 'ctyp)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyUid", [Qast.Loc; i]) : 'ctyp)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyLid", [Qast.Loc; i]) : 'ctyp)); [Gramext.Stoken ("", "_")], Gramext.action - (fun _ (loc : int * int) -> + (fun _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyAny", [Qast.Loc]) : 'ctyp)); [Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyQuo", [Qast.Loc; i]) : 'ctyp))]]; Grammar.Entry.obj (constructor_declaration : 'constructor_declaration Grammar.Entry.e), @@ -2412,7 +2678,7 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (ci : 'a_UIDENT) (loc : int * int) -> + (fun (ci : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; ci; Qast.List []] : 'constructor_declaration)); [Gramext.Snterm @@ -2424,14 +2690,16 @@ Grammar.extend (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'ctyp list) (loc : int * int) -> + (fun (a : 'ctyp list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (cal : 'a_list) _ (ci : 'a_UIDENT) (loc : int * int) -> + (fun (cal : 'a_list) _ (ci : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; ci; cal] : 'constructor_declaration))]]; Grammar.Entry.obj (label_declaration : 'label_declaration Grammar.Entry.e), @@ -2445,45 +2713,53 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "mutable")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__10))])], Gramext.action - (fun (a : 'e__10 option) (loc : int * int) -> + (fun (a : 'e__10 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) (mf : 'a_opt) _ (i : 'a_LIDENT) (loc : int * int) -> + (fun (t : 'ctyp) (mf : 'a_opt) _ (i : 'a_LIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; i; o2b mf; t] : 'label_declaration))]]; Grammar.Entry.obj (ident : 'ident Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], - Gramext.action (fun (i : 'a_UIDENT) (loc : int * int) -> (i : 'ident)); + Gramext.action + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> + (i : 'ident)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> (i : 'ident))]]; + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> + (i : 'ident))]]; Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e), None, [None, Some Gramext.RightA, [[Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e)); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (j : 'mod_ident) _ (i : 'a_UIDENT) (loc : int * int) -> + (fun (j : 'mod_ident) _ (i : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Cons (i, j) : 'mod_ident)); [Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.List [i] : 'mod_ident)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_UIDENT) (loc : int * int) -> + (fun (i : 'a_UIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.List [i] : 'mod_ident))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), None, [None, None, @@ -2496,14 +2772,16 @@ Grammar.extend 'class_type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'class_type_declaration list) (loc : int * int) -> + (fun (a : 'class_type_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (ctd : 'a_list) _ _ (loc : int * int) -> + (fun (ctd : 'a_list) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StClt", [Qast.Loc; ctd]) : 'str_item)); [Gramext.Stoken ("", "class"); Gramext.srules @@ -2513,14 +2791,16 @@ Grammar.extend (class_declaration : 'class_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'class_declaration list) (loc : int * int) -> + (fun (a : 'class_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (cd : 'a_list) _ (loc : int * int) -> + (fun (cd : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StCls", [Qast.Loc; cd]) : 'str_item))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [None, None, @@ -2533,14 +2813,16 @@ Grammar.extend 'class_type_declaration Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'class_type_declaration list) (loc : int * int) -> + (fun (a : 'class_type_declaration list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (ctd : 'a_list) _ _ (loc : int * int) -> + (fun (ctd : 'a_list) _ _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgClt", [Qast.Loc; ctd]) : 'sig_item)); [Gramext.Stoken ("", "class"); Gramext.srules @@ -2550,14 +2832,16 @@ Grammar.extend (class_description : 'class_description Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'class_description list) (loc : int * int) -> + (fun (a : 'class_description list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (cd : 'a_list) _ (loc : int * int) -> + (fun (cd : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgCls", [Qast.Loc; cd]) : 'sig_item))]]; Grammar.Entry.obj (class_declaration : 'class_declaration Grammar.Entry.e), @@ -2568,15 +2852,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "virtual")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__11))])], Gramext.action - (fun (a : 'e__11 option) (loc : int * int) -> + (fun (a : 'e__11 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e)); Gramext.Snterm @@ -2587,7 +2874,8 @@ Grammar.extend (class_fun_binding : 'class_fun_binding Grammar.Entry.e))], Gramext.action (fun (cfb : 'class_fun_binding) (ctp : 'class_type_parameters) - (i : 'a_LIDENT) (vf : 'a_opt) (loc : int * int) -> + (i : 'a_LIDENT) (vf : 'a_opt) + (loc : Lexing.position * Lexing.position) -> (Qast.Record ["ciLoc", Qast.Loc; "ciVir", o2b vf; "ciPrm", ctp; "ciNam", i; "ciExp", cfb] : @@ -2599,7 +2887,8 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (cfb : 'class_fun_binding) (p : 'ipatt) (loc : int * int) -> + (fun (cfb : 'class_fun_binding) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeFun", [Qast.Loc; p; cfb]) : 'class_fun_binding)); [Gramext.Stoken ("", ":"); Gramext.Snterm @@ -2608,13 +2897,14 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (ct : 'class_type) _ (loc : int * int) -> + (fun (ce : 'class_expr) _ (ct : 'class_type) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeTyc", [Qast.Loc; ce; ct]) : 'class_fun_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (loc : int * int) -> + (fun (ce : 'class_expr) _ (loc : Lexing.position * Lexing.position) -> (ce : 'class_fun_binding))]]; Grammar.Entry.obj (class_type_parameters : 'class_type_parameters Grammar.Entry.e), @@ -2628,19 +2918,21 @@ Grammar.extend (type_parameter : 'type_parameter Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'type_parameter list) (loc : int * int) -> + (fun (a : 'type_parameter list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (tpl : 'a_list) _ (loc : int * int) -> + (fun _ (tpl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; tpl] : 'class_type_parameters)); [], Gramext.action - (fun (loc : int * int) -> + (fun (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [Qast.Loc; Qast.List []] : 'class_type_parameters))]]; Grammar.Entry.obj (class_fun_def : 'class_fun_def Grammar.Entry.e), None, [None, None, @@ -2648,11 +2940,13 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_expr) _ (loc : int * int) -> (ce : 'class_fun_def)); + (fun (ce : 'class_expr) _ (loc : Lexing.position * Lexing.position) -> + (ce : 'class_fun_def)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (ce : 'class_fun_def) (p : 'ipatt) (loc : int * int) -> + (fun (ce : 'class_fun_def) (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeFun", [Qast.Loc; p; ce]) : 'class_fun_def))]]; Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e), None, [Some "top", None, @@ -2662,15 +2956,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "rec")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__12))])], Gramext.action - (fun (a : 'e__12 option) (loc : int * int) -> + (fun (a : 'e__12 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist1sep (Gramext.Snterm @@ -2678,16 +2975,18 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (ce : 'class_expr) _ (lb : 'a_list) (rf : 'a_opt) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeLet", [Qast.Loc; o2b rf; lb; ce]) : 'class_expr)); [Gramext.Stoken ("", "fun"); Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); @@ -2695,25 +2994,30 @@ Grammar.extend (Grammar.Entry.obj (class_fun_def : 'class_fun_def Grammar.Entry.e))], Gramext.action - (fun (ce : 'class_fun_def) (p : 'ipatt) _ (loc : int * int) -> + (fun (ce : 'class_fun_def) (p : 'ipatt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeFun", [Qast.Loc; p; ce]) : 'class_expr))]; Some "apply", Some Gramext.NonA, [[Gramext.Sself; Gramext.Snterml (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), "label")], Gramext.action - (fun (e : 'expr) (ce : 'class_expr) (loc : int * int) -> + (fun (e : 'expr) (ce : 'class_expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeApp", [Qast.Loc; ce; e]) : 'class_expr))]; Some "simple", None, [[Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (ce : 'class_expr) _ (loc : int * int) -> (ce : 'class_expr)); + (fun _ (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> + (ce : 'class_expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (ct : 'class_type) _ (ce : 'class_expr) _ (loc : int * int) -> + (fun _ (ct : 'class_type) _ (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeTyc", [Qast.Loc; ce; ct]) : 'class_expr)); [Gramext.Stoken ("", "object"); Gramext.srules @@ -2722,24 +3026,28 @@ Grammar.extend (Grammar.Entry.obj (class_self_patt : 'class_self_patt Grammar.Entry.e)))], Gramext.action - (fun (a : 'class_self_patt option) (loc : int * int) -> + (fun (a : 'class_self_patt option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (class_structure : 'class_structure Grammar.Entry.e)); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (cf : 'class_structure) (cspo : 'a_opt) _ (loc : int * int) -> + (fun _ (cf : 'class_structure) (cspo : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeStr", [Qast.Loc; cspo; cf]) : 'class_expr)); [Gramext.Snterm (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (ci : 'class_longident) (loc : int * int) -> + (fun (ci : 'class_longident) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeCon", [Qast.Loc; ci; Qast.List []]) : 'class_expr)); [Gramext.Snterm (Grammar.Entry.obj @@ -2751,15 +3059,17 @@ Grammar.extend (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'ctyp list) (loc : int * int) -> + (fun (a : 'ctyp list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (ctcl : 'a_list) _ (ci : 'class_longident) (loc : int * int) -> + (fun _ (ctcl : 'a_list) _ (ci : 'class_longident) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CeCon", [Qast.Loc; ci; ctcl]) : 'class_expr))]]; Grammar.Entry.obj (class_structure : 'class_structure Grammar.Entry.e), None, @@ -2772,17 +3082,21 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (cf : 'class_str_item) (loc : int * int) -> + (fun _ (cf : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (cf : 'e__13))])], Gramext.action - (fun (a : 'e__13 list) (loc : int * int) -> + (fun (a : 'e__13 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (cf : 'a_list) (loc : int * int) -> (cf : 'class_structure))]]; + (fun (cf : 'a_list) (loc : Lexing.position * Lexing.position) -> + (cf : 'class_structure))]]; Grammar.Entry.obj (class_self_patt : 'class_self_patt Grammar.Entry.e), None, [None, None, @@ -2792,27 +3106,30 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (p : 'patt) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (p : 'patt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyc", [Qast.Loc; p; t]) : 'class_self_patt)); [Gramext.Stoken ("", "("); Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (p : 'patt) _ (loc : int * int) -> (p : 'class_self_patt))]]; + (fun _ (p : 'patt) _ (loc : Lexing.position * Lexing.position) -> + (p : 'class_self_patt))]]; Grammar.Entry.obj (class_str_item : 'class_str_item Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "initializer"); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (se : 'expr) _ (loc : int * int) -> + (fun (se : 'expr) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrIni", [Qast.Loc; se]) : 'class_str_item)); [Gramext.Stoken ("", "type"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrCtr", [Qast.Loc; t1; t2]) : 'class_str_item)); [Gramext.Stoken ("", "method"); Gramext.srules @@ -2820,32 +3137,37 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "private")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__17))])], Gramext.action - (fun (a : 'e__17 option) (loc : int * int) -> + (fun (a : 'e__17 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.srules [[Gramext.Sopt (Gramext.Snterm (Grammar.Entry.obj (polyt : 'polyt Grammar.Entry.e)))], Gramext.action - (fun (a : 'polyt option) (loc : int * int) -> + (fun (a : 'polyt option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (fun_binding : 'fun_binding Grammar.Entry.e))], Gramext.action (fun (e : 'fun_binding) (topt : 'a_opt) (l : 'label) (pf : 'a_opt) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrMth", [Qast.Loc; l; o2b pf; e; topt]) : 'class_str_item)); [Gramext.Stoken ("", "method"); Gramext.Stoken ("", "virtual"); @@ -2854,20 +3176,24 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "private")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__16))])], Gramext.action - (fun (a : 'e__16 option) (loc : int * int) -> + (fun (a : 'e__16 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ _ (loc : int * int) -> + (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrVir", [Qast.Loc; l; o2b pf; t]) : 'class_str_item)); [Gramext.Stoken ("", "value"); Gramext.srules @@ -2875,22 +3201,25 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "mutable")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__15))])], Gramext.action - (fun (a : 'e__15 option) (loc : int * int) -> + (fun (a : 'e__15 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.Snterm (Grammar.Entry.obj (cvalue_binding : 'cvalue_binding Grammar.Entry.e))], Gramext.action (fun (e : 'cvalue_binding) (lab : 'label) (mf : 'a_opt) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrVal", [Qast.Loc; lab; o2b mf; e]) : 'class_str_item)); [Gramext.Stoken ("", "inherit"); @@ -2902,14 +3231,17 @@ Grammar.extend (Grammar.Entry.obj (as_lident : 'as_lident Grammar.Entry.e)))], Gramext.action - (fun (a : 'as_lident option) (loc : int * int) -> + (fun (a : 'as_lident option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]], + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]], Gramext.action - (fun (pb : 'a_opt) (ce : 'class_expr) _ (loc : int * int) -> + (fun (pb : 'a_opt) (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrInh", [Qast.Loc; ce; pb]) : 'class_str_item)); [Gramext.Stoken ("", "declare"); Gramext.srules @@ -2920,18 +3252,21 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'class_str_item) (loc : int * int) -> + (fun _ (s : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__14))])], Gramext.action - (fun (a : 'e__14 list) (loc : int * int) -> + (fun (a : 'e__14 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'a_list) _ (loc : int * int) -> + (fun _ (st : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CrDcl", [Qast.Loc; st]) : 'class_str_item))]]; Grammar.Entry.obj (as_lident : 'as_lident Grammar.Entry.e), None, [None, None, @@ -2939,12 +3274,15 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) _ (loc : int * int) -> (i : 'as_lident))]]; + (fun (i : 'a_LIDENT) _ (loc : Lexing.position * Lexing.position) -> + (i : 'as_lident))]]; Grammar.Entry.obj (polyt : 'polyt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], - Gramext.action (fun (t : 'ctyp) _ (loc : int * int) -> (t : 'polyt))]]; + Gramext.action + (fun (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'polyt))]]; Grammar.Entry.obj (cvalue_binding : 'cvalue_binding Grammar.Entry.e), None, [None, None, @@ -2953,7 +3291,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExCoe", [Qast.Loc; e; Qast.Option None; t]) : 'cvalue_binding)); [Gramext.Stoken ("", ":"); @@ -2963,7 +3302,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t2 : 'ctyp) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t2 : 'ctyp) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExCoe", [Qast.Loc; e; Qast.Option (Some t); t2]) : 'cvalue_binding)); [Gramext.Stoken ("", ":"); @@ -2971,18 +3311,21 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (t : 'ctyp) _ (loc : int * int) -> + (fun (e : 'expr) _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTyc", [Qast.Loc; e; t]) : 'cvalue_binding)); [Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'cvalue_binding))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'cvalue_binding))]]; Grammar.Entry.obj (label : 'label Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> (i : 'label))]]; + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> + (i : 'label))]]; Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "object"); @@ -2992,12 +3335,14 @@ Grammar.extend (Grammar.Entry.obj (class_self_type : 'class_self_type Grammar.Entry.e)))], Gramext.action - (fun (a : 'class_self_type option) (loc : int * int) -> + (fun (a : 'class_self_type option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist0 (Gramext.srules @@ -3006,24 +3351,29 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (csf : 'class_sig_item) (loc : int * int) -> + (fun _ (csf : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (csf : 'e__18))])], Gramext.action - (fun (a : 'e__18 list) (loc : int * int) -> + (fun (a : 'e__18 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (csf : 'a_list) (cst : 'a_opt) _ (loc : int * int) -> + (fun _ (csf : 'a_list) (cst : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CtSig", [Qast.Loc; cst; csf]) : 'class_type)); [Gramext.Snterm (Grammar.Entry.obj (clty_longident : 'clty_longident Grammar.Entry.e))], Gramext.action - (fun (id : 'clty_longident) (loc : int * int) -> + (fun (id : 'clty_longident) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CtCon", [Qast.Loc; id; Qast.List []]) : 'class_type)); [Gramext.Snterm (Grammar.Entry.obj @@ -3035,21 +3385,24 @@ Grammar.extend (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", ","))], Gramext.action - (fun (a : 'ctyp list) (loc : int * int) -> + (fun (a : 'ctyp list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action - (fun _ (tl : 'a_list) _ (id : 'clty_longident) (loc : int * int) -> + (fun _ (tl : 'a_list) _ (id : 'clty_longident) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CtCon", [Qast.Loc; id; tl]) : 'class_type)); [Gramext.Stoken ("", "["); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", "]"); Gramext.Stoken ("", "->"); Gramext.Sself], Gramext.action - (fun (ct : 'class_type) _ _ (t : 'ctyp) _ (loc : int * int) -> + (fun (ct : 'class_type) _ _ (t : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CtFun", [Qast.Loc; t; ct]) : 'class_type))]]; Grammar.Entry.obj (class_self_type : 'class_self_type Grammar.Entry.e), None, @@ -3058,7 +3411,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (loc : int * int) -> (t : 'class_self_type))]]; + (fun _ (t : 'ctyp) _ (loc : Lexing.position * Lexing.position) -> + (t : 'class_self_type))]]; Grammar.Entry.obj (class_sig_item : 'class_sig_item Grammar.Entry.e), None, [None, None, @@ -3067,7 +3421,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ (loc : int * int) -> + (fun (t2 : 'ctyp) _ (t1 : 'ctyp) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgCtr", [Qast.Loc; t1; t2]) : 'class_sig_item)); [Gramext.Stoken ("", "method"); Gramext.srules @@ -3075,20 +3430,24 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "private")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__22))])], Gramext.action - (fun (a : 'e__22 option) (loc : int * int) -> + (fun (a : 'e__22 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgMth", [Qast.Loc; l; o2b pf; t]) : 'class_sig_item)); [Gramext.Stoken ("", "method"); Gramext.Stoken ("", "virtual"); Gramext.srules @@ -3096,20 +3455,24 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "private")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__21))])], Gramext.action - (fun (a : 'e__21 option) (loc : int * int) -> + (fun (a : 'e__21 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ _ (loc : int * int) -> + (fun (t : 'ctyp) _ (l : 'label) (pf : 'a_opt) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgVir", [Qast.Loc; l; o2b pf; t]) : 'class_sig_item)); [Gramext.Stoken ("", "value"); Gramext.srules @@ -3117,26 +3480,30 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "mutable")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__20))])], Gramext.action - (fun (a : 'e__20 option) (loc : int * int) -> + (fun (a : 'e__20 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (l : 'label) (mf : 'a_opt) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (l : 'label) (mf : 'a_opt) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgVal", [Qast.Loc; l; o2b mf; t]) : 'class_sig_item)); [Gramext.Stoken ("", "inherit"); Gramext.Snterm (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action - (fun (cs : 'class_type) _ (loc : int * int) -> + (fun (cs : 'class_type) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgInh", [Qast.Loc; cs]) : 'class_sig_item)); [Gramext.Stoken ("", "declare"); Gramext.srules @@ -3147,18 +3514,21 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (s : 'class_sig_item) (loc : int * int) -> + (fun _ (s : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (s : 'e__19))])], Gramext.action - (fun (a : 'e__19 list) (loc : int * int) -> + (fun (a : 'e__19 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (st : 'a_list) _ (loc : int * int) -> + (fun _ (st : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("CgDcl", [Qast.Loc; st]) : 'class_sig_item))]]; Grammar.Entry.obj (class_description : 'class_description Grammar.Entry.e), @@ -3169,15 +3539,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "virtual")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__23))])], Gramext.action - (fun (a : 'e__23 option) (loc : int * int) -> + (fun (a : 'e__23 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e)); Gramext.Snterm @@ -3188,7 +3561,8 @@ Grammar.extend (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action (fun (ct : 'class_type) _ (ctp : 'class_type_parameters) - (n : 'a_LIDENT) (vf : 'a_opt) (loc : int * int) -> + (n : 'a_LIDENT) (vf : 'a_opt) + (loc : Lexing.position * Lexing.position) -> (Qast.Record ["ciLoc", Qast.Loc; "ciVir", o2b vf; "ciPrm", ctp; "ciNam", n; "ciExp", ct] : @@ -3202,15 +3576,18 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "virtual")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__24))])], Gramext.action - (fun (a : 'e__24 option) (loc : int * int) -> + (fun (a : 'e__24 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e)); Gramext.Snterm @@ -3221,7 +3598,8 @@ Grammar.extend (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e))], Gramext.action (fun (cs : 'class_type) _ (ctp : 'class_type_parameters) - (n : 'a_LIDENT) (vf : 'a_opt) (loc : int * int) -> + (n : 'a_LIDENT) (vf : 'a_opt) + (loc : Lexing.position * Lexing.position) -> (Qast.Record ["ciLoc", Qast.Loc; "ciVir", o2b vf; "ciPrm", ctp; "ciNam", n; "ciExp", cs] : @@ -3234,7 +3612,8 @@ Grammar.extend (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (i : 'class_longident) _ (loc : int * int) -> + (fun (i : 'class_longident) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExNew", [Qast.Loc; i]) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "."), @@ -3242,7 +3621,8 @@ Grammar.extend [[Gramext.Sself; Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (label : 'label Grammar.Entry.e))], Gramext.action - (fun (lab : 'label) _ (e : 'expr) (loc : int * int) -> + (fun (lab : 'label) _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExSnd", [Qast.Loc; e; lab]) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -3255,21 +3635,24 @@ Grammar.extend (field_expr : 'field_expr Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'field_expr list) (loc : int * int) -> + (fun (a : 'field_expr list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", ">}")], Gramext.action - (fun _ (fel : 'a_list) _ (loc : int * int) -> + (fun _ (fel : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExOvr", [Qast.Loc; fel]) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":>"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExCoe", [Qast.Loc; e; Qast.Option None; t]) : 'expr)); [Gramext.Stoken ("", "("); Gramext.Sself; Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); @@ -3277,7 +3660,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (t2 : 'ctyp) _ (t : 'ctyp) _ (e : 'expr) _ (loc : int * int) -> + (fun _ (t2 : 'ctyp) _ (t : 'ctyp) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExCoe", [Qast.Loc; e; Qast.Option (Some t); t2]) : 'expr))]]; Grammar.Entry.obj (field_expr : 'field_expr Grammar.Entry.e), None, @@ -3286,7 +3670,8 @@ Grammar.extend Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (l : 'label) (loc : int * int) -> + (fun (e : 'expr) _ (l : 'label) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [l; e] : 'field_expr))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -3298,36 +3683,43 @@ Grammar.extend (Grammar.Entry.obj (field : 'field Grammar.Entry.e)), Gramext.Stoken ("", ";"))], Gramext.action - (fun (a : 'field list) (loc : int * int) -> + (fun (a : 'field list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.srules [[Gramext.Sopt (Gramext.srules [[Gramext.Stoken ("", "..")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__25))])], Gramext.action - (fun (a : 'e__25 option) (loc : int * int) -> + (fun (a : 'e__25 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ">")], Gramext.action - (fun _ (v : 'a_opt) (ml : 'a_list) _ (loc : int * int) -> + (fun _ (v : 'a_opt) (ml : 'a_list) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyObj", [Qast.Loc; ml; o2b v]) : 'ctyp)); [Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e))], Gramext.action - (fun (id : 'class_longident) _ (loc : int * int) -> + (fun (id : 'class_longident) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyCls", [Qast.Loc; id]) : 'ctyp))]]; Grammar.Entry.obj (field : 'field Grammar.Entry.e), None, [None, None, @@ -3336,27 +3728,30 @@ Grammar.extend Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (lab : 'a_LIDENT) (loc : int * int) -> + (fun (t : 'ctyp) _ (lab : 'a_LIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Tuple [lab; t] : 'field))]]; Grammar.Entry.obj (typevar : 'typevar Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "'"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> (i : 'typevar))]]; + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> + (i : 'typevar))]]; Grammar.Entry.obj (clty_longident : 'clty_longident Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.List [i] : 'clty_longident)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e)); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (l : 'clty_longident) _ (m : 'a_UIDENT) (loc : int * int) -> + (fun (l : 'clty_longident) _ (m : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Cons (m, l) : 'clty_longident))]]; Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e), None, @@ -3364,18 +3759,58 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_LIDENT) (loc : int * int) -> + (fun (i : 'a_LIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.List [i] : 'class_longident)); [Gramext.Snterm (Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e)); Gramext.Stoken ("", "."); Gramext.Sself], Gramext.action - (fun (l : 'class_longident) _ (m : 'a_UIDENT) (loc : int * int) -> + (fun (l : 'class_longident) _ (m : 'a_UIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Cons (m, l) : 'class_longident))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); + [[Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", ">"); + Gramext.srules + [[Gramext.Slist1 + (Gramext.Snterm + (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e)))], + Gramext.action + (fun (a : 'name_tag list) + (loc : Lexing.position * Lexing.position) -> + (Qast.List a : 'a_list)); + [Gramext.Snterm + (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], + Gramext.action + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (ntl : 'a_list) _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (Qast.Node + ("TyVrn", + [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))]) : + 'ctyp)); + [Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (Qast.Node + ("TyVrn", + [Qast.Loc; rfl; + Qast.Option (Some (Qast.Option (Some (Qast.List []))))]) : + 'ctyp)); + [Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); Gramext.Snterm (Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e)); @@ -3385,16 +3820,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e)))], Gramext.action - (fun (a : 'name_tag list) (loc : int * int) -> + (fun (a : 'name_tag list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "]")], Gramext.action (fun _ (ntl : 'a_list) _ (rfl : 'row_field_list) _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))]) : @@ -3405,7 +3842,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; @@ -3417,7 +3855,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option (Some (Qast.Option None))]) : @@ -3428,7 +3867,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option None]) : 'ctyp))]]; Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e), @@ -3440,19 +3880,22 @@ Grammar.extend (Grammar.Entry.obj (row_field : 'row_field Grammar.Entry.e)), Gramext.Stoken ("", "|"))], Gramext.action - (fun (a : 'row_field list) (loc : int * int) -> + (fun (a : 'row_field list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (rfl : 'a_list) (loc : int * int) -> (rfl : 'row_field_list))]]; + (fun (rfl : 'a_list) (loc : Lexing.position * Lexing.position) -> + (rfl : 'row_field_list))]]; Grammar.Entry.obj (row_field : 'row_field Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) (loc : int * int) -> + (fun (t : 'ctyp) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("RfInh", [t]) : 'row_field)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e)); @@ -3462,34 +3905,39 @@ Grammar.extend (Gramext.srules [[Gramext.Stoken ("", "&")], Gramext.action - (fun (x : string) (loc : int * int) -> + (fun (x : string) + (loc : Lexing.position * Lexing.position) -> (Qast.Str x : 'e__26))])], Gramext.action - (fun (a : 'e__26 option) (loc : int * int) -> + (fun (a : 'e__26 option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.srules [[Gramext.Slist1sep (Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)), Gramext.Stoken ("", "&"))], Gramext.action - (fun (a : 'ctyp list) (loc : int * int) -> + (fun (a : 'ctyp list) (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (l : 'a_list) (ao : 'a_opt) _ (i : 'ident) _ (loc : int * int) -> + (fun (l : 'a_list) (ao : 'a_opt) _ (i : 'ident) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("RfTag", [i; o2b ao; l]) : 'row_field)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("RfTag", [i; Qast.Bool true; Qast.List []]) : 'row_field))]]; Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e), None, @@ -3497,7 +3945,8 @@ Grammar.extend [[Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (i : 'ident) _ (loc : int * int) -> (i : 'name_tag))]]; + (fun (i : 'ident) _ (loc : Lexing.position * Lexing.position) -> + (i : 'name_tag))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, @@ -3509,15 +3958,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (eo : 'a_opt) (p : 'patt_tcon) _ _ (loc : int * int) -> + (fun _ (eo : 'a_opt) (p : 'patt_tcon) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; Qast.Str ""; @@ -3527,7 +3979,8 @@ Grammar.extend (Grammar.Entry.obj (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_QUESTIONIDENT) (loc : int * int) -> + (fun (i : 'a_QUESTIONIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option None]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_OPTLABEL : 'a_OPTLABEL Grammar.Entry.e)); @@ -3539,16 +3992,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'a_opt) (p : 'patt_tcon) _ (i : 'a_OPTLABEL) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option (Some (Qast.Tuple [p; eo]))]) : @@ -3564,16 +4019,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'a_opt) (p : 'patt_tcon) _ _ (i : 'a_QUESTIONIDENT) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option (Some (Qast.Tuple [p; eo]))]) : @@ -3581,42 +4038,47 @@ Grammar.extend [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (i : 'a_TILDEIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option None]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_LABEL : 'a_LABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (p : 'patt) (i : 'a_LABEL) (loc : int * int) -> + (fun (p : 'patt) (i : 'a_LABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option (Some p)]) : 'patt)); [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (p : 'patt) _ (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (p : 'patt) _ (i : 'a_TILDEIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option (Some p)]) : 'patt)); [Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e))], Gramext.action - (fun (sl : 'mod_ident) _ (loc : int * int) -> + (fun (sl : 'mod_ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyp", [Qast.Loc; sl]) : 'patt)); [Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (s : 'ident) _ (loc : int * int) -> + (fun (s : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaVrn", [Qast.Loc; s]) : 'patt))]]; Grammar.Entry.obj (patt_tcon : 'patt_tcon Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e))], - Gramext.action (fun (p : 'patt) (loc : int * int) -> (p : 'patt_tcon)); + Gramext.action + (fun (p : 'patt) (loc : Lexing.position * Lexing.position) -> + (p : 'patt_tcon)); [Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (p : 'patt) (loc : int * int) -> + (fun (t : 'ctyp) _ (p : 'patt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyc", [Qast.Loc; p; t]) : 'patt_tcon))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, @@ -3628,15 +4090,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action - (fun _ (eo : 'a_opt) (p : 'ipatt_tcon) _ _ (loc : int * int) -> + (fun _ (eo : 'a_opt) (p : 'ipatt_tcon) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; Qast.Str ""; @@ -3646,7 +4111,8 @@ Grammar.extend (Grammar.Entry.obj (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_QUESTIONIDENT) (loc : int * int) -> + (fun (i : 'a_QUESTIONIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option None]) : 'ipatt)); [Gramext.Snterm (Grammar.Entry.obj (a_OPTLABEL : 'a_OPTLABEL Grammar.Entry.e)); @@ -3658,16 +4124,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'a_opt) (p : 'ipatt_tcon) _ (i : 'a_OPTLABEL) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option (Some (Qast.Tuple [p; eo]))]) : @@ -3683,16 +4151,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e)))], Gramext.action - (fun (a : 'eq_expr option) (loc : int * int) -> + (fun (a : 'eq_expr option) + (loc : Lexing.position * Lexing.position) -> (Qast.Option a : 'a_opt)); [Gramext.Snterm (Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e))], Gramext.action - (fun (a : 'a_opt) (loc : int * int) -> (a : 'a_opt))]; + (fun (a : 'a_opt) (loc : Lexing.position * Lexing.position) -> + (a : 'a_opt))]; Gramext.Stoken ("", ")")], Gramext.action (fun _ (eo : 'a_opt) (p : 'ipatt_tcon) _ _ (i : 'a_QUESTIONIDENT) - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaOlb", [Qast.Loc; i; Qast.Option (Some (Qast.Tuple [p; eo]))]) : @@ -3700,39 +4170,44 @@ Grammar.extend [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (i : 'a_TILDEIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option None]) : 'ipatt)); [Gramext.Snterm (Grammar.Entry.obj (a_LABEL : 'a_LABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (p : 'ipatt) (i : 'a_LABEL) (loc : int * int) -> + (fun (p : 'ipatt) (i : 'a_LABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option (Some p)]) : 'ipatt)); [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (p : 'ipatt) _ (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (p : 'ipatt) _ (i : 'a_TILDEIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaLab", [Qast.Loc; i; Qast.Option (Some p)]) : 'ipatt))]]; Grammar.Entry.obj (ipatt_tcon : 'ipatt_tcon Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e))], Gramext.action - (fun (p : 'ipatt) (loc : int * int) -> (p : 'ipatt_tcon)); + (fun (p : 'ipatt) (loc : Lexing.position * Lexing.position) -> + (p : 'ipatt_tcon)); [Gramext.Snterm (Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (p : 'ipatt) (loc : int * int) -> + (fun (t : 'ctyp) _ (p : 'ipatt) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyc", [Qast.Loc; p; t]) : 'ipatt_tcon))]]; Grammar.Entry.obj (eq_expr : 'eq_expr Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "="); Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) _ (loc : int * int) -> (e : 'eq_expr))]]; + (fun (e : 'expr) _ (loc : Lexing.position * Lexing.position) -> + (e : 'eq_expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.After "apply"), [Some "label", Some Gramext.NonA, @@ -3740,13 +4215,15 @@ Grammar.extend (Grammar.Entry.obj (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_QUESTIONIDENT) (loc : int * int) -> + (fun (i : 'a_QUESTIONIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExOlb", [Qast.Loc; i; Qast.Option None]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_OPTLABEL : 'a_OPTLABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'expr) (i : 'a_OPTLABEL) (loc : int * int) -> + (fun (e : 'expr) (i : 'a_OPTLABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExOlb", [Qast.Loc; i; Qast.Option (Some e)]) : 'expr)); [Gramext.Snterm @@ -3754,26 +4231,29 @@ Grammar.extend (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (i : 'a_QUESTIONIDENT) (loc : int * int) -> + (fun (e : 'expr) _ (i : 'a_QUESTIONIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExOlb", [Qast.Loc; i; Qast.Option (Some e)]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e))], Gramext.action - (fun (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (i : 'a_TILDEIDENT) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLab", [Qast.Loc; i; Qast.Option None]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_LABEL : 'a_LABEL Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'expr) (i : 'a_LABEL) (loc : int * int) -> + (fun (e : 'expr) (i : 'a_LABEL) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLab", [Qast.Loc; i; Qast.Option (Some e)]) : 'expr)); [Gramext.Snterm (Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e)); Gramext.Stoken ("", ":"); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ (i : 'a_TILDEIDENT) (loc : int * int) -> + (fun (e : 'expr) _ (i : 'a_TILDEIDENT) + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExLab", [Qast.Loc; i; Qast.Option (Some e)]) : 'expr))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), @@ -3782,17 +4262,19 @@ Grammar.extend [[Gramext.Stoken ("", "`"); Gramext.Snterm (Grammar.Entry.obj (ident : 'ident Grammar.Entry.e))], Gramext.action - (fun (s : 'ident) _ (loc : int * int) -> + (fun (s : 'ident) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExVrn", [Qast.Loc; s]) : 'expr))]]; Grammar.Entry.obj (direction_flag : 'direction_flag Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("", "downto")], Gramext.action - (fun _ (loc : int * int) -> (Qast.Bool false : 'direction_flag)); + (fun _ (loc : Lexing.position * Lexing.position) -> + (Qast.Bool false : 'direction_flag)); [Gramext.Stoken ("", "to")], Gramext.action - (fun _ (loc : int * int) -> (Qast.Bool true : 'direction_flag))]]; + (fun _ (loc : Lexing.position * Lexing.position) -> + (Qast.Bool true : 'direction_flag))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, @@ -3810,16 +4292,18 @@ Grammar.extend (Gramext.Snterm (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e)))], Gramext.action - (fun (a : 'name_tag list) (loc : int * int) -> + (fun (a : 'name_tag list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "|]")], Gramext.action (fun _ (ntl : 'a_list) _ (rfl : 'row_field_list) _ _ _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))]) : @@ -3834,7 +4318,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; @@ -3850,7 +4335,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option (Some (Qast.Option None))]) : @@ -3864,7 +4350,8 @@ Grammar.extend (row_field_list : 'row_field_list Grammar.Entry.e)); Gramext.Stoken ("", "|]")], Gramext.action - (fun _ (rfl : 'row_field_list) _ _ (loc : int * int) -> + (fun _ (rfl : 'row_field_list) _ _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyVrn", [Qast.Loc; rfl; Qast.Option None]) : 'ctyp))]]; Grammar.Entry.obj (warning_variant : 'warning_variant Grammar.Entry.e), @@ -3872,7 +4359,7 @@ Grammar.extend [None, None, [[], Gramext.action - (fun (loc : int * int) -> + (fun (loc : Lexing.position * Lexing.position) -> (warn_variant Qast.Loc : 'warning_variant))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "top"), @@ -3885,20 +4372,25 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__29))])], + (fun _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> + (e : 'e__29))])], Gramext.action - (fun (a : 'e__29 list) (loc : int * int) -> + (fun (a : 'e__29 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Stoken ("", "done")], Gramext.action - (fun _ _ (seq : 'a_list) _ (e : 'expr) _ (loc : int * int) -> + (fun _ _ (seq : 'a_list) _ (e : 'expr) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExWhi", [Qast.Loc; e; seq]) : 'expr)); [Gramext.Stoken ("", "for"); Gramext.Snterm @@ -3915,21 +4407,26 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__28))])], + (fun _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> + (e : 'e__28))])], Gramext.action - (fun (a : 'e__28 list) (loc : int * int) -> + (fun (a : 'e__28 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Stoken ("", "done")], Gramext.action (fun _ _ (seq : 'a_list) _ (e2 : 'expr) (df : 'direction_flag) - (e1 : 'expr) _ (i : 'a_LIDENT) _ (loc : int * int) -> + (e1 : 'expr) _ (i : 'a_LIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExFor", [Qast.Loc; i; e1; e2; df; seq]) : 'expr)); [Gramext.Stoken ("", "do"); Gramext.srules @@ -3939,78 +4436,85 @@ Grammar.extend (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (e : 'expr) (loc : int * int) -> (e : 'e__27))])], + (fun _ (e : 'expr) + (loc : Lexing.position * Lexing.position) -> + (e : 'e__27))])], Gramext.action - (fun (a : 'e__27 list) (loc : int * int) -> + (fun (a : 'e__27 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "return"); Gramext.Snterm (Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e)); Gramext.Sself], Gramext.action - (fun (e : 'expr) _ _ (seq : 'a_list) _ (loc : int * int) -> + (fun (e : 'expr) _ _ (seq : 'a_list) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExSeq", [Qast.Loc; append_elem seq e]) : 'expr))]]; Grammar.Entry.obj (warning_sequence : 'warning_sequence Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> + (fun (loc : Lexing.position * Lexing.position) -> (warn_sequence Qast.Loc : 'warning_sequence))]]; Grammar.Entry.obj (sequence : 'sequence Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "list")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "list" loc a : 'sequence))]]; Grammar.Entry.obj (expr_ident : 'expr_ident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'expr_ident))]]; Grammar.Entry.obj (patt_label_ident : 'patt_label_ident Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'patt_label_ident))]]; Grammar.Entry.obj (when_expr_opt : 'when_expr_opt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "when")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "when" loc a : 'when_expr_opt))]]; Grammar.Entry.obj (mod_ident : 'mod_ident Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'mod_ident))]]; Grammar.Entry.obj (clty_longident : 'clty_longident Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'clty_longident))]]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'clty_longident))]]; Grammar.Entry.obj (class_longident : 'class_longident Grammar.Entry.e), None, [None, None, [[Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'class_longident))]]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'class_longident))]]; Grammar.Entry.obj (direction_flag : 'direction_flag Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "to")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "to" loc a : 'direction_flag))]]; Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4025,18 +4529,22 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (cf : 'class_str_item) (loc : int * int) -> + (fun _ (cf : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (cf : 'e__30))])], Gramext.action - (fun (a : 'e__30 list) (loc : int * int) -> + (fun (a : 'e__30 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (csl : 'a_list) _ (x : string) _ (loc : int * int) -> + (fun _ (csl : 'a_list) _ (x : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.05" in Qast.Node ("CeStr", @@ -4049,7 +4557,8 @@ Grammar.extend (class_structure : 'class_structure Grammar.Entry.e)); Gramext.Stoken ("", "end")], Gramext.action - (fun _ (cf : 'class_structure) (x : string) _ (loc : int * int) -> + (fun _ (cf : 'class_structure) (x : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.05" in Qast.Node ("CeStr", [Qast.Loc; antiquot "" loc x; cf]) : 'class_expr))]]; @@ -4065,18 +4574,22 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (csf : 'class_sig_item) (loc : int * int) -> + (fun _ (csf : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (csf : 'e__32))])], Gramext.action - (fun (a : 'e__32 list) (loc : int * int) -> + (fun (a : 'e__32 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (csf : 'a_list) _ (x : string) _ (loc : int * int) -> + (fun _ (csf : 'a_list) _ (x : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.05" in Qast.Node ("CtSig", @@ -4092,18 +4605,22 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("", ";")], Gramext.action - (fun _ (csf : 'class_sig_item) (loc : int * int) -> + (fun _ (csf : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (csf : 'e__31))])], Gramext.action - (fun (a : 'e__31 list) (loc : int * int) -> + (fun (a : 'e__31 list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "end")], Gramext.action - (fun _ (csf : 'a_list) (x : string) _ (loc : int * int) -> + (fun _ (csf : 'a_list) (x : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.05" in Qast.Node ("CtSig", [Qast.Loc; antiquot "" loc x; csf]) : 'class_type))]]; @@ -4118,15 +4635,18 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action - (fun (x : 'expr) _ (l : 'a_list) (r : string) _ (loc : int * int) -> + (fun (x : 'expr) _ (l : 'a_list) (r : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("ExLet", [Qast.Loc; antiquot "rec" loc r; l; x]) : 'expr))]]; @@ -4141,14 +4661,17 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]], + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]], Gramext.action - (fun (l : 'a_list) (r : string) _ (loc : int * int) -> + (fun (l : 'a_list) (r : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("StVal", [Qast.Loc; antiquot "rec" loc r; l]) : 'str_item))]]; @@ -4163,16 +4686,18 @@ Grammar.extend (let_binding : 'let_binding Grammar.Entry.e)), Gramext.Stoken ("", "and"))], Gramext.action - (fun (a : 'let_binding list) (loc : int * int) -> + (fun (a : 'let_binding list) + (loc : Lexing.position * Lexing.position) -> (Qast.List a : 'a_list)); [Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) (loc : int * int) -> (a : 'a_list))]; + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; Gramext.Stoken ("", "in"); Gramext.Sself], Gramext.action (fun (ce : 'class_expr) _ (lb : 'a_list) (r : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("CeLet", [Qast.Loc; antiquot "rec" loc r; lb; ce]) : 'class_expr))]]; @@ -4186,7 +4711,7 @@ Grammar.extend (cvalue_binding : 'cvalue_binding Grammar.Entry.e))], Gramext.action (fun (e : 'cvalue_binding) (lab : 'label) (mf : string) _ - (loc : int * int) -> + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("CrVal", [Qast.Loc; lab; antiquot "mut" loc mf; e]) : 'class_str_item)); @@ -4195,7 +4720,8 @@ Grammar.extend (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e)); Gramext.Stoken ("ANTIQUOT", "as")], Gramext.action - (fun (pb : string) (ce : 'class_expr) _ (loc : int * int) -> + (fun (pb : string) (ce : 'class_expr) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("CrInh", [Qast.Loc; ce; antiquot "as" loc pb]) : 'class_str_item))]]; @@ -4207,7 +4733,8 @@ Grammar.extend Gramext.Stoken ("", ":"); Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e))], Gramext.action - (fun (t : 'ctyp) _ (l : 'label) (mf : string) _ (loc : int * int) -> + (fun (t : 'ctyp) _ (l : 'label) (mf : string) _ + (loc : Lexing.position * Lexing.position) -> (let _ = warn_antiq loc "3.06+18" in Qast.Node ("CgVal", [Qast.Loc; l; antiquot "mut" loc mf; t]) : 'class_sig_item))]]]);; @@ -4229,7 +4756,8 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (dir_param : 'dir_param Grammar.Entry.e))], Gramext.action - (fun (dp : 'dir_param) (n : 'a_LIDENT) _ (loc : int * int) -> + (fun (dp : 'dir_param) (n : 'a_LIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("StDir", [Qast.Loc; n; dp]) : 'str_item))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), None, [None, None, @@ -4239,20 +4767,22 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (dir_param : 'dir_param Grammar.Entry.e))], Gramext.action - (fun (dp : 'dir_param) (n : 'a_LIDENT) _ (loc : int * int) -> + (fun (dp : 'dir_param) (n : 'a_LIDENT) _ + (loc : Lexing.position * Lexing.position) -> (Qast.Node ("SgDir", [Qast.Loc; n; dp]) : 'sig_item))]]; Grammar.Entry.obj (dir_param : 'dir_param Grammar.Entry.e), None, [None, None, [[], Gramext.action - (fun (loc : int * int) -> (Qast.Option None : 'dir_param)); + (fun (loc : Lexing.position * Lexing.position) -> + (Qast.Option None : 'dir_param)); [Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e))], Gramext.action - (fun (e : 'expr) (loc : int * int) -> + (fun (e : 'expr) (loc : Lexing.position * Lexing.position) -> (Qast.Option (Some e) : 'dir_param)); [Gramext.Stoken ("ANTIQUOT", "opt")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "opt" loc a : 'dir_param))]]]);; (* Antiquotations *) @@ -4263,44 +4793,44 @@ Grammar.extend [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'module_expr)); [Gramext.Stoken ("ANTIQUOT", "mexp")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "mexp" loc a : 'module_expr))]]; Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e), Some (Gramext.Level "top"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'str_item)); [Gramext.Stoken ("ANTIQUOT", "stri")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "stri" loc a : 'str_item))]]; Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'module_type)); [Gramext.Stoken ("ANTIQUOT", "mtyp")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "mtyp" loc a : 'module_type))]]; Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e), Some (Gramext.Level "top"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'sig_item)); [Gramext.Stoken ("ANTIQUOT", "sigi")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "sigi" loc a : 'sig_item))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4309,18 +4839,19 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (el : 'a_list) _ (loc : int * int) -> + (fun _ (el : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExTup", [Qast.Loc; el]) : 'expr)); [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExAnt", [Qast.Loc; antiquot "anti" loc a]) : 'expr)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'expr)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'expr)); [Gramext.Stoken ("ANTIQUOT", "exp")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "exp" loc a : 'expr))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4329,18 +4860,19 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'a_list) _ (loc : int * int) -> + (fun _ (pl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTup", [Qast.Loc; pl]) : 'patt)); [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAnt", [Qast.Loc; antiquot "anti" loc a]) : 'patt)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'patt)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'patt)); [Gramext.Stoken ("ANTIQUOT", "pat")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "pat" loc a : 'patt))]]; Grammar.Entry.obj (ipatt : 'ipatt Grammar.Entry.e), None, [None, None, @@ -4348,18 +4880,19 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (pl : 'a_list) _ (loc : int * int) -> + (fun _ (pl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTup", [Qast.Loc; pl]) : 'ipatt)); [Gramext.Stoken ("ANTIQUOT", "anti")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaAnt", [Qast.Loc; antiquot "anti" loc a]) : 'ipatt)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'ipatt)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'ipatt)); [Gramext.Stoken ("ANTIQUOT", "pat")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "pat" loc a : 'ipatt))]]; Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4368,39 +4901,40 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e)); Gramext.Stoken ("", ")")], Gramext.action - (fun _ (tl : 'a_list) _ (loc : int * int) -> + (fun _ (tl : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("TyTup", [Qast.Loc; tl]) : 'ctyp)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'ctyp)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'ctyp)); [Gramext.Stoken ("ANTIQUOT", "typ")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "typ" loc a : 'ctyp))]]; Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'class_expr))]]; Grammar.Entry.obj (class_str_item : 'class_str_item Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'class_str_item))]]; Grammar.Entry.obj (class_sig_item : 'class_sig_item Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'class_sig_item))]]; Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'class_type))]]; Grammar.Entry.obj (expr : 'expr Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4409,7 +4943,7 @@ Grammar.extend Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e)); Gramext.Stoken ("", ">}")], Gramext.action - (fun _ (fel : 'a_list) _ (loc : int * int) -> + (fun _ (fel : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("ExOvr", [Qast.Loc; fel]) : 'expr))]]; Grammar.Entry.obj (patt : 'patt Grammar.Entry.e), Some (Gramext.Level "simple"), @@ -4417,125 +4951,179 @@ Grammar.extend [[Gramext.Stoken ("", "#"); Gramext.Snterm (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], Gramext.action - (fun (a : 'a_list) _ (loc : int * int) -> + (fun (a : 'a_list) _ (loc : Lexing.position * Lexing.position) -> (Qast.Node ("PaTyp", [Qast.Loc; a]) : 'patt))]]; Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "list")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "list" loc a : 'a_list))]]; Grammar.Entry.obj (a_opt : 'a_opt Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("ANTIQUOT", "opt")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "opt" loc a : 'a_opt))]]; Grammar.Entry.obj (a_UIDENT : 'a_UIDENT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("UIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> (Qast.Str i : 'a_UIDENT)); + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str i : 'a_UIDENT)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'a_UIDENT)); [Gramext.Stoken ("ANTIQUOT", "uid")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "uid" loc a : 'a_UIDENT))]]; Grammar.Entry.obj (a_LIDENT : 'a_LIDENT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LIDENT", "")], Gramext.action - (fun (i : string) (loc : int * int) -> (Qast.Str i : 'a_LIDENT)); + (fun (i : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str i : 'a_LIDENT)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'a_LIDENT)); [Gramext.Stoken ("ANTIQUOT", "lid")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "lid" loc a : 'a_LIDENT))]]; Grammar.Entry.obj (a_INT : 'a_INT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("INT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_INT)); + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_INT)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_INT)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_INT)); [Gramext.Stoken ("ANTIQUOT", "int")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "int" loc a : 'a_INT))]]; + Grammar.Entry.obj (a_INT32 : 'a_INT32 Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("INT32", "")], + Gramext.action + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_INT32)); + [Gramext.Stoken ("ANTIQUOT", "")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_INT32)); + [Gramext.Stoken ("ANTIQUOT", "int32")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "int32" loc a : 'a_INT32))]]; + Grammar.Entry.obj (a_INT64 : 'a_INT64 Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("INT64", "")], + Gramext.action + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_INT64)); + [Gramext.Stoken ("ANTIQUOT", "")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_INT64)); + [Gramext.Stoken ("ANTIQUOT", "int64")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "int64" loc a : 'a_INT64))]]; + Grammar.Entry.obj (a_NATIVEINT : 'a_NATIVEINT Grammar.Entry.e), None, + [None, None, + [[Gramext.Stoken ("NATIVEINT", "")], + Gramext.action + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_NATIVEINT)); + [Gramext.Stoken ("ANTIQUOT", "")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_NATIVEINT)); + [Gramext.Stoken ("ANTIQUOT", "nativeint")], + Gramext.action + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "nativeint" loc a : 'a_NATIVEINT))]]; Grammar.Entry.obj (a_FLOAT : 'a_FLOAT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("FLOAT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_FLOAT)); + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_FLOAT)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_FLOAT)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_FLOAT)); [Gramext.Stoken ("ANTIQUOT", "flo")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "flo" loc a : 'a_FLOAT))]]; Grammar.Entry.obj (a_STRING : 'a_STRING Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("STRING", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_STRING)); + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_STRING)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'a_STRING)); [Gramext.Stoken ("ANTIQUOT", "str")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "str" loc a : 'a_STRING))]]; Grammar.Entry.obj (a_CHAR : 'a_CHAR Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("CHAR", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_CHAR)); + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_CHAR)); [Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) (loc : int * int) -> (antiquot "" loc a : 'a_CHAR)); + (fun (a : string) (loc : Lexing.position * Lexing.position) -> + (antiquot "" loc a : 'a_CHAR)); [Gramext.Stoken ("ANTIQUOT", "chr")], Gramext.action - (fun (a : string) (loc : int * int) -> + (fun (a : string) (loc : Lexing.position * Lexing.position) -> (antiquot "chr" loc a : 'a_CHAR))]]; Grammar.Entry.obj (a_TILDEIDENT : 'a_TILDEIDENT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("TILDEIDENT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_TILDEIDENT)); + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_TILDEIDENT)); [Gramext.Stoken ("", "~"); Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) _ (loc : int * int) -> + (fun (a : string) _ (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'a_TILDEIDENT))]]; Grammar.Entry.obj (a_LABEL : 'a_LABEL Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("LABEL", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_LABEL))]]; + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_LABEL))]]; Grammar.Entry.obj (a_QUESTIONIDENT : 'a_QUESTIONIDENT Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("QUESTIONIDENT", "")], Gramext.action - (fun (s : string) (loc : int * int) -> + (fun (s : string) (loc : Lexing.position * Lexing.position) -> (Qast.Str s : 'a_QUESTIONIDENT)); [Gramext.Stoken ("", "?"); Gramext.Stoken ("ANTIQUOT", "")], Gramext.action - (fun (a : string) _ (loc : int * int) -> + (fun (a : string) _ (loc : Lexing.position * Lexing.position) -> (antiquot "" loc a : 'a_QUESTIONIDENT))]]; Grammar.Entry.obj (a_OPTLABEL : 'a_OPTLABEL Grammar.Entry.e), None, [None, None, [[Gramext.Stoken ("OPTLABEL", "")], Gramext.action - (fun (s : string) (loc : int * int) -> (Qast.Str s : 'a_OPTLABEL))]]];; + (fun (s : string) (loc : Lexing.position * Lexing.position) -> + (Qast.Str s : 'a_OPTLABEL))]]];; let apply_entry e = let f s = Grammar.Entry.parse e (Stream.of_string s) in @@ -4551,7 +5139,8 @@ Grammar.extend (Grammar.Entry.obj (sig_item : 'sig_item Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'sig_item) (loc : int * int) -> (x : 'sig_item_eoi))]]]; + (fun _ (x : 'sig_item) (loc : Lexing.position * Lexing.position) -> + (x : 'sig_item_eoi))]]]; Quotation.add "sig_item" (apply_entry sig_item_eoi);; let str_item_eoi = Grammar.Entry.create gram "structure item" in @@ -4562,7 +5151,8 @@ Grammar.extend (Grammar.Entry.obj (str_item : 'str_item Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'str_item) (loc : int * int) -> (x : 'str_item_eoi))]]]; + (fun _ (x : 'str_item) (loc : Lexing.position * Lexing.position) -> + (x : 'str_item_eoi))]]]; Quotation.add "str_item" (apply_entry str_item_eoi);; let ctyp_eoi = Grammar.Entry.create gram "type" in @@ -4572,7 +5162,8 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'ctyp) (loc : int * int) -> (x : 'ctyp_eoi))]]]; + (fun _ (x : 'ctyp) (loc : Lexing.position * Lexing.position) -> + (x : 'ctyp_eoi))]]]; Quotation.add "ctyp" (apply_entry ctyp_eoi);; let patt_eoi = Grammar.Entry.create gram "pattern" in @@ -4582,7 +5173,8 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (patt : 'patt Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'patt) (loc : int * int) -> (x : 'patt_eoi))]]]; + (fun _ (x : 'patt) (loc : Lexing.position * Lexing.position) -> + (x : 'patt_eoi))]]]; Quotation.add "patt" (apply_entry patt_eoi);; let expr_eoi = Grammar.Entry.create gram "expression" in @@ -4592,7 +5184,8 @@ Grammar.extend [[Gramext.Snterm (Grammar.Entry.obj (expr : 'expr Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'expr) (loc : int * int) -> (x : 'expr_eoi))]]]; + (fun _ (x : 'expr) (loc : Lexing.position * Lexing.position) -> + (x : 'expr_eoi))]]]; Quotation.add "expr" (apply_entry expr_eoi);; let module_type_eoi = Grammar.Entry.create gram "module type" in @@ -4604,7 +5197,7 @@ Grammar.extend (Grammar.Entry.obj (module_type : 'module_type Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'module_type) (loc : int * int) -> + (fun _ (x : 'module_type) (loc : Lexing.position * Lexing.position) -> (x : 'module_type_eoi))]]]; Quotation.add "module_type" (apply_entry module_type_eoi);; @@ -4617,7 +5210,7 @@ Grammar.extend (Grammar.Entry.obj (module_expr : 'module_expr Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'module_expr) (loc : int * int) -> + (fun _ (x : 'module_expr) (loc : Lexing.position * Lexing.position) -> (x : 'module_expr_eoi))]]]; Quotation.add "module_expr" (apply_entry module_expr_eoi);; @@ -4629,7 +5222,7 @@ Grammar.extend (Grammar.Entry.obj (class_type : 'class_type Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'class_type) (loc : int * int) -> + (fun _ (x : 'class_type) (loc : Lexing.position * Lexing.position) -> (x : 'class_type_eoi))]]]; Quotation.add "class_type" (apply_entry class_type_eoi);; @@ -4641,7 +5234,7 @@ Grammar.extend (Grammar.Entry.obj (class_expr : 'class_expr Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'class_expr) (loc : int * int) -> + (fun _ (x : 'class_expr) (loc : Lexing.position * Lexing.position) -> (x : 'class_expr_eoi))]]]; Quotation.add "class_expr" (apply_entry class_expr_eoi);; @@ -4656,7 +5249,8 @@ Grammar.extend (class_sig_item : 'class_sig_item Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'class_sig_item) (loc : int * int) -> + (fun _ (x : 'class_sig_item) + (loc : Lexing.position * Lexing.position) -> (x : 'class_sig_item_eoi))]]]; Quotation.add "class_sig_item" (apply_entry class_sig_item_eoi);; @@ -4671,7 +5265,8 @@ Grammar.extend (class_str_item : 'class_str_item Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'class_str_item) (loc : int * int) -> + (fun _ (x : 'class_str_item) + (loc : Lexing.position * Lexing.position) -> (x : 'class_str_item_eoi))]]]; Quotation.add "class_str_item" (apply_entry class_str_item_eoi);; @@ -4684,7 +5279,7 @@ Grammar.extend (Grammar.Entry.obj (with_constr : 'with_constr Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'with_constr) (loc : int * int) -> + (fun _ (x : 'with_constr) (loc : Lexing.position * Lexing.position) -> (x : 'with_constr_eoi))]]]; Quotation.add "with_constr" (apply_entry with_constr_eoi);; @@ -4696,5 +5291,6 @@ Grammar.extend (Grammar.Entry.obj (row_field : 'row_field Grammar.Entry.e)); Gramext.Stoken ("EOI", "")], Gramext.action - (fun _ (x : 'row_field) (loc : int * int) -> (x : 'row_field_eoi))]]]; + (fun _ (x : 'row_field) (loc : Lexing.position * Lexing.position) -> + (x : 'row_field_eoi))]]]; Quotation.add "row_field" (apply_entry row_field_eoi);; diff --git a/camlp4/ocaml_src/odyl/.depend b/camlp4/ocaml_src/odyl/.depend index b63c10b0b6..7823dd01b0 100644 --- a/camlp4/ocaml_src/odyl/.depend +++ b/camlp4/ocaml_src/odyl/.depend @@ -1,6 +1,6 @@ +odyl.cmo: odyl_config.cmo odyl_main.cmi +odyl.cmx: odyl_config.cmx odyl_main.cmx odyl_main.cmo: $(OTOP)/otherlibs/dynlink/dynlink.cmi odyl_config.cmo \ odyl_main.cmi odyl_main.cmx: odyl_config.cmx \ odyl_main.cmi -odyl.cmo: odyl_config.cmo odyl_main.cmi -odyl.cmx: odyl_config.cmx odyl_main.cmx diff --git a/camlp4/ocpp/Makefile b/camlp4/ocpp/Makefile index 60729e323c..f3d844d0cb 100644 --- a/camlp4/ocpp/Makefile +++ b/camlp4/ocpp/Makefile @@ -12,7 +12,7 @@ OBJS=ocpp.cmo all: ocpp$(EXE) ocpp$(EXE): $(OBJS) - $(OCAMLC) $(LINKFLAGS) ../boot/stdpp.cmo ../camlp4/quotation.cmo ../odyl/odyl.cma $(OBJS) ../odyl/odyl.cmo -linkall -o ocpp$(EXE) + $(OCAMLC) $(LINKFLAGS) ../boot/stdpp.cmo ../camlp4/reloc.cmo ../camlp4/quotation.cmo ../odyl/odyl.cma $(OBJS) ../odyl/odyl.cmo -linkall -o ocpp$(EXE) clean:: rm -f *.cm[ioa] *.pp[io] *.o *.out *.bak .*.bak ocpp$(EXE) diff --git a/camlp4/ocpp/ocpp.ml b/camlp4/ocpp/ocpp.ml index afe517c0e5..92c939455b 100644 --- a/camlp4/ocpp/ocpp.ml +++ b/camlp4/ocpp/ocpp.ml @@ -46,7 +46,16 @@ and inside_locate cs = | [: :] -> raise (Stream.Error "end of file in locate directive") ] ; +value nowhere = { + Lexing.pos_fname = ""; + Lexing.pos_lnum = 0; + Lexing.pos_bol = 0; + Lexing.pos_cnum = 0 +} +; + value quot name pos str = + let pos = Reloc.shift_pos pos nowhere in let exp = try match Quotation.find name with @@ -54,13 +63,13 @@ value quot name pos str = | _ -> raise Not_found ] with [ Not_found -> - Stdpp.raise_with_loc (pos, pos + String.length str) Not_found ] + Stdpp.raise_with_loc (pos, Reloc.shift_pos (String.length str) pos) Not_found ] in let new_str = try exp True str with [ Stdpp.Exc_located (p1, p2) exc -> - Stdpp.raise_with_loc (pos + p1, pos + p2) exc - | exc -> Stdpp.raise_with_loc (pos, pos + String.length str) exc ] + Stdpp.raise_with_loc (Reloc.adjust_loc pos (p1, p2)) exc + | exc -> Stdpp.raise_with_loc (pos, Reloc.shift_pos (String.length str) pos) exc ] in let cs = Stream.of_string new_str in copy_strip_locate cs ; diff --git a/camlp4/tools/camlp4_comm.sh b/camlp4/tools/camlp4_comm.sh index b6bb8f87ed..61189dae13 100755 --- a/camlp4/tools/camlp4_comm.sh +++ b/camlp4/tools/camlp4_comm.sh @@ -1,4 +1,5 @@ #!/bin/sh +======= # $Id$ ARGS1= @@ -24,7 +25,7 @@ if test "$2" = "camlp4r" -o "$2" = "camlp4"; then fi shift; shift ARGS2=`echo $* | sed -e "s/[()*]//g"` -# ARGS1="$ARGS1 -verbose" + ARGS1="$ARGS1 -verbose" if test "$QUIET" = "no"; then echo $COMM $ARGS2 $ARGS1 $FILE; fi $COMM $ARGS2 $ARGS1 $FILE else diff --git a/camlp4/top/Makefile b/camlp4/top/Makefile index 4ea4e46bc2..d2b795e86c 100644 --- a/camlp4/top/Makefile +++ b/camlp4/top/Makefile @@ -5,15 +5,17 @@ include ../config/Makefile INCLUDES=-I ../camlp4 -I ../boot -I $(OTOP)/utils -I $(OTOP)/parsing -I $(OTOP)/typing -I $(OTOP)/toplevel OCAMLCFLAGS=-warn-error A $(INCLUDES) -CAMLP4_OBJS=$(OTOP)/utils/config.cmo ../boot/stdpp.cmo ../boot/token.cmo ../boot/plexer.cmo ../boot/gramext.cmo ../boot/grammar.cmo ../boot/extfold.cmo ../boot/extfun.cmo ../boot/fstream.cmo ../camlp4/quotation.cmo ../camlp4/ast2pt.cmo ../camlp4/reloc.cmo ../camlp4/spretty.cmo ../camlp4/pcaml.cmo +CAMLP4_OBJS=$(OTOP)/utils/config.cmo ../boot/stdpp.cmo ../boot/token.cmo ../boot/plexer.cmo ../boot/gramext.cmo ../boot/grammar.cmo ../boot/extfold.cmo ../boot/extfun.cmo ../boot/fstream.cmo ../camlp4/quotation.cmo ../camlp4/reloc.cmo ../camlp4/spretty.cmo ../camlp4/pcaml.cmo ../camlp4/ast2pt.cmo TOP=camlp4_top.cmo ROBJS=$(CAMLP4_OBJS) ../meta/pa_r.cmo ../meta/pa_rp.cmo rprint.cmo $(TOP) -SOBJS=$(CAMLP4_OBJS) ../etc/pa_scheme.cmo $(TOP) +# pa_scheme needs to use new locations SOBJS=$(CAMLP4_OBJS) ../etc/pa_scheme.cmo $(TOP) +SOBJS=$(CAMLP4_OBJS) $(TOP) OOBJS=$(CAMLP4_OBJS) ../etc/pa_o.cmo ../etc/pa_op.cmo $(TOP) OOOBJS=$(CAMLP4_OBJS) ../etc/pa_o.cmo ../etc/pa_oop.cmo $(TOP) -OBJS=$(OTOP)/utils/config.cmo ../camlp4/quotation.cmo ../camlp4/reloc.cmo ../camlp4/ast2pt.cmo ../camlp4/spretty.cmo ../camlp4/pcaml.cmo camlp4_top.cmo +OBJS=$(OTOP)/utils/config.cmo ../camlp4/quotation.cmo ../camlp4/reloc.cmo ../camlp4/spretty.cmo ../camlp4/pcaml.cmo ../camlp4/ast2pt.cmo camlp4_top.cmo -TARGET=camlp4o.cma camlp4r.cma camlp4sch.cma camlp4_top.cma +# camlp4sch.cma needs to use new locations TARGET=camlp4o.cma camlp4r.cma camlp4sch.cma camlp4_top.cma +TARGET=camlp4o.cma camlp4r.cma camlp4_top.cma all: $(TARGET) diff --git a/camlp4/top/camlp4_top.ml b/camlp4/top/camlp4_top.ml index 4d0d12f785..65d7d643d7 100644 --- a/camlp4/top/camlp4_top.ml +++ b/camlp4/top/camlp4_top.ml @@ -59,8 +59,9 @@ value highlight_locations lb loc1 loc2 = value print_location lb loc = if String.length Toploop.input_name.val = 0 then - highlight_locations lb loc (-1, -1) - else Toploop.print_location Format.err_formatter (Ast2pt.mkloc loc) + highlight_locations lb ((fst loc).Lexing.pos_cnum, (snd loc).Lexing.pos_cnum) (-1, -1) + else Toploop.print_location Format.err_formatter + (Ast2pt.mkloc loc) ; value wrap f shfn lb = diff --git a/camlp4/top/rprint.ml b/camlp4/top/rprint.ml index 76f19fe11e..bfac0188d7 100644 --- a/camlp4/top/rprint.ml +++ b/camlp4/top/rprint.ml @@ -167,8 +167,8 @@ and print_simple_out_type ppf = | Ovar_name id tyl -> fprintf ppf "@[%a%a@]" print_typargs tyl print_ident id ] in - fprintf ppf "%s[|%s@[<hv>@[<hv>%a@]%a|]@]" (if non_gen then "_" else "") - (if closed then if tags = None then " " else "< " + fprintf ppf "%s[%s@[<hv>@[<hv>%a@]%a ]@]" (if non_gen then "_" else "") + (if closed then if tags = None then "= " else "< " else if tags = None then "> " else "? ") print_fields row_fields @@ -313,12 +313,14 @@ and print_out_signature ppf = print_out_signature items ] and print_out_sig_item ppf = fun - [ Osig_class vir_flag name params clt -> - fprintf ppf "@[<2>class%s@ %a%s@ :@ %a@]" + [ Osig_class vir_flag name params clt rs -> + fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]" + (if rs = Orec_next then "and" else "class") (if vir_flag then " virtual" else "") print_out_class_params params name Toploop.print_out_class_type.val clt - | Osig_class_type vir_flag name params clt -> - fprintf ppf "@[<2>class type%s@ %a%s@ =@ %a@]" + | Osig_class_type vir_flag name params clt rs -> + fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]" + (if rs = Orec_next then "and" else "class type") (if vir_flag then " virtual" else "") print_out_class_params params name Toploop.print_out_class_type.val clt | Osig_exception id tyl -> @@ -328,10 +330,16 @@ and print_out_sig_item ppf = | Osig_modtype name mty -> fprintf ppf "@[<2>module type %s =@ %a@]" name Toploop.print_out_module_type.val mty - | Osig_module name mty -> - fprintf ppf "@[<2>module %s :@ %a@]" name + | Osig_module name mty rs -> + fprintf ppf "@[<2>%s %s :@ %a@]" name + (match rs with [ Orec_not -> "module" + | Orec_first -> "module rec" + | Orec_next -> "and" ]) Toploop.print_out_module_type.val mty - | Osig_type tdl -> print_out_type_decl_list ppf tdl + | Osig_type td rs -> + print_out_type_decl + (if rs = Orec_next then "and" else "type") + ppf td | Osig_value name ty prims -> let kwd = if prims = [] then "value" else "external" in let pr_prims ppf = @@ -345,16 +353,7 @@ and print_out_sig_item ppf = in fprintf ppf "@[<2>%s %a :@ %a%a@]" kwd value_ident name Toploop.print_out_type.val ty pr_prims prims ] -and print_out_type_decl_list ppf = - fun - [ [] -> () - | [x] -> print_out_type_decl "type" ppf x - | [x :: l] -> - do { - print_out_type_decl "type" ppf x; - List.iter (fun x -> fprintf ppf "@ %a" (print_out_type_decl "and") x) - l - } ] + and print_out_type_decl kwd ppf (name, args, ty, constraints) = let constrain ppf (ty, ty') = fprintf ppf "@ @[<2>constraint %a =@ %a@]" Toploop.print_out_type.val ty |