]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/probe/macLexer.mll
commit in ground_2, static_2, basic_2, apps_2
[helm.git] / matita / components / binaries / probe / macLexer.mll
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 {
13    module O = Options
14    
15    let out s = if !O.debug_lexer then prerr_endline s
16 }
17
18 let OL  = "(*"
19 let CL  = "*)" 
20 let UNI = ['\x80'-'\xBF']+
21 let SPC = ['\r' '\n' '\t' ' ']+
22 let WRD = ['0'-'9' 'A'-'Z' 'a'-'z' '_']+
23 let QT  = '"'
24
25 rule token = parse
26    | OL     { out "COM"; block lexbuf; token lexbuf                     }
27    | QT     { out "STR"; O.chars := !O.chars + str lexbuf; token lexbuf }
28    | SPC    { out "SPC"; incr O.chars; token lexbuf                     }
29    | UNI    { out "UNI"; incr O.chars; token lexbuf                     }
30    | WRD    { out "WRD"; incr O.chars; token lexbuf                     }
31    | _      { out "CHR"; incr O.chars; token lexbuf                     }
32    | eof    { out "EOF"                                                 }
33 and str = parse
34    | QT     { 2 }
35    | "\\\"" { succ (str lexbuf)                                         }
36    | UNI    { succ (str lexbuf)                                         }
37    | WRD    { succ (str lexbuf)                                         }
38    | _      { succ (str lexbuf)                                         }
39 and block = parse
40    | CL     { ()                                                        }
41    | OL     { block lexbuf; block lexbuf                                }
42    | QT     { let _ = str lexbuf in block lexbuf                        }
43    | _      { block lexbuf                                              }