summaryrefslogtreecommitdiff
path: root/lex/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lex/main.ml')
-rw-r--r--lex/main.ml20
1 files changed, 15 insertions, 5 deletions
diff --git a/lex/main.ml b/lex/main.ml
index d97820151f..03b9ac91ef 100644
--- a/lex/main.ml
+++ b/lex/main.ml
@@ -55,6 +55,9 @@ let main () =
let oc = open_out dest_name in
let tr = Common.open_tracker dest_name oc in
let lexbuf = Lexing.from_channel ic in
+ lexbuf.Lexing.lex_curr_p <-
+ {Lexing.pos_fname = source_name; Lexing.pos_lnum = 1;
+ Lexing.pos_bol = 0; Lexing.pos_cnum = 0};
try
let def = Parser.lexer_definition Lexer.main lexbuf in
let (entries, transitions) = Lexgen.make_dfa def.entrypoints in
@@ -76,15 +79,22 @@ let main () =
Common.close_tracker tr;
Sys.remove dest_name;
begin match exn with
- Parsing.Parse_error ->
+ | Cset.Bad ->
+ let p = Lexing.lexeme_start_p lexbuf in
+ Printf.fprintf stderr
+ "File \"%s\", line %d, character %d: character set expected.\n"
+ p.Lexing.pos_fname p.Lexing.pos_lnum
+ (p.Lexing.pos_cnum - p.Lexing.pos_bol)
+ | Parsing.Parse_error ->
+ let p = Lexing.lexeme_start_p lexbuf in
Printf.fprintf stderr
"File \"%s\", line %d, character %d: syntax error.\n"
- source_name !Lexer.line_num
- (Lexing.lexeme_start lexbuf - !Lexer.line_start_pos)
- | Lexer.Lexical_error(msg, line, col) ->
+ p.Lexing.pos_fname p.Lexing.pos_lnum
+ (p.Lexing.pos_cnum - p.Lexing.pos_bol)
+ | Lexer.Lexical_error(msg, file, line, col) ->
Printf.fprintf stderr
"File \"%s\", line %d, character %d: %s.\n"
- source_name line col msg
+ file line col msg
| Lexgen.Memory_overflow ->
Printf.fprintf stderr
"File \"%s\":\n Position memory overflow, too many bindings\n"