]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_test/mQGTopParser.mly
MathQL query generator: new interface
[helm.git] / helm / ocaml / mathql_test / mQGTopParser.mly
diff --git a/helm/ocaml/mathql_test/mQGTopParser.mly b/helm/ocaml/mathql_test/mQGTopParser.mly
new file mode 100644 (file)
index 0000000..9fd70a0
--- /dev/null
@@ -0,0 +1,103 @@
+/* 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/.
+ */
+
+%{
+   let f (x, y, z) = x
+   let s (x, y, z) = y
+   let t (x, y, z) = z
+   
+   module G = MQueryGenerator
+%}
+   %token <string> ID
+   %token <UriManager.uri> CONURI
+   %token <UriManager.uri> VARURI
+   %token <UriManager.uri * int> INDTYURI
+   %token <UriManager.uri * int * int> INDCONURI
+   %token ALIAS EOF
+
+   %start interp
+   %type  <CicTextualParser0.interpretation_domain_item -> CicTextualParser0.interpretation_codomain_item option> interp
+   
+   %token <string> STR
+   %token DL DQ LC RC CM NOT
+   %token MOBJ MSORT MREL SOBJ SSORT OREL WOBJ WSORT
+   
+   %start qstr 
+   %type  <string>                       qstr
+%%
+   uri:
+      | CONURI    { CicTextualParser0.ConUri $1                           }
+      | VARURI    { CicTextualParser0.VarUri $1                           }
+      | INDTYURI  { CicTextualParser0.IndTyUri ((fst $1), (snd $1))       }
+      | INDCONURI { CicTextualParser0.IndConUri ((f $1), (s $1), (t $1))  }
+   ;
+   alias:      
+      | ALIAS ID uri { ($2, CicTextualParser0.Uri $3) }
+   ;
+   aliases:
+      | alias aliases { $1 :: $2 } 
+      | EOF           { []       }
+   ;
+   interp:
+      | aliases { function CicTextualParser0.Id s -> (try Some (List.assoc s $1) 
+                                    with Not_found -> None)
+                        | _ -> None }
+   ;
+
+   qstr:
+      | DQ       { ""      }
+      | STR qstr { $1 ^ $2 }
+   ;
+/*   str:
+      | STR   { $1                            }
+      | DL ID { try G.builtin $2 with _ -> "" }
+   ;
+   strs:
+      | str CM strs { $1 :: $3 }
+      | str         { [$1]     }
+      |             { []       }
+   ;
+   list:
+      | LC strs RC { $2 }
+   ;
+   not: 
+      | NOT { true  }
+      |     { false }
+   ;
+   spec:
+      | MOBJ  not list list list { G.MustObj   ($2, $3, $4, $5) }
+      | MSORT not list list list { G.MustSort  ($2, $3, $4, $5) }
+      | MREL  not list list      { G.MustRel   ($2, $3, $4)     }
+      | SOBJ  not list list list { G.SOnlyObj  ($2, $3, $4, $5) }
+      | SSORT not list list list { G.SOnlySort ($2, $3, $4, $5) }
+      | OREL  not list list      { G.OnlyRel   ($2, $3, $4)     }
+      | WOBJ  not list list list { G.WOnlyObj  ($2, $3, $4, $5) }
+      | WSORT not list list list { G.WOnlySort ($2, $3, $4, $5) }
+   ;   
+   specs:
+      | spec specs { $1 :: $2 }
+      | EOF        { []       }
+   ;
+*/