]> matita.cs.unibo.it Git - helm.git/blob - helm/mathql_test/mQGTopParser.mly
ocaml 3.09 transition
[helm.git] / helm / 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 /*  AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
27  */
28
29 %{
30    let f (x, y, z) = x
31    let s (x, y, z) = y
32    let t (x, y, z) = z
33
34    module T = MQGTypes
35    module U = MQGUtil
36 %}
37    %token <string> ID
38    %token <UriManager.uri> CONURI
39    %token <UriManager.uri> VARURI
40    %token <UriManager.uri * int> INDTYURI
41    %token <UriManager.uri * int * int> INDCONURI
42    %token ALIAS EOF
43
44    %start interp
45    %type  <CicTextualParser0.interpretation_domain_item -> CicTextualParser0.interpretation_codomain_item option> interp
46    
47    %token <string> STR
48    %token DL DQ LC RC CM 
49    %token MOBJ MSORT MREL OOBJ OSORT OREL UNIV
50    
51    %start qstr specs
52    %type  <string>                    qstr
53    %type  <MQGTypes.spec list> specs
54 %%
55    uri:
56       | CONURI    { CicTextualParser0.ConUri $1                           }
57       | VARURI    { CicTextualParser0.VarUri $1                           }
58       | INDTYURI  { CicTextualParser0.IndTyUri ((fst $1), (snd $1))       }
59       | INDCONURI { CicTextualParser0.IndConUri ((f $1), (s $1), (t $1))  }
60    ;
61    alias:      
62       | ALIAS ID uri { ($2, CicTextualParser0.Uri $3) }
63    ;
64    aliases:
65       | alias aliases { $1 :: $2 } 
66       | EOF           { []       }
67    ;
68    interp:
69       | aliases { function CicTextualParser0.Id s -> (try Some (List.assoc s $1) 
70                                     with Not_found -> None)
71                          | _ -> None }
72    ;
73
74    qstr:
75       | DQ       { ""      }
76       | STR qstr { $1 ^ $2 }
77    ;
78    strs:
79       | STR CM strs { $1 :: $3 }
80       | STR         { [$1]     }
81       |             { []       }
82    ;
83    uri_list:
84       | LC strs RC { List.map U.uri_of_mathql $2 }
85    ;
86    sort_list:
87       | LC strs RC { List.map U.sort_of_mathql $2 }
88    ;
89    pos_list:
90       | LC strs RC { List.map U.position_of_mathql $2 }
91    ;
92    depth_list:
93       | LC strs RC { List.map U.depth_of_mathql $2 }
94    ;
95    spec:
96       | MOBJ  uri_list pos_list depth_list  { T.MustObj  ($2, $3, $4) }
97       | MSORT sort_list pos_list depth_list { T.MustSort ($2, $3, $4) }
98       | MREL  pos_list depth_list           { T.MustRel  ($2, $3)     }
99       | OOBJ  uri_list pos_list depth_list  { T.OnlyObj  ($2, $3, $4) }
100       | OSORT sort_list pos_list depth_list { T.OnlySort ($2, $3, $4) }
101       | OREL  pos_list depth_list           { T.OnlyRel  ($2, $3)     }
102       | UNIV  pos_list                      { T.Universe $2           }
103    ;   
104    specs:
105       | spec specs { $1 :: $2 }
106       | EOF        { []       }
107    ;