m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/query.cup
blob: 6460d785f1dc9c9a75c4ff83cc5214c73e17a7ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// -*- Java -*- This Cup file was machine-generated by BNFC
package pl.edu.mimuw.mmws.cloudatlas.query;

parser code {:
  public pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program pProgram() throws Exception
  {
	java_cup.runtime.Symbol res = parse();
	return (pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program) res.value;
  }

public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; }

public void syntax_error(java_cup.runtime.Symbol cur_token)
{
	report_error("Syntax Error, trying to recover and continue parse...", cur_token);
}

public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception
{
	throw new Exception("Unrecoverable Syntax Error");
}

:}

nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListStatement ListStatement;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListOrderItem ListOrderItem;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListSelItem ListSelItem;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr ListCondExpr;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Program Program;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Statement Statement;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Where Where;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderBy OrderBy;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderItem OrderItem;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Order Order;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.Nulls Nulls;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.SelItem SelItem;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExpr BoolExpr;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr1;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExpr CondExpr2;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr1;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr2;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExpr BasicExpr3;
nonterminal pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOp RelOp;

terminal _SYMB_0;    //   ;
terminal _SYMB_1;    //   ,
terminal _SYMB_2;    //   +
terminal _SYMB_3;    //   -
terminal _SYMB_4;    //   *
terminal _SYMB_5;    //   /
terminal _SYMB_6;    //   %
terminal _SYMB_7;    //   (
terminal _SYMB_8;    //   )
terminal _SYMB_9;    //   >
terminal _SYMB_10;    //   =
terminal _SYMB_11;    //   <>
terminal _SYMB_12;    //   <
terminal _SYMB_13;    //   <=
terminal _SYMB_14;    //   >=
terminal _SYMB_15;    //   AND
terminal _SYMB_16;    //   AS
terminal _SYMB_17;    //   ASC
terminal _SYMB_18;    //   BY
terminal _SYMB_19;    //   DESC
terminal _SYMB_20;    //   FIRST
terminal _SYMB_21;    //   LAST
terminal _SYMB_22;    //   NOT
terminal _SYMB_23;    //   NULLS
terminal _SYMB_24;    //   OR
terminal _SYMB_25;    //   ORDER
terminal _SYMB_26;    //   REGEXP
terminal _SYMB_27;    //   SELECT
terminal _SYMB_28;    //   WHERE

terminal String _STRING_;





terminal String QBool;
terminal String QIdent;
terminal String QDouble;
terminal String QInteger;


start with Program;


ListStatement ::= Statement:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListStatement(); RESULT.addLast(p_1); :} 
  | Statement:p_1 _SYMB_0 ListStatement:p_3  {: RESULT = p_3; p_3.addFirst(p_1); :}
;
ListOrderItem ::= OrderItem:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListOrderItem(); RESULT.addLast(p_1); :} 
  | OrderItem:p_1 _SYMB_1 ListOrderItem:p_3  {: RESULT = p_3; p_3.addFirst(p_1); :}
;
ListSelItem ::= SelItem:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListSelItem(); RESULT.addLast(p_1); :} 
  | SelItem:p_1 _SYMB_1 ListSelItem:p_3  {: RESULT = p_3; p_3.addFirst(p_1); :}
;
ListCondExpr ::=  /* empty */  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr(); :} 
  | CondExpr:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ListCondExpr(); RESULT.addLast(p_1); :}
  | CondExpr:p_1 _SYMB_1 ListCondExpr:p_3  {: RESULT = p_3; p_3.addFirst(p_1); :}
;
Program ::= ListStatement:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ProgramC(p_1); :} 
;
Statement ::= _SYMB_27 ListSelItem:p_2 Where:p_3 OrderBy:p_4  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.StatementC(p_2,p_3,p_4); :} 
;
Where ::=  /* empty */  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoWhereC(); :} 
  | _SYMB_28 CondExpr:p_2  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.WhereC(p_2); :}
;
OrderBy ::=  /* empty */  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoOrderByC(); :} 
  | _SYMB_25 _SYMB_18 ListOrderItem:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderByC(p_3); :}
;
OrderItem ::= CondExpr:p_1 Order:p_2 Nulls:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.OrderItemC(p_1,p_2,p_3); :} 
;
Order ::= _SYMB_17  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.AscOrderC(); :} 
  | _SYMB_19  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.DescOrderC(); :}
  |  /* empty */  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoOrderC(); :}
;
Nulls ::=  /* empty */  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NoNullsC(); :} 
  | _SYMB_23 _SYMB_20  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NullFirstsC(); :}
  | _SYMB_23 _SYMB_21  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.NullsLastC(); :}
;
SelItem ::= CondExpr:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.SelItemC(p_1); :} 
  | CondExpr:p_1 _SYMB_16 QIdent:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.AliasedSelItemC(p_1,p_3); :}
;
BoolExpr ::= BasicExpr:p_1 RelOp:p_2 BasicExpr:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprCmpC(p_1,p_2,p_3); :} 
  | BasicExpr:p_1 _SYMB_26 _STRING_:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprRegExpC(p_1,p_3); :}
  | BasicExpr:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BoolExprBasicExprC(p_1); :}
;
CondExpr ::= CondExpr:p_1 _SYMB_24 CondExpr1:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprOrC(p_1,p_3); :} 
  | CondExpr1:p_1  {: RESULT = p_1; :}
;
CondExpr1 ::= CondExpr1:p_1 _SYMB_15 CondExpr2:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprAndC(p_1,p_3); :} 
  | CondExpr2:p_1  {: RESULT = p_1; :}
;
CondExpr2 ::= _SYMB_22 CondExpr2:p_2  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprNotC(p_2); :} 
  | BoolExpr:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.CondExprBoolExprC(p_1); :}
;
BasicExpr ::= BasicExpr:p_1 _SYMB_2 BasicExpr1:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprAddC(p_1,p_3); :} 
  | BasicExpr:p_1 _SYMB_3 BasicExpr1:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprSubC(p_1,p_3); :}
  | BasicExpr1:p_1  {: RESULT = p_1; :}
;
BasicExpr1 ::= BasicExpr1:p_1 _SYMB_4 BasicExpr2:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprMulC(p_1,p_3); :} 
  | BasicExpr1:p_1 _SYMB_5 BasicExpr2:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprDivC(p_1,p_3); :}
  | BasicExpr1:p_1 _SYMB_6 BasicExpr2:p_3  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprModC(p_1,p_3); :}
  | BasicExpr2:p_1  {: RESULT = p_1; :}
;
BasicExpr2 ::= _SYMB_3 BasicExpr2:p_2  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.BasicExprNegC(p_2); :} 
  | BasicExpr3:p_1  {: RESULT = p_1; :}
;
BasicExpr3 ::= QBool:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EBoolC(p_1); :} 
  | QIdent:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EIdentC(p_1); :}
  | QIdent:p_1 _SYMB_7 ListCondExpr:p_3 _SYMB_8  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EFunC(p_1,p_3); :}
  | _STRING_:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EStrC(p_1); :}
  | QInteger:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EIntC(p_1); :}
  | QDouble:p_1  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EDblC(p_1); :}
  | _SYMB_7 CondExpr:p_2 _SYMB_8  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.ECondExprC(p_2); :}
  | _SYMB_7 Statement:p_2 _SYMB_8  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.EStmtC(p_2); :}
;
RelOp ::= _SYMB_9  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpGtC(); :} 
  | _SYMB_10  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpEqC(); :}
  | _SYMB_11  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpNeC(); :}
  | _SYMB_12  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpLtC(); :}
  | _SYMB_13  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpLeC(); :}
  | _SYMB_14  {: RESULT = new pl.edu.mimuw.mmws.cloudatlas.query.Absyn.RelOpGeC(); :}
;