X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fcomponents%2Fbinaries%2Fprobe%2FmacLexer.mll;fp=matita%2Fcomponents%2Fbinaries%2Fprobe%2FmacLexer.mll;h=5e4c01d3d39b3e4efeea963f823c45e3cb268a9a;hb=9722a8d7b63e62f2b5b00de008304485371f7bf6;hp=0000000000000000000000000000000000000000;hpb=c62bc0725203409f99fd10eaf0b670a406e311b3;p=helm.git diff --git a/matita/components/binaries/probe/macLexer.mll b/matita/components/binaries/probe/macLexer.mll new file mode 100644 index 000000000..5e4c01d3d --- /dev/null +++ b/matita/components/binaries/probe/macLexer.mll @@ -0,0 +1,43 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department, University of Bologna, Italy. + ||I|| + ||T|| HELM is free software; you can redistribute it and/or + ||A|| modify it under the terms of the GNU General Public License + \ / version 2 or (at your option) any later version. + \ / This software is distributed as is, NO WARRANTY. + V_______________________________________________________________ *) + +{ + module O = Options + + let out s = if !O.debug_lexer then prerr_endline s +} + +let OL = "(*" +let CL = "*)" +let UNI = ['\x80'-'\xBF']+ +let SPC = ['\r' '\n' '\t' ' ']+ +let WRD = ['0'-'9' 'A'-'Z' 'a'-'z' '_']+ +let QT = '"' + +rule token = parse + | OL { out "COM"; block lexbuf; token lexbuf } + | QT { out "STR"; O.chars := !O.chars + str lexbuf; token lexbuf } + | SPC { out "SPC"; incr O.chars; token lexbuf } + | UNI { out "UNI"; incr O.chars; token lexbuf } + | WRD { out "WRD"; incr O.chars; token lexbuf } + | _ { out "CHR"; incr O.chars; token lexbuf } + | eof { out "EOF" } +and str = parse + | QT { 2 } + | "\\\"" { succ (str lexbuf) } + | UNI { succ (str lexbuf) } + | WRD { succ (str lexbuf) } + | _ { succ (str lexbuf) } +and block = parse + | CL { () } + | OL { block lexbuf; block lexbuf } + | QT { let _ = str lexbuf in block lexbuf } + | _ { block lexbuf }