]> matita.cs.unibo.it Git - helm.git/blob - helm/www/lambda_delta/bin/xhtbl/textLexer.mll
update ...
[helm.git] / helm / www / lambda_delta / bin / xhtbl / textLexer.mll
1 {
2    module S  = String
3    module O  = Options
4    module TP = TextParser
5    
6    let trim s = S.sub s 1 (S.length s - 2)
7    
8    let out s = if !O.debug_lexer then prerr_endline s
9 }
10
11 let SPC = ['\r' '\n' '\t' ' ']+
12 let QT  = '"'
13 let STR = QT [^'"']* QT
14 let NUM = ['0'-'9']+
15
16 rule token = parse
17    | SPC      { token lexbuf                    }
18    | STR as s { out s; TP.TEXT (trim s)         }
19    | NUM as s { out s; TP.NUM (int_of_string s) }
20    | "{"      { out "{"; TP.OC                  }
21    | "}"      { out "}"; TP.CC                  }
22    | "["      { out "["; TP.OB                  }
23    | "]"      { out "]"; TP.CB                  }   
24    | "*"      { out "*"; TP.SR                  }
25    | "name"   { out "name"; TP.NAME             }   
26    | "table"  { out "table"; TP.TABLE           }
27    | "class"  { out "class"; TP.CSS             }
28    | eof      { TP.EOF                          }