From c540548108057140163c63c50710fda2e5c6ea8f Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Mon, 26 Nov 2007 15:30:52 +0000 Subject: [PATCH] add dump of position information in the lexed file --- helm/software/components/content_pres/test_lexer.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/helm/software/components/content_pres/test_lexer.ml b/helm/software/components/content_pres/test_lexer.ml index b032d7f61..393017a44 100644 --- a/helm/software/components/content_pres/test_lexer.ml +++ b/helm/software/components/content_pres/test_lexer.ml @@ -44,14 +44,17 @@ let _ = 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 -- 2.39.2