]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql/mQueryTLexer.mll
textual parser and other utilities for mathql
[helm.git] / helm / ocaml / mathql / mQueryTLexer.mll
1 (* Copyright (C) 2000, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 (******************************************************************************)
27 (*                                                                            *)
28 (*                               PROJECT HELM                                 *)
29 (*                                                                            *)
30 (*                     Ferruccio Guidi <fguidi@cs.unibo.it>                   *)
31 (*                                 23/05/2002                                 *)
32 (*                                                                            *)
33 (*                                                                            *)
34 (******************************************************************************)
35
36
37    open MQueryTParser
38 }
39
40 let SPC   = [' ' '\t' '\n']+
41 let ALPHA = ['A'-'Z' 'a'-'z']
42 let NUM   = ['0'-'9']
43 let IDEN  = ALPHA (NUM | ALPHA)*
44 let DQ    = '"'
45 let SQ    = '''
46 let QSTR  = [^ ''']*
47 let USTR  = [^ '"' ':' '/' '#' '?' '*']+
48
49 rule rtoken = parse
50    | DQ               { DQT   }
51    | ":/"             { PROT  }
52    | "/"              { SLASH }
53    | "#1"             { FRAG  }
54    | "?"              { QUEST }
55    | "**"             { SSTAR }
56    | "*"              { STAR  }
57    | USTR             { STR (Lexing.lexeme lexbuf) }
58 and stoken = parse
59    | SQ               { SQT   }
60    | QSTR             { STR (Lexing.lexeme lexbuf) }
61 and qtoken = parse
62    | SPC              { qtoken lexbuf }
63    | '('              { LPR    }
64    | ')'              { RPR    }
65    | '$'              { DLR    }
66    | SQ               { STR (qstr stoken lexbuf) }
67    | DQ               { REF (ref rtoken lexbuf) }
68    | "name"           { NAME   }
69    | "mainconclusion" { MCONCL }
70    | "conclusion"     { CONCL  }
71    | "true"           { TRUE   }
72    | "false"          { FALSE  }
73    | "and"            { AND    }
74    | "or"             { OR     }
75    | "not"            { NOT    }
76    | "is"             { IS     }
77    | "select"         { SELECT }
78    | "in"             { IN     }
79    | "where"          { WHERE  }
80    | "use"            { USE    }
81    | "position"       { POS    }
82    | "usedby"         { USEDBY }
83    | "pattern"        { PATT   }
84    | "union"          { UNION  }
85    | "intersect"      { INTER  }
86    | IDEN             { ID (Lexing.lexeme lexbuf) }
87    | eof              { EOF   }
88