X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fcontent_pres%2Ftest_lexer.ml;h=587d87bd898fd63bc3823ac32e19e3929c47b56f;hb=f9abd21eb0d26cf9b632af4df819225be4d091e3;hp=b032d7f61d7b5d6c3d3394fef80431baf151f0ef;hpb=55b82bd235d82ff7f0a40d980effe1efde1f5073;p=helm.git diff --git a/helm/software/components/content_pres/test_lexer.ml b/helm/software/components/content_pres/test_lexer.ml index b032d7f61..587d87bd8 100644 --- a/helm/software/components/content_pres/test_lexer.ml +++ b/helm/software/components/content_pres/test_lexer.ml @@ -37,21 +37,24 @@ let _ = Arg.parse arg_spec open_file usage; let lexer = match !level with - "1" -> CicNotationLexer.level1_pattern_lexer - | "2@" -> CicNotationLexer.level2_ast_lexer - | "2$" -> CicNotationLexer.level2_meta_lexer + "1" -> CicNotationLexer.level1_pattern_lexer () + | "2@" -> CicNotationLexer.level2_ast_lexer () + | "2$" -> CicNotationLexer.level2_meta_lexer () | l -> 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 + (Stdpp.first_pos pos) (Stdpp.last_pos pos)); + incr tok_count; dump () in try