]> matita.cs.unibo.it Git - helm.git/blob - matita/components/binaries/mac/lexer.mll
lambdadelta
[helm.git] / matita / components / binaries / mac / lexer.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 QT  = '"'
23
24 rule token = parse
25    | OL     { out "COM"; block lexbuf; token lexbuf                     }
26    | QT     { out "STR"; O.count := !O.count + str lexbuf; token lexbuf }
27    | SPC    { out "SPC"; incr O.count; token lexbuf                     }
28    | UNI    { out "UNI"; token lexbuf                                   }
29    | _      { out "CHR"; incr O.count; token lexbuf                     }
30    | eof    { out "EOF"                                                 }
31 and str = parse
32    | QT     { 2 }
33    | "\\\"" { succ (str lexbuf)                                         }
34    | UNI    { str lexbuf                                                }
35    | _      { succ (str lexbuf)                                         }
36 and block = parse
37    | CL     { ()                                                        }
38    | OL     { block lexbuf; block lexbuf                                }
39    | QT     { let _ = str lexbuf in block lexbuf                        }
40    | _      { block lexbuf                                              }