]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql_test/mQGTopParser.mly
MathQL query generator: new interface
[helm.git] / helm / ocaml / mathql_test / mQGTopParser.mly
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    let f (x, y, z) = x
28    let s (x, y, z) = y
29    let t (x, y, z) = z
30    
31    module G = MQueryGenerator
32 %}
33    %token <string> ID
34    %token <UriManager.uri> CONURI
35    %token <UriManager.uri> VARURI
36    %token <UriManager.uri * int> INDTYURI
37    %token <UriManager.uri * int * int> INDCONURI
38    %token ALIAS EOF
39
40    %start interp
41    %type  <CicTextualParser0.interpretation_domain_item -> CicTextualParser0.interpretation_codomain_item option> interp
42    
43    %token <string> STR
44    %token DL DQ LC RC CM NOT
45    %token MOBJ MSORT MREL SOBJ SSORT OREL WOBJ WSORT
46    
47    %start qstr 
48    %type  <string>                       qstr
49 %%
50    uri:
51       | CONURI    { CicTextualParser0.ConUri $1                           }
52       | VARURI    { CicTextualParser0.VarUri $1                           }
53       | INDTYURI  { CicTextualParser0.IndTyUri ((fst $1), (snd $1))       }
54       | INDCONURI { CicTextualParser0.IndConUri ((f $1), (s $1), (t $1))  }
55    ;
56    alias:      
57       | ALIAS ID uri { ($2, CicTextualParser0.Uri $3) }
58    ;
59    aliases:
60       | alias aliases { $1 :: $2 } 
61       | EOF           { []       }
62    ;
63    interp:
64       | aliases { function CicTextualParser0.Id s -> (try Some (List.assoc s $1) 
65                                     with Not_found -> None)
66                          | _ -> None }
67    ;
68
69    qstr:
70       | DQ       { ""      }
71       | STR qstr { $1 ^ $2 }
72    ;
73 /*   str:
74       | STR   { $1                            }
75       | DL ID { try G.builtin $2 with _ -> "" }
76    ;
77    strs:
78       | str CM strs { $1 :: $3 }
79       | str         { [$1]     }
80       |             { []       }
81    ;
82    list:
83       | LC strs RC { $2 }
84    ;
85    not: 
86       | NOT { true  }
87       |     { false }
88    ;
89    spec:
90       | MOBJ  not list list list { G.MustObj   ($2, $3, $4, $5) }
91       | MSORT not list list list { G.MustSort  ($2, $3, $4, $5) }
92       | MREL  not list list      { G.MustRel   ($2, $3, $4)     }
93       | SOBJ  not list list list { G.SOnlyObj  ($2, $3, $4, $5) }
94       | SSORT not list list list { G.SOnlySort ($2, $3, $4, $5) }
95       | OREL  not list list      { G.OnlyRel   ($2, $3, $4)     }
96       | WOBJ  not list list list { G.WOnlyObj  ($2, $3, $4, $5) }
97       | WSORT not list list list { G.WOnlySort ($2, $3, $4, $5) }
98    ;   
99    specs:
100       | spec specs { $1 :: $2 }
101       | EOF        { []       }
102    ;
103 */