]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/bin/xhtbl/textLexer.mll
update in ground
[helm.git] / matita / matita / contribs / lambdadelta / bin / xhtbl / textLexer.mll
1 {
2    module S  = String
3    
4    module O  = Options
5    module TP = TextParser
6    
7    let out s = if !O.debug_lexer then prerr_endline s
8 }
9
10 let SPC = ['\r' '\n' '\t' ' ']+
11 let QT  = "\""
12 let NUM = ['0'-'9']+
13
14 rule token = parse
15    | SPC      { token lexbuf                    }
16    | QT       { let s = str lexbuf in 
17                 out s; TP.TEXT s                }
18    | NUM as s { out s; TP.NUM (int_of_string s) }
19    | "(*"     { block lexbuf; token lexbuf      }
20    | "{"      { out "{"; TP.OC                  }
21    | "}"      { out "}"; TP.CC                  }
22    | "["      { out "["; TP.OB                  }
23    | "]"      { out "]"; TP.CB                  }   
24    | "*"      { out "*"; TP.SR                  }
25    | "^"      { out "^"; TP.CF                  }
26    | "+"      { out "+"; TP.PS                  }
27    | "("      { out "("; TP.OP                  }
28    | ")"      { out ")"; TP.CP                  }   
29    | "@"      { out ")"; TP.AT                  }    
30    | "space"  { out "space"; TP.SPACE           }
31    | "name"   { out "name"; TP.NAME             }   
32    | "table"  { out "table"; TP.TABLE           }
33    | "class"  { out "class"; TP.CSS             }
34    | "uri"    { out "uri"; TP.URI               }
35    | "ext"    { out "ext"; TP.EXT               }
36    | eof      { TP.EOF                          }
37 and str = parse
38    | QT       { ""                              }
39    | "\\\\"   { "\\" ^ str lexbuf               }
40    | "\\\""   { "\"" ^ str lexbuf               }
41    | "\\ "    { "\xC2\xA0" ^ str lexbuf         }
42    | _ as c   { S.make 1 c ^ str lexbuf         }
43 and block = parse
44    | "*)"     { ()                              }
45    | "(*"     { block lexbuf; block lexbuf      }
46    | QT       { let _ = str lexbuf in
47                 block lexbuf                    }
48    | _        { block lexbuf                    }