]> matita.cs.unibo.it Git - helm.git/blob - helm/www/lambdadelta/bin/xhtbl/textLexer.mll
planned dehyphenation of lambdadelta eventually took place!
[helm.git] / helm / www / lambdadelta / 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    | "+"      { out "+"; TP.PS                  }
26    | "name"   { out "name"; TP.NAME             }   
27    | "table"  { out "table"; TP.TABLE           }
28    | "class"  { out "class"; TP.CSS             }
29    | "(*"     { block lexbuf; token lexbuf      }
30    | eof      { TP.EOF                          }
31 and block = parse
32    | "*)"     { ()                              }
33    | "(*"     { block lexbuf; block lexbuf      }
34    | STR      { block lexbuf                    }
35    | _        { block lexbuf                    }