1 /* Copyright (C) 2000, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 /******************************************************************************/
30 /* Ferruccio Guidi <fguidi@cs.unibo.it> */
34 /******************************************************************************/
38 %token <string> ID STR
39 %token IS LC RC CM SC LP RP AT PC DL FS DQ EOF
40 %token AND ATTR ATTRIB BE DIFF EQ EX FALSE FUN IN INTER LET MEET NOT OR
41 %token PAT REF REFOF REL SELECT SUB SUPER TRUE UNION WHERE
42 %left DIFF WHERE REFOF
45 %nonassoc NOT EX IN STR ATTR
46 %start qstr query result
48 %type <MathQL.query> query
49 %type <MathQL.result> result
53 | STR qstr { $1 ^ $2 }
65 | STR CM qstr_list { $1 :: $3 }
69 | vvar CM vvar_list { $1 :: $3 }
73 | SUB { MathQL.SubOp }
74 | SUPER { MathQL.SuperOp }
78 | STR { MathQL.Const [$1] }
79 | FUN STR val_exp { MathQL.Fun ($2, $3) }
80 | ATTRIB ref_op STR val_exp { MathQL.Attribute ($2, $3, $4) }
81 | rvar FS vvar { MathQL.Record ($1, $3) }
82 | LC qstr_list RC { MathQL.Const $2 }
83 | LC RC { MathQL.Const [] }
84 | REFOF set_exp { MathQL.RefOf $2 }
87 | TRUE { MathQL.True }
88 | FALSE { MathQL.False }
89 | LP boole_exp RP { $2 }
90 | NOT boole_exp { MathQL.Not $2 }
91 | EX boole_exp { MathQL.Ex $2 }
92 | val_exp SUB val_exp { MathQL.Sub ($1, $3) }
93 | val_exp MEET val_exp { MathQL.Meet ($1, $3) }
94 | val_exp EQ val_exp { MathQL.Eq ($1, $3) }
95 | boole_exp AND boole_exp { MathQL.And ($1, $3) }
96 | boole_exp OR boole_exp { MathQL.Or ($1, $3) }
99 | REF val_exp { MathQL.Ref $2 }
100 | PAT val_exp { MathQL.Pattern $2 }
101 | LP set_exp RP { $2 }
102 | SELECT rvar IN set_exp WHERE boole_exp { MathQL.Select ($2, $4, $6) }
103 | REL ref_op STR set_exp ATTR vvar_list { MathQL.Relation ($2, $3, $4, $6) }
104 | REL ref_op STR set_exp { MathQL.Relation ($2, $3, $4, []) }
105 | svar { MathQL.SVar $1 }
106 | rvar { MathQL.RVar $1 }
107 | set_exp UNION set_exp { MathQL.Union ($1, $3) }
108 | set_exp INTER set_exp { MathQL.Intersect ($1, $3) }
109 | set_exp DIFF set_exp { MathQL.Diff ($1, $3) }
110 | LET svar BE set_exp IN set_exp { MathQL.Let ($2, $4, $6) }
116 | STR IS qstr_list { ($1, $3) }
120 | attribute SC attr_list { $1 :: $3 }
124 LC attr_list RC { $2 }
127 | group CM group_list { $1 :: $3 }
131 | STR ATTR group_list { ($1, $3) }
135 | resource SC resource_list { $1 :: $3 }
140 | resource_list EOF { $1 }