prerr_endline (Printf.sprintf "Unsupported level %s" l);
exit 2
in
- let token_stream =
- fst (lexer.Token.tok_func (Obj.magic (Ulexing.from_utf8_channel !ic)))
- in
+ let token_stream, loc_func =
+ lexer.Token.tok_func (Obj.magic (Ulexing.from_utf8_channel !ic)) in
Printf.printf "Lexing notation level %s\n" !level; flush stdout;
+ let tok_count = ref 0 in
let rec dump () =
let (a,b) = Stream.next token_stream in
if a = "EOI" then raise Stream.Failure;
- print_endline (Printf.sprintf "%s '%s'" a b);
+ let pos = loc_func !tok_count in
+ print_endline (Printf.sprintf "%s '%s' (@ %d-%d)" a b
+ (Ploc.first_pos pos) (Ploc.last_pos pos));
+ incr tok_count;
dump ()
in
try