]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/mathql/mQueryTParser.mly
a small correction to mathQL.ml
[helm.git] / helm / ocaml / mathql / mQueryTParser.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 /*                                                                            */
28 /*                               PROJECT HELM                                 */
29 /*                                                                            */
30 /*                     Ferruccio Guidi <fguidi@cs.unibo.it>                   */
31 /*                                 23/05/2002                                 */
32 /*                                                                            */
33 /*                                                                            */
34 /******************************************************************************/
35
36 %{
37 %}
38    %token    <string> ID STR
39    %token    LC RC CM SC LP RP AT PC DL FS DQ EOF 
40    %token    AND ATTR ATTRIB DIFF EQ FALSE FUN IN INTER NOT OR PAT REF REFOF
41    %token    REL SELECT SUB SUPER TRUE UNION WHERE
42    %left     DIFF
43    %left     OR UNION
44    %left     AND INTER
45    %nonassoc NOT
46    %start    qstr ref query
47    %type     <string>              qstr      
48    %type     <MathQL.resource_set> query   
49 %%
50    qstr:
51       | QT       { ""      }
52       | STR qstr { $1 @ $2 }
53    ;
54    svar:
55       | PC ID { $2 }
56    ;
57    rvar:
58       | AT ID { $2 }
59    ;
60    vvar:
61       | DL ID { $2 }
62    ;
63    val:
64       | MCONCL    { MQMConclusion   }
65       | CONCL     { MQConclusion    }
66       | STR       { MQCons $1       } 
67       | rvar      { MQStringRVar $1 }
68       | svar      { MQStringSVar $1 }
69       | func rvar { MQFunc ($1, $2) }
70    ;
71    boole:
72       | TRUE            { MQTrue         }
73       | FALSE           { MQFalse        }
74       | str IS str      { MQIs ($1, $3)  }
75       | NOT boole       { MQNot $2       }
76       | boole AND boole { MQAnd ($1, $3) }
77       | boole OR boole  { MQOr ($1, $3)  }
78       | LPR boole RPR   { $2             }
79    ;   
80    rlist:
81       | PATT REF                         { MQPattern $2          } 
82       | rlist UNION rlist                { MQUnion ($1, $3)      }
83       | rlist INTER rlist                { MQIntersect ($1, $3)  }
84       | USE rlist POS svar               { MQUse ($2, $4)        }
85       | USEDBY rlist POS svar            { MQUsedBy ($2, $4)     }
86       | SELECT rvar IN rlist WHERE boole { MQSelect ($2, $4, $6) }
87       | LPR rlist RPR                    { $2                    }
88    ;
89    query:
90       rlist EOF { MQList $1 }
91    ;