]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql/mQueryTLexer.mll
textual parser and other utilities for mathql
[helm.git] / helm / ocaml / mathql / mQueryTLexer.mll
diff --git a/helm/ocaml/mathql/mQueryTLexer.mll b/helm/ocaml/mathql/mQueryTLexer.mll
new file mode 100644 (file)
index 0000000..0075f3a
--- /dev/null
@@ -0,0 +1,88 @@
+(* Copyright (C) 2000, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(******************************************************************************)
+(*                                                                            *)
+(*                               PROJECT HELM                                 *)
+(*                                                                            *)
+(*                     Ferruccio Guidi <fguidi@cs.unibo.it>                   *)
+(*                                 23/05/2002                                 *)
+(*                                                                            *)
+(*                                                                            *)
+(******************************************************************************)
+
+{ 
+   open MQueryTParser
+}
+
+let SPC   = [' ' '\t' '\n']+
+let ALPHA = ['A'-'Z' 'a'-'z']
+let NUM   = ['0'-'9']
+let IDEN  = ALPHA (NUM | ALPHA)*
+let DQ    = '"'
+let SQ    = '''
+let QSTR  = [^ ''']*
+let USTR  = [^ '"' ':' '/' '#' '?' '*']+
+
+rule rtoken = parse
+   | DQ               { DQT   }
+   | ":/"             { PROT  }
+   | "/"              { SLASH }
+   | "#1"             { FRAG  }
+   | "?"              { QUEST }
+   | "**"             { SSTAR }
+   | "*"              { STAR  }
+   | USTR             { STR (Lexing.lexeme lexbuf) }
+and stoken = parse
+   | SQ               { SQT   }
+   | QSTR             { STR (Lexing.lexeme lexbuf) }
+and qtoken = parse
+   | SPC              { qtoken lexbuf }
+   | '('              { LPR    }
+   | ')'              { RPR    }
+   | '$'              { DLR    }
+   | SQ               { STR (qstr stoken lexbuf) }
+   | DQ               { REF (ref rtoken lexbuf) }
+   | "name"           { NAME   }
+   | "mainconclusion" { MCONCL }
+   | "conclusion"     { CONCL  }
+   | "true"           { TRUE   }
+   | "false"          { FALSE  }
+   | "and"            { AND    }
+   | "or"             { OR     }
+   | "not"            { NOT    }
+   | "is"             { IS     }
+   | "select"         { SELECT }
+   | "in"             { IN     }
+   | "where"          { WHERE  }
+   | "use"            { USE    }
+   | "position"       { POS    }
+   | "usedby"         { USEDBY }
+   | "pattern"        { PATT   }
+   | "union"          { UNION  }
+   | "intersect"      { INTER  }
+   | IDEN             { ID (Lexing.lexeme lexbuf) }
+   | eof              { EOF   }
+