]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/binaries/transcript/v8Lexer.mll
transcript: improved debuugging facilities
[helm.git] / helm / software / components / binaries / transcript / v8Lexer.mll
index 57f7d16ae1bff92121e55c2b05bbefc357a99600..0ef38a919b55604548d120eaf607004d2d961e52 100644 (file)
@@ -1,7 +1,17 @@
 {
+   module O = Options
    module P = V8Parser
    
-   let out t s = prerr_endline (t ^ " " ^ s)
+   let out t s = if !O.verbose_lexer then prerr_endline (t ^ " " ^ s)
+
+   let check s =
+      let c = Char.code s.[0] in
+      if c <= 127 then s else 
+      let escaped = Printf.sprintf "\\%3u\\" c in
+      begin 
+         if !O.verbose_escape then Printf.eprintf "ESCAPED: %s %s\n" s escaped;
+        escaped 
+      end
 }
 
 let QT    = '"'
@@ -89,6 +99,6 @@ rule token = parse
    | ";"           { let s = Lexing.lexeme lexbuf in out "SC" s; P.SC s      }
    | ":"           { let s = Lexing.lexeme lexbuf in out "CN" s; P.CN s      }
    | ","           { let s = Lexing.lexeme lexbuf in out "CM" s; P.CM s      }
-   | ".."          { let s = Lexing.lexeme lexbuf in out "SPEC" s; P.EXTRA s }
-   | _             { let s = Lexing.lexeme lexbuf in out "SPEC" s; P.EXTRA s }
+   | _             
+      { let s = check (Lexing.lexeme lexbuf) in out "SPEC" s; P.EXTRA s }
    | eof           { let s = Lexing.lexeme lexbuf in out "EOF" s; P.EOF      }