summaryrefslogtreecommitdiff
path: root/lex
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2013-09-04 15:12:37 +0000
committerDamien Doligez <damien.doligez-inria.fr>2013-09-04 15:12:37 +0000
commit7844495624be79259e613182e6a615319b2f4376 (patch)
tree8656b9339174ab9061b42be2b50c2d9563401c8a /lex
parente9723139769a4df610fadba0fdeecab298c1c17e (diff)
downloadocaml-7844495624be79259e613182e6a615319b2f4376.tar.gz
Merge branch 4.01 from branching point to 4.01.0+rc1
Command line used: svn merge --accept postpone -r 13776:14055 $REPO/version/4.01 . git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14060 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'lex')
-rw-r--r--lex/common.ml8
-rw-r--r--lex/common.mli3
-rw-r--r--lex/lexer.mll3
-rw-r--r--lex/output.ml8
-rw-r--r--lex/outputbis.ml8
-rw-r--r--lex/parser.mly4
-rw-r--r--lex/syntax.ml12
-rw-r--r--lex/syntax.mli12
8 files changed, 32 insertions, 26 deletions
diff --git a/lex/common.ml b/lex/common.ml
index d52cbb94c4..36f8225e31 100644
--- a/lex/common.ml
+++ b/lex/common.ml
@@ -68,9 +68,9 @@ let copy_chars =
"Win32" | "Cygwin" -> copy_chars_win32
| _ -> copy_chars_unix
-let copy_chunk sourcefile ic oc trl loc add_parens =
+let copy_chunk ic oc trl loc add_parens =
if loc.start_pos < loc.end_pos || add_parens then begin
- fprintf oc "# %d \"%s\"\n" loc.start_line sourcefile;
+ fprintf oc "# %d \"%s\"\n" loc.start_line loc.loc_file;
if add_parens then begin
for _i = 1 to loc.start_col - 1 do output_char oc ' ' done;
output_char oc '(';
@@ -122,7 +122,7 @@ let output_tag_access oc = function
| Sum (a,i) ->
fprintf oc "(%a + %d)" output_base_mem a i
-let output_env sourcefile ic oc tr env =
+let output_env ic oc tr env =
let pref = ref "let" in
match env with
| [] -> ()
@@ -138,7 +138,7 @@ let output_env sourcefile ic oc tr env =
List.iter
(fun ((x,pos),v) ->
fprintf oc "%s\n" !pref ;
- copy_chunk sourcefile ic oc tr pos false ;
+ copy_chunk ic oc tr pos false ;
begin match v with
| Ident_string (o,nstart,nend) ->
fprintf oc
diff --git a/lex/common.mli b/lex/common.mli
index f85baa01f8..c71febe8c6 100644
--- a/lex/common.mli
+++ b/lex/common.mli
@@ -14,13 +14,12 @@ type line_tracker;;
val open_tracker : string -> out_channel -> line_tracker
val close_tracker : line_tracker -> unit
val copy_chunk :
- string ->
in_channel -> out_channel -> line_tracker -> Syntax.location -> bool -> unit
val output_mem_access : out_channel -> int -> unit
val output_memory_actions :
string -> out_channel -> Lexgen.memory_action list -> unit
val output_env :
- string -> in_channel -> out_channel -> line_tracker ->
+ in_channel -> out_channel -> line_tracker ->
(Lexgen.ident * Lexgen.ident_info) list -> unit
val output_args : out_channel -> string list -> unit
diff --git a/lex/lexer.mll b/lex/lexer.mll
index 699c859924..8fc472e684 100644
--- a/lex/lexer.mll
+++ b/lex/lexer.mll
@@ -166,12 +166,13 @@ rule main = parse
}
| '{'
{ let p = Lexing.lexeme_end_p lexbuf in
+ let f = p.Lexing.pos_fname in
let n1 = p.Lexing.pos_cnum
and l1 = p.Lexing.pos_lnum
and s1 = p.Lexing.pos_bol in
brace_depth := 1;
let n2 = handle_lexical_error action lexbuf in
- Taction({start_pos = n1; end_pos = n2;
+ Taction({loc_file = f; start_pos = n1; end_pos = n2;
start_line = l1; start_col = n1 - s1}) }
| '=' { Tequal }
| '|' { Tor }
diff --git a/lex/output.ml b/lex/output.ml
index ae1df0e1fd..d99f2f9010 100644
--- a/lex/output.ml
+++ b/lex/output.ml
@@ -92,8 +92,8 @@ let output_entry sourcefile ic oc oci e =
(fun (num, env, loc) ->
fprintf oc " | ";
fprintf oc "%d ->\n" num;
- output_env sourcefile ic oc oci env;
- copy_chunk sourcefile ic oc oci loc true;
+ output_env ic oc oci env;
+ copy_chunk ic oc oci loc true;
fprintf oc "\n")
e.auto_actions;
fprintf oc " | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; \
@@ -123,7 +123,7 @@ let output_lexdef sourcefile ic oc oci header tables entry_points trailer =
Printf.printf "%d additional bytes used for bindings\n" size_groups ;
flush stdout;
if Array.length tables.tbl_trans > 0x8000 then raise Table_overflow;
- copy_chunk sourcefile ic oc oci header false;
+ copy_chunk ic oc oci header false;
output_tables oc tables;
begin match entry_points with
[] -> ()
@@ -134,4 +134,4 @@ let output_lexdef sourcefile ic oc oci header tables entry_points trailer =
entries;
output_string oc ";;\n\n";
end;
- copy_chunk sourcefile ic oc oci trailer false
+ copy_chunk ic oc oci trailer false
diff --git a/lex/outputbis.ml b/lex/outputbis.ml
index 57851ab495..7e8cba6e17 100644
--- a/lex/outputbis.ml
+++ b/lex/outputbis.ml
@@ -165,8 +165,8 @@ let output_entry sourcefile ic oc tr e =
(fun (num, env, loc) ->
fprintf oc " | ";
fprintf oc "%d ->\n" num;
- output_env sourcefile ic oc tr env ;
- copy_chunk sourcefile ic oc tr loc true;
+ output_env ic oc tr env ;
+ copy_chunk ic oc tr loc true;
fprintf oc "\n")
e.auto_actions;
fprintf oc " | _ -> raise (Failure \"lexing: empty token\")\n\n\n"
@@ -176,7 +176,7 @@ let output_entry sourcefile ic oc tr e =
let output_lexdef sourcefile ic oc tr header entry_points transitions trailer =
- copy_chunk sourcefile ic oc tr header false;
+ copy_chunk ic oc tr header false;
output_automata oc transitions ;
begin match entry_points with
[] -> ()
@@ -187,4 +187,4 @@ let output_lexdef sourcefile ic oc tr header entry_points transitions trailer =
entries;
output_string oc ";;\n\n";
end;
- copy_chunk sourcefile ic oc tr trailer false
+ copy_chunk ic oc tr trailer false
diff --git a/lex/parser.mly b/lex/parser.mly
index fe8260d766..b42cced949 100644
--- a/lex/parser.mly
+++ b/lex/parser.mly
@@ -74,7 +74,8 @@ header:
Taction
{ $1 }
| /*epsilon*/
- { { start_pos = 0; end_pos = 0; start_line = 1; start_col = 0 } }
+ { { loc_file = ""; start_pos = 0; end_pos = 0; start_line = 1;
+ start_col = 0 } }
;
named_regexps:
named_regexps Tlet Tident Tequal regexp
@@ -162,6 +163,7 @@ regexp:
{let p1 = Parsing.rhs_start_pos 3
and p2 = Parsing.rhs_end_pos 3 in
let p = {
+ loc_file = p1.Lexing.pos_fname ;
start_pos = p1.Lexing.pos_cnum ;
end_pos = p2.Lexing.pos_cnum ;
start_line = p1.Lexing.pos_lnum ;
diff --git a/lex/syntax.ml b/lex/syntax.ml
index afa6ac3b01..72f101e253 100644
--- a/lex/syntax.ml
+++ b/lex/syntax.ml
@@ -15,11 +15,13 @@
(* The shallow abstract syntax *)
-type location =
- { start_pos: int;
- end_pos: int;
- start_line: int;
- start_col: int }
+type location = {
+ loc_file : string;
+ start_pos : int;
+ end_pos : int;
+ start_line : int;
+ start_col : int;
+}
type regular_expression =
Epsilon
diff --git a/lex/syntax.mli b/lex/syntax.mli
index d186f12c39..55c3c117a1 100644
--- a/lex/syntax.mli
+++ b/lex/syntax.mli
@@ -12,11 +12,13 @@
(* The shallow abstract syntax *)
-type location =
- { start_pos: int;
- end_pos: int;
- start_line: int;
- start_col: int }
+type location = {
+ loc_file : string;
+ start_pos : int;
+ end_pos : int;
+ start_line : int;
+ start_col : int;
+}
type regular_expression =
Epsilon