Initial import into git.
[galago.git] / java / pig-galago / src / com / yahoo / pig / impl / logicalLayer / parser / QueryParser.jj
blob778556ef7b619fe230549e43ab1ec16142641770
1 /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. /Users/trevor/Documents/School/othercode/pig-src/src/com/yahoo/pig/impl/logicalLayer/parser/QueryParser.jj */
2 /*@egen*//*
3  * Copyright (c) 2007 Yahoo! Inc.  All rights reserved.
4  * See accompanying LICENSE file.
5  */
6 /**
7  * JavaCC file
8  * This file lists the grammar for PIG Latin.
9  * QueryParser program ouputs a ParseTree given a Valid Pig Latin Query
10  */
11 options {
12   // Generate non-static functions
13   STATIC = false;
14   // Case is ignored in keywords
15   IGNORE_CASE = true;
18 PARSER_BEGIN(QueryParser)
19 package com.yahoo.pig.impl.logicalLayer.parser;
20 import java.io.*;
21 import java.util.*;
22 import java.lang.reflect.*;
23 import com.yahoo.pig.impl.logicalLayer.*;
24 import com.yahoo.pig.impl.eval.*;
25 import com.yahoo.pig.impl.eval.func.*;
26 import com.yahoo.pig.impl.eval.groupby.*;
27 import com.yahoo.pig.impl.eval.filter.*;
28 import com.yahoo.pig.impl.eval.window.*;
29 import com.yahoo.pig.impl.eval.sad.*;
30 import com.yahoo.pig.impl.logicalLayer.schema.*;
31 import com.yahoo.pig.*;
32 import com.yahoo.pig.impl.PigContext;
33 import com.yahoo.pig.PigServer.ExecType;
34 import com.yahoo.pig.impl.physicalLayer.IntermedResult;
35 import com.yahoo.pig.impl.io.FileLocalizer;
36 import com.yahoo.pig.builtin.*;
37 public class QueryParser/*@bgen(jjtree)*/implements QueryParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
38   protected JJTQueryParserState jjtree = new JJTQueryParserState();
40 /*@egen*/
41         private PigContext pigContext;
42         private Map<String, IntermedResult> aliases;
44         public QueryParser(InputStream in, PigContext pigContext, Map aliases) {
45                 this(in);
46                 this.pigContext = pigContext;
47                 this.aliases = aliases;
48         }
49         
50         public class EvalSpecPipeAndSchema{
51                 EvalSpecPipe pipe;
52                 SchemaItemList schema;
53         }
54         
55         public class CogroupInput {
56                 public LogicalOperator op;
57                 public GroupBySpec spec;
58         }
59             
60     static String unquote(String s) {
61                 return s.substring(1, s.length()-1);
62         }
63         
64         static int undollar(String s) {
65                 return Integer.parseInt(s.substring(1, s.length()));    
66         }
67         
68         NestableEvalItem newFuncEvalItem(EvalFunc func, EvalItemList args) throws ParseException {
69                 if (func instanceof AtomEvalFunc) return new AtomFuncEvalItem(pigContext, (AtomEvalFunc) func, args);
70                 else if (func instanceof TupleEvalFunc) return new TupleFuncEvalItem(pigContext, (TupleEvalFunc) func, args);
71                 else if (func instanceof BagEvalFunc) return new BagFuncEvalItem(pigContext, (BagEvalFunc) func, args);
72                 else throw new ParseException("Error: unknown Eval Function type: " + func.getClass().getName());       
73         }
74         
75         
76         LogicalOperator makeLORead(String alias) throws ParseException {
77                 if (!aliases.containsKey(alias)) throw new ParseException("Unrecognized alias: " + alias);
78         
79                 LORead readOp = new LORead(pigContext, aliases.get(alias));
80                 readOp.alias = alias;
81                 return readOp;
82         }
83         
85         
86         String massageFilename(String filename) throws IOException {
87                 if (pigContext.getExecType() != ExecType.LOCAL) {
88                         if (filename.startsWith(FileLocalizer.LOCAL_PREFIX)) {
89                  filename = FileLocalizer.hadoopify(filename);
90              } else {
91                  if (filename.startsWith(FileLocalizer.HADOOP_PREFIX)) {
92                      filename = filename.substring(FileLocalizer.HADOOP_PREFIX.length());
93                  }
94                         }
95                 }
96                                 
97                 return filename;
98         }
99         
100         LogicalOperator parseCogroup(ArrayList<CogroupInput> gis) throws ParseException{
101                 int n = gis.size();
102                 
103                 LogicalOperator[] los = new LogicalOperator[n];
104                 GroupBySpec[] specs = new GroupBySpec[n];
105                 
106                 for (int i = 0; i < n ; i++){
107                         
108                         CogroupInput gi = gis.get(i);
109                         los[i] = gi.op;
110                         specs[i] = gi.spec;
111                 }
112                 
113                 return new LOCogroup(pigContext, los, specs);
114         }
115                         
116         
117         LogicalOperator rewriteCross(ArrayList<LogicalOperator> inputs) throws IOException, ParseException{
118                 ArrayList<CogroupInput> gis = new ArrayList<CogroupInput>();
119                 Iterator<LogicalOperator> iter = inputs.iterator();
120                 int n = inputs.size();
122                 EvalSpecPipe pipe = new EvalSpecPipe(pigContext);
123                 EvalItemList list = new EvalItemList(pigContext);
124                 pipe.add(list);
125                 for (int i=0; i< n; i++){
126                         
127                         CogroupInput gi = new CogroupInput();
128                         gis.add(gi);
130                         gi.op = inputs.get(i);
131                         EvalItemList itemList = new EvalItemList(pigContext);
132                         itemList.add(new ConstEvalItem(pigContext, n+""));
133                         itemList.add(new ConstEvalItem(pigContext, i+"")); 
134                         gi.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFCross.class.getName()), itemList, false);
135                         
136                         ColEvalItem item = new ColEvalItem(pigContext, i+1);
137                         EvalItemList subSpec = new EvalItemList(pigContext);
138                         subSpec.add(new StarEvalItem(pigContext));
139                         item.subColSpec = subSpec;
140                         
141                         list.add(item);
142                 }
143                 
144                 return new LOEval(pigContext, parseCogroup(gis),pipe);
145         }
146         
147         LOLoad getDefaultLoadOperator(boolean continuous, String filename) throws IOException{
148                 
149                 String[] args = null;
150                 /*
151                 if (continuous){
152                         args = new String[2];
153                         args[0]="\t";
154                         args[1]="0";
155                 }
156                 */      
157                 StorageFunc loadFunc = (StorageFunc) pigContext.getUDF(PigStorage.class.getName()); 
158                 return new LOLoad(pigContext, massageFilename(filename), loadFunc, args);               
159         }
160         
161         void assertAtomic(EvalItem item, boolean desiredAtomic) throws ParseException{
162                 Boolean isAtomic = null;
163                 if (item instanceof ConstEvalItem || item instanceof AtomFuncEvalItem)
164                         isAtomic = true;
165                 else if (item instanceof FuncEvalItem)
166                         isAtomic = false;
167                 
168                 if (isAtomic != null && isAtomic != desiredAtomic){
169                         if (desiredAtomic)
170                                 throw new ParseException("Atomic field expected but found non-atomic field");
171                         else
172                                 throw new ParseException("Non-atomic field expected but found atomic field");
173                 }
174         }                                       
176         EvalItem copyItemAndAddSpec(EvalItem item, EvalSpec spec) throws ParseException{
177                 assertAtomic(item,false);
178                 item = item.copy();
179                 if (!(item instanceof NestableEvalItem))
180                         throw new ParseException("Internal Error: Cannot add spec to non-nestable field.");     
181                 NestableEvalItem nestableItem =  (NestableEvalItem)item;
182                 EvalSpecPipe specPipe = nestableItem.nestedEval;
183                 nestableItem.addNestedEvalSpec(spec);
184                 return item;
185         }
189         
190 PARSER_END(QueryParser)
192 // Skip all the new lines, tabs and spaces
193 SKIP : { " " |  "\r" |  "\t" |  "\n" }
195 // Skip comments(single line and multiline)
196 SKIP : {
197    <"--"(~["\r","\n"])*>
198 |  <"/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
200 // Comparison operators that can be used in a filter:
201 TOKEN : { <#STRFILTEROP : "eq" | "gt" | "lt" | "gte" | "lte" | "neq" > }
202 TOKEN : { <#NUMFILTEROP : "==" | "<" | "<=" | ">" | ">=" | "!=" > }
203 TOKEN : { <FILTEROP : <STRFILTEROP> | <NUMFILTEROP>  > }
205 // List all the keywords in the language
206 TOKEN : { <LOAD : "load"> }
207 TOKEN : { <FILTER : "filter"> }
208 TOKEN : { <FOREACH : "foreach"> }
209 TOKEN : { <MATCHES : "matches"> }
210 TOKEN : { <ORDER : "order"> }
211 TOKEN : { <ARRANGE : "arrange"> }
212 TOKEN : { <DISTINCT : "distinct"> }
213 TOKEN : { <COGROUP : "cogroup"> }
214 TOKEN : { <CROSS : "cross"> }
215 TOKEN : { <UNION : "union"> }
216 TOKEN : { <ALL : "all"> }
217 TOKEN : { <ANY : "any"> }
218 TOKEN : { <AS : "as">   }
219 TOKEN : { <BY : "by">   }
220 TOKEN : { <USING : "using"> }
221 TOKEN : { <INNER : "inner"> }
222 TOKEN : { <OUTER : "outer"> }
223 TOKEN : { <STAR : "*">          }
224 TOKEN : { <PARALLEL : "parallel"> }
225 TOKEN : { <GROUP : "group"> }
226 TOKEN : { <AND : "and"> }
227 TOKEN : { <OR : "or"> }
228 TOKEN : { <NOT : "not"> }
229 TOKEN : { <CONTINUOUSLY : "continuously"> }
230 TOKEN : { <WINDOW : "window"> }
231 TOKEN : { <SECONDS : "seconds"> }
232 TOKEN : { <MINUTES : "minutes"> }
233 TOKEN : { <HOURS : "hours"> }
234 TOKEN : { <TUPLES : "tuples"> }
235 TOKEN : { <GENERATE : "generate"> }
236 TOKEN : { <FLATTEN : "flatten"> }
237 TOKEN : { <EVAL : "eval"> }
239 TOKEN:
241         <#LETTER : ["a"-"z", "A"-"Z"] >
242 |       <#DIGIT : ["0"-"9"] >
243 |   <#SPECIALCHAR : ["_"] >
244 |   <#FSSPECIALCHAR: ["-", ":", "/"]>
245 |       <IDENTIFIER: ( <LETTER> )+ ( <DIGIT> | <LETTER> | <SPECIALCHAR> | "::")* >
247 // Define Numeric Constants
248 TOKEN :
250         < NUMBER: <INTEGER> | <FLOAT> | <FLOAT> ( ["e","E"] ([ "-","+"])? <FLOAT> )?>
251 |       < #FLOAT: <INTEGER> ( "." <INTEGER> )? | "." <INTEGER> >
252 |       < INTEGER: ( <DIGIT> )+ >
255 TOKEN : { <QUOTEDSTRING : "'" (~["'"])* "'"> }
256 // Pig has special variables starting with $
257 TOKEN : { <DOLLARVAR : "$" <INTEGER> > }
259 // Parse is the Starting function.
260 LogicalPlan Parse() : {/*@bgen(jjtree) Parse */
261                        SimpleNode jjtn000 = new SimpleNode(JJTPARSE);
262                        boolean jjtc000 = true;
263                        jjtree.openNodeScope(jjtn000);
264 /*@egen*/LogicalOperator root; Token t1;}
265 {/*@bgen(jjtree) Parse */
266         try {
267 /*@egen*/
268         (
269         LOOKAHEAD(2)
270         (t1 = <IDENTIFIER> "=" root = Expr() ";"{root.alias = t1.image;})
271 |       (root = Expr() ";")
272         )/*@bgen(jjtree)*/
273         {
274           jjtree.closeNodeScope(jjtn000, true);
275           jjtc000 = false;
276         }
277 /*@egen*/
278         { return new LogicalPlan(root, pigContext); }/*@bgen(jjtree)*/
279         } catch (Throwable jjte000) {
280           if (jjtc000) {
281             jjtree.clearNodeScope(jjtn000);
282             jjtc000 = false;
283           } else {
284             jjtree.popNode();
285           }
286           if (jjte000 instanceof RuntimeException) {
287             throw (RuntimeException)jjte000;
288           }
289           if (jjte000 instanceof ParseException) {
290             throw (ParseException)jjte000;
291           }
292           throw (Error)jjte000;
293         } finally {
294           if (jjtc000) {
295             jjtree.closeNodeScope(jjtn000, true);
296           }
297         }
298 /*@egen*/
301 LogicalOperator Expr() : {/*@bgen(jjtree) Expr */
302                           SimpleNode jjtn000 = new SimpleNode(JJTEXPR);
303                           boolean jjtc000 = true;
304                           jjtree.openNodeScope(jjtn000);
305 /*@egen*/LogicalOperator op; SchemaItemList schema;}
306 {/*@bgen(jjtree) Expr */
307         try {
308 /*@egen*/
309         (
310         ( op = NestedExpr() [ <AS> schema = AsClause() {op.schema=schema;} ] )
311 |       op = BaseExpr()
312         )/*@bgen(jjtree)*/
313         {
314           jjtree.closeNodeScope(jjtn000, true);
315           jjtc000 = false;
316         }
317 /*@egen*/
318         {return op;}/*@bgen(jjtree)*/
319         } catch (Throwable jjte000) {
320           if (jjtc000) {
321             jjtree.clearNodeScope(jjtn000);
322             jjtc000 = false;
323           } else {
324             jjtree.popNode();
325           }
326           if (jjte000 instanceof RuntimeException) {
327             throw (RuntimeException)jjte000;
328           }
329           if (jjte000 instanceof ParseException) {
330             throw (ParseException)jjte000;
331           }
332           throw (Error)jjte000;
333         } finally {
334           if (jjtc000) {
335             jjtree.closeNodeScope(jjtn000, true);
336           }
337         }
338 /*@egen*/
339 }       
341 LogicalOperator NestedExpr() : {/*@bgen(jjtree) NestedExpr */
342                                 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDEXPR);
343                                 boolean jjtc000 = true;
344                                 jjtree.openNodeScope(jjtn000);
345 /*@egen*/LogicalOperator op;}
346 {/*@bgen(jjtree) NestedExpr */
347         try {
348 /*@egen*/
349         (
350         (op = Alias())
351 |       LOOKAHEAD(2) ( "(" op = NestedExpr() ")" )
352 |       ( "(" op = BaseExpr() ")" )
353         )/*@bgen(jjtree)*/
354         {
355           jjtree.closeNodeScope(jjtn000, true);
356           jjtc000 = false;
357         }
358 /*@egen*/
359         {return op;}/*@bgen(jjtree)*/
360         } catch (Throwable jjte000) {
361           if (jjtc000) {
362             jjtree.clearNodeScope(jjtn000);
363             jjtc000 = false;
364           } else {
365             jjtree.popNode();
366           }
367           if (jjte000 instanceof RuntimeException) {
368             throw (RuntimeException)jjte000;
369           }
370           if (jjte000 instanceof ParseException) {
371             throw (ParseException)jjte000;
372           }
373           throw (Error)jjte000;
374         } finally {
375           if (jjtc000) {
376             jjtree.closeNodeScope(jjtn000, true);
377           }
378         }
379 /*@egen*/
382 // A reference to an alias
383 LogicalOperator Alias() : {/*@bgen(jjtree) Alias */
384                            SimpleNode jjtn000 = new SimpleNode(JJTALIAS);
385                            boolean jjtc000 = true;
386                            jjtree.openNodeScope(jjtn000);
387 /*@egen*/Token t1; LogicalOperator op;}
388 {/*@bgen(jjtree) Alias */
389         try {
390 /*@egen*/
391         t1 = <IDENTIFIER>/*@bgen(jjtree)*/
392         {
393           jjtree.closeNodeScope(jjtn000, true);
394           jjtc000 = false;
395         }
396 /*@egen*/ 
397         {
398                 op = makeLORead(t1.image);
399                 return op;
400         }/*@bgen(jjtree)*/
401         } finally {
402           if (jjtc000) {
403             jjtree.closeNodeScope(jjtn000, true);
404           }
405         }
406 /*@egen*/
411         
412         
413 LogicalOperator BaseExpr() : {/*@bgen(jjtree) BaseExpr */
414                               SimpleNode jjtn000 = new SimpleNode(JJTBASEEXPR);
415                               boolean jjtc000 = true;
416                               jjtree.openNodeScope(jjtn000);
417 /*@egen*/LogicalOperator op; SchemaItemList schema; Token t1, t2;}
418 {/*@bgen(jjtree) BaseExpr */
419         try {
420 /*@egen*/
421         (
422         (
423         (<LOAD> op = LoadClause() [<AS> schema = AsClause() {op.schema=schema;} ])
424 |       ((<GROUP> | <COGROUP>) op = CogroupClause())
425 |       (<FILTER> op = FilterClause())
426 |       (<CROSS> op = CrossClause())
427 |       (<UNION> op = UnionClause())
428 |       (<FOREACH> op = ForEachClause())
429         )
430     [<PARALLEL> t2=<NUMBER> { op.requestedParallelism = Integer.parseInt(t2.image);} ]
431         )/*@bgen(jjtree)*/
432         {
433           jjtree.closeNodeScope(jjtn000, true);
434           jjtc000 = false;
435         }
436 /*@egen*/       
437         {return op;}/*@bgen(jjtree)*/
438         } catch (Throwable jjte000) {
439           if (jjtc000) {
440             jjtree.clearNodeScope(jjtn000);
441             jjtc000 = false;
442           } else {
443             jjtree.popNode();
444           }
445           if (jjte000 instanceof RuntimeException) {
446             throw (RuntimeException)jjte000;
447           }
448           if (jjte000 instanceof ParseException) {
449             throw (ParseException)jjte000;
450           }
451           throw (Error)jjte000;
452         } finally {
453           if (jjtc000) {
454             jjtree.closeNodeScope(jjtn000, true);
455           }
456         }
457 /*@egen*/
460 LogicalOperator LoadClause() : {/*@bgen(jjtree) LoadClause */
461                                 SimpleNode jjtn000 = new SimpleNode(JJTLOADCLAUSE);
462                                 boolean jjtc000 = true;
463                                 jjtree.openNodeScope(jjtn000);
464 /*@egen*/Token t1, t2; String filename; StorageFunc loadFunc = null; 
465                                                                 ArrayList<String> loadParams = new ArrayList<String>(); LOLoad lo=null; boolean continuous=false;}
466 {/*@bgen(jjtree) LoadClause */
467         try {
468 /*@egen*/
469         (       t1 = <QUOTEDSTRING> {filename = unquote(t1.image);}
470                 (<USING> loadFunc = LoadFunction() "(" (t2 = <QUOTEDSTRING> {loadParams.add(t2.image);})? 
471                                                                                            ( "," t2 = <QUOTEDSTRING> {loadParams.add(t2.image);})* 
472                                                                                     ")"
473                         {lo = new LOLoad(pigContext, massageFilename(filename), loadFunc, loadParams);}
474                 )?
475         )
476         [ <CONTINUOUSLY> {continuous=true;} ]/*@bgen(jjtree)*/
477         {
478           jjtree.closeNodeScope(jjtn000, true);
479           jjtc000 = false;
480         }
481 /*@egen*/ 
482         {
483                 if (lo == null){
484                         lo = getDefaultLoadOperator(continuous,filename);
485                 }       
486                 if (continuous)
487                         lo.setOutputType(LogicalOperator.MONOTONE);
488                 return lo;
489         }/*@bgen(jjtree)*/
490         } catch (Throwable jjte000) {
491           if (jjtc000) {
492             jjtree.clearNodeScope(jjtn000);
493             jjtc000 = false;
494           } else {
495             jjtree.popNode();
496           }
497           if (jjte000 instanceof RuntimeException) {
498             throw (RuntimeException)jjte000;
499           }
500           if (jjte000 instanceof ParseException) {
501             throw (ParseException)jjte000;
502           }
503           throw (Error)jjte000;
504         } finally {
505           if (jjtc000) {
506             jjtree.closeNodeScope(jjtn000, true);
507           }
508         }
509 /*@egen*/ 
510 }    
512 LogicalOperator FilterClause():
513 {/*@bgen(jjtree) FilterClause */
514  SimpleNode jjtn000 = new SimpleNode(JJTFILTERCLAUSE);
515  boolean jjtc000 = true;
516  jjtree.openNodeScope(jjtn000);
517 /*@egen*/Cond cond; LogicalOperator input;}
518 {/*@bgen(jjtree) FilterClause */
519         try {
520 /*@egen*/
521         input = NestedExpr()    
522          <BY> cond = PCond(input.outputSchema(),null)/*@bgen(jjtree)*/
523         {
524           jjtree.closeNodeScope(jjtn000, true);
525           jjtc000 = false;
526         }
527 /*@egen*/
528         {
529                 EvalSpecPipe specPipe = new EvalSpecPipe(pigContext);
530                 specPipe.add(new FilterSpec(cond));
531                 return new LOEval(pigContext, input, specPipe);
532         }/*@bgen(jjtree)*/
533         } catch (Throwable jjte000) {
534           if (jjtc000) {
535             jjtree.clearNodeScope(jjtn000);
536             jjtc000 = false;
537           } else {
538             jjtree.popNode();
539           }
540           if (jjte000 instanceof RuntimeException) {
541             throw (RuntimeException)jjte000;
542           }
543           if (jjte000 instanceof ParseException) {
544             throw (ParseException)jjte000;
545           }
546           throw (Error)jjte000;
547         } finally {
548           if (jjtc000) {
549             jjtree.closeNodeScope(jjtn000, true);
550           }
551         }
552 /*@egen*/
557 Cond PCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PCond */
558                                                             SimpleNode jjtn000 = new SimpleNode(JJTPCOND);
559                                                             boolean jjtc000 = true;
560                                                             jjtree.openNodeScope(jjtn000);
561 /*@egen*/Cond cond = null;}
562 {/*@bgen(jjtree) PCond */
563         try {
564 /*@egen*/
565         cond = POrCond(over,pipes)/*@bgen(jjtree)*/
566         {
567           jjtree.closeNodeScope(jjtn000, true);
568           jjtc000 = false;
569         }
570 /*@egen*/
571         {return cond;}/*@bgen(jjtree)*/
572         } catch (Throwable jjte000) {
573           if (jjtc000) {
574             jjtree.clearNodeScope(jjtn000);
575             jjtc000 = false;
576           } else {
577             jjtree.popNode();
578           }
579           if (jjte000 instanceof RuntimeException) {
580             throw (RuntimeException)jjte000;
581           }
582           if (jjte000 instanceof ParseException) {
583             throw (ParseException)jjte000;
584           }
585           throw (Error)jjte000;
586         } finally {
587           if (jjtc000) {
588             jjtree.closeNodeScope(jjtn000, true);
589           }
590         }
591 /*@egen*/
594 Cond POrCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) POrCond */
595                                                               SimpleNode jjtn000 = new SimpleNode(JJTPORCOND);
596                                                               boolean jjtc000 = true;
597                                                               jjtree.openNodeScope(jjtn000);
598 /*@egen*/Cond cond; List<Cond> cList = new ArrayList<Cond>();}
599 {/*@bgen(jjtree) POrCond */
600         try {
601 /*@egen*/
602         (
603         cond = PAndCond(over,pipes) {cList.add(cond);}
604         ( <OR> cond = PAndCond(over,pipes) {cList.add(cond);})* 
605         )/*@bgen(jjtree)*/
606         {
607           jjtree.closeNodeScope(jjtn000, true);
608           jjtc000 = false;
609         }
610 /*@egen*/
611         {
612                 if (cList.size()==1)
613                         return cond;
614                 else    
615                         return new OrCond(cList);
616         }/*@bgen(jjtree)*/
617         } catch (Throwable jjte000) {
618           if (jjtc000) {
619             jjtree.clearNodeScope(jjtn000);
620             jjtc000 = false;
621           } else {
622             jjtree.popNode();
623           }
624           if (jjte000 instanceof RuntimeException) {
625             throw (RuntimeException)jjte000;
626           }
627           if (jjte000 instanceof ParseException) {
628             throw (ParseException)jjte000;
629           }
630           throw (Error)jjte000;
631         } finally {
632           if (jjtc000) {
633             jjtree.closeNodeScope(jjtn000, true);
634           }
635         }
636 /*@egen*/
638         
639 Cond PAndCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PAndCond */
640                                                                SimpleNode jjtn000 = new SimpleNode(JJTPANDCOND);
641                                                                boolean jjtc000 = true;
642                                                                jjtree.openNodeScope(jjtn000);
643 /*@egen*/Cond cond = null; List<Cond> cList = new ArrayList<Cond>();}
644 {/*@bgen(jjtree) PAndCond */
645         try {
646 /*@egen*/
647         (
648         cond = PUnaryCond(over,pipes) {cList.add(cond);}
649         ( <AND> cond = PUnaryCond(over,pipes) {cList.add(cond);} )*
650         )/*@bgen(jjtree)*/
651         {
652           jjtree.closeNodeScope(jjtn000, true);
653           jjtc000 = false;
654         }
655 /*@egen*/
656         {
657                 if (cList.size()==1)
658                         return cond;
659                 else    
660                         return new AndCond(cList);
661         }/*@bgen(jjtree)*/
662         } catch (Throwable jjte000) {
663           if (jjtc000) {
664             jjtree.clearNodeScope(jjtn000);
665             jjtc000 = false;
666           } else {
667             jjtree.popNode();
668           }
669           if (jjte000 instanceof RuntimeException) {
670             throw (RuntimeException)jjte000;
671           }
672           if (jjte000 instanceof ParseException) {
673             throw (ParseException)jjte000;
674           }
675           throw (Error)jjte000;
676         } finally {
677           if (jjtc000) {
678             jjtree.closeNodeScope(jjtn000, true);
679           }
680         }
681 /*@egen*/       
684 Cond PUnaryCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PUnaryCond */
685                                                                  SimpleNode jjtn000 = new SimpleNode(JJTPUNARYCOND);
686                                                                  boolean jjtc000 = true;
687                                                                  jjtree.openNodeScope(jjtn000);
688 /*@egen*/Cond cond = null; EvalItem c1, c2; Token t1; FilterFunc func; EvalItemList args;}
689 {/*@bgen(jjtree) PUnaryCond */
690         try {
691 /*@egen*/
692         (
693         LOOKAHEAD("(" PCond(over,pipes) ")")
694         ("(" cond = PCond(over,pipes) ")")
695 |       LOOKAHEAD(FilterFunction() "(") (func=FilterFunction() "(" args=EvalArgs(over,pipes) ")" {cond = new FuncCond(func, args);})
696 |       cond = PNotCond(over,pipes)
697 |       LOOKAHEAD(InfixExpr(over,pipes) <FILTEROP>) 
698                 (c1=InfixExpr(over,pipes) t1=<FILTEROP> c2=InfixExpr(over,pipes) {cond = new CompCond(c1, t1.image, c2);})
699 |       LOOKAHEAD(2) 
700                 (c1=InfixExpr(over,pipes) <MATCHES> t1=<QUOTEDSTRING> {cond = new RegexpCond(c1, unquote(t1.image));})
701         )/*@bgen(jjtree)*/
702         {
703           jjtree.closeNodeScope(jjtn000, true);
704           jjtc000 = false;
705         }
706 /*@egen*/
707         {return cond;}/*@bgen(jjtree)*/
708         } catch (Throwable jjte000) {
709           if (jjtc000) {
710             jjtree.clearNodeScope(jjtn000);
711             jjtc000 = false;
712           } else {
713             jjtree.popNode();
714           }
715           if (jjte000 instanceof RuntimeException) {
716             throw (RuntimeException)jjte000;
717           }
718           if (jjte000 instanceof ParseException) {
719             throw (ParseException)jjte000;
720           }
721           throw (Error)jjte000;
722         } finally {
723           if (jjtc000) {
724             jjtree.closeNodeScope(jjtn000, true);
725           }
726         }
727 /*@egen*/
730 Cond PNotCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PNotCond */
731                                                                SimpleNode jjtn000 = new SimpleNode(JJTPNOTCOND);
732                                                                boolean jjtc000 = true;
733                                                                jjtree.openNodeScope(jjtn000);
734 /*@egen*/Cond c1;}
735 {/*@bgen(jjtree) PNotCond */
736         try {
737 /*@egen*/
738         <NOT> c1=PUnaryCond(over,pipes)/*@bgen(jjtree)*/
739         {
740           jjtree.closeNodeScope(jjtn000, true);
741           jjtc000 = false;
742         }
743 /*@egen*/
744         {return new NotCond(c1);}/*@bgen(jjtree)*/
745         } catch (Throwable jjte000) {
746           if (jjtc000) {
747             jjtree.clearNodeScope(jjtn000);
748             jjtc000 = false;
749           } else {
750             jjtree.popNode();
751           }
752           if (jjte000 instanceof RuntimeException) {
753             throw (RuntimeException)jjte000;
754           }
755           if (jjte000 instanceof ParseException) {
756             throw (ParseException)jjte000;
757           }
758           throw (Error)jjte000;
759         } finally {
760           if (jjtc000) {
761             jjtree.closeNodeScope(jjtn000, true);
762           }
763         }
764 /*@egen*/
769 LogicalOperator CogroupClause() : {/*@bgen(jjtree) CogroupClause */
770                                    SimpleNode jjtn000 = new SimpleNode(JJTCOGROUPCLAUSE);
771                                    boolean jjtc000 = true;
772                                    jjtree.openNodeScope(jjtn000);
773 /*@egen*/CogroupInput gi; ArrayList<CogroupInput> gis = new ArrayList<CogroupInput>();}
774 {/*@bgen(jjtree) CogroupClause */
775         try {
776 /*@egen*/
777         (gi = GroupItem() { gis.add(gi); }
778         ("," gi = GroupItem() { gis.add(gi); })*)/*@bgen(jjtree)*/
779         {
780           jjtree.closeNodeScope(jjtn000, true);
781           jjtc000 = false;
782         }
783 /*@egen*/
784         {return parseCogroup(gis);}/*@bgen(jjtree)*/
785         } catch (Throwable jjte000) {
786           if (jjtc000) {
787             jjtree.clearNodeScope(jjtn000);
788             jjtc000 = false;
789           } else {
790             jjtree.popNode();
791           }
792           if (jjte000 instanceof RuntimeException) {
793             throw (RuntimeException)jjte000;
794           }
795           if (jjte000 instanceof ParseException) {
796             throw (ParseException)jjte000;
797           }
798           throw (Error)jjte000;
799         } finally {
800           if (jjtc000) {
801             jjtree.closeNodeScope(jjtn000, true);
802           }
803         }
804 /*@egen*/
808 CogroupInput GroupItem() : {/*@bgen(jjtree) GroupItem */
809                             SimpleNode jjtn000 = new SimpleNode(JJTGROUPITEM);
810                             boolean jjtc000 = true;
811                             jjtree.openNodeScope(jjtn000);
812 /*@egen*/LogicalOperator op; GroupFunc groupFunc; CogroupInput cogroupInput = new CogroupInput();}
813 {/*@bgen(jjtree) GroupItem */
814         try {
815 /*@egen*/
816         (
817         cogroupInput.op = NestedExpr()
818         (
819         (
820         ( <BY>  cogroupInput.spec = GroupByExpr(cogroupInput.op.outputSchema()) )
821 |       <ALL> {cogroupInput.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFAll.class.getName()), new EvalItemList(pigContext), false);}
822 |       <ANY> {cogroupInput.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFAny.class.getName()), new EvalItemList(pigContext), false);}
823         )
824         [<INNER> {cogroupInput.spec.isInner = true;} | <OUTER>]
825         )
826         )/*@bgen(jjtree)*/
827         {
828           jjtree.closeNodeScope(jjtn000, true);
829           jjtc000 = false;
830         }
831 /*@egen*/
832         {return cogroupInput;}/*@bgen(jjtree)*/
833         } catch (Throwable jjte000) {
834           if (jjtc000) {
835             jjtree.clearNodeScope(jjtn000);
836             jjtc000 = false;
837           } else {
838             jjtree.popNode();
839           }
840           if (jjte000 instanceof RuntimeException) {
841             throw (RuntimeException)jjte000;
842           }
843           if (jjte000 instanceof ParseException) {
844             throw (ParseException)jjte000;
845           }
846           throw (Error)jjte000;
847         } finally {
848           if (jjtc000) {
849             jjtree.closeNodeScope(jjtn000, true);
850           }
851         }
852 /*@egen*/
855 GroupBySpec GroupByExpr(SchemaItem over) : {/*@bgen(jjtree) GroupByExpr */
856                                             SimpleNode jjtn000 = new SimpleNode(JJTGROUPBYEXPR);
857                                             boolean jjtc000 = true;
858                                             jjtree.openNodeScope(jjtn000);
859 /*@egen*/Token t1; GroupBySpec spec = null; EvalItem projItem = null; EvalItemList proj = null; String s; GroupFunc func = null;}
860 {/*@bgen(jjtree) GroupByExpr */
861         try {
862 /*@egen*/
863         (
864         LOOKAHEAD(2) (func = GroupFunction() "(" proj = SimpleProjOrEmpty(over) ")" {spec = new GroupBySpec(pigContext, func, proj, false);})
865 |    (proj = BracketedSimpleProj(over)) {spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFTupleNoop.class.getName()), proj, false);}  
866         )/*@bgen(jjtree)*/
867     {
868       jjtree.closeNodeScope(jjtn000, true);
869       jjtc000 = false;
870     }
871 /*@egen*/
872     {return spec;}/*@bgen(jjtree)*/
873         } catch (Throwable jjte000) {
874           if (jjtc000) {
875             jjtree.clearNodeScope(jjtn000);
876             jjtc000 = false;
877           } else {
878             jjtree.popNode();
879           }
880           if (jjte000 instanceof RuntimeException) {
881             throw (RuntimeException)jjte000;
882           }
883           if (jjte000 instanceof ParseException) {
884             throw (ParseException)jjte000;
885           }
886           throw (Error)jjte000;
887         } finally {
888           if (jjtc000) {
889             jjtree.closeNodeScope(jjtn000, true);
890           }
891         }
892 /*@egen*/
895 //Used in serialization and deserialization
896 GroupBySpec GroupBySpec() : {/*@bgen(jjtree) GroupBySpec */
897                              SimpleNode jjtn000 = new SimpleNode(JJTGROUPBYSPEC);
898                              boolean jjtc000 = true;
899                              jjtree.openNodeScope(jjtn000);
900 /*@egen*/GroupBySpec spec = null;}
901 {/*@bgen(jjtree) GroupBySpec */
902         try {
903 /*@egen*/
904         (spec = GroupByExpr(null)
905         [<INNER> {spec.isInner = true;} | <OUTER>])/*@bgen(jjtree)*/
906         {
907           jjtree.closeNodeScope(jjtn000, true);
908           jjtc000 = false;
909         }
910 /*@egen*/
911         {return spec;}/*@bgen(jjtree)*/
912         } catch (Throwable jjte000) {
913           if (jjtc000) {
914             jjtree.clearNodeScope(jjtn000);
915             jjtc000 = false;
916           } else {
917             jjtree.popNode();
918           }
919           if (jjte000 instanceof RuntimeException) {
920             throw (RuntimeException)jjte000;
921           }
922           if (jjte000 instanceof ParseException) {
923             throw (ParseException)jjte000;
924           }
925           throw (Error)jjte000;
926         } finally {
927           if (jjtc000) {
928             jjtree.closeNodeScope(jjtn000, true);
929           }
930         }
931 /*@egen*/
934 LogicalOperator CrossClause() : {/*@bgen(jjtree) CrossClause */
935                                  SimpleNode jjtn000 = new SimpleNode(JJTCROSSCLAUSE);
936                                  boolean jjtc000 = true;
937                                  jjtree.openNodeScope(jjtn000);
938 /*@egen*/LogicalOperator op; ArrayList<LogicalOperator> inputs = new ArrayList<LogicalOperator>();}
939 {/*@bgen(jjtree) CrossClause */
940         try {
941 /*@egen*/
942         (
943         op = NestedExpr() { inputs.add(op); }
944         ("," op = NestedExpr() { inputs.add(op); })*
945         )/*@bgen(jjtree)*/
946         {
947           jjtree.closeNodeScope(jjtn000, true);
948           jjtc000 = false;
949         }
950 /*@egen*/
951         {return rewriteCross(inputs);}/*@bgen(jjtree)*/
952         } catch (Throwable jjte000) {
953           if (jjtc000) {
954             jjtree.clearNodeScope(jjtn000);
955             jjtc000 = false;
956           } else {
957             jjtree.popNode();
958           }
959           if (jjte000 instanceof RuntimeException) {
960             throw (RuntimeException)jjte000;
961           }
962           if (jjte000 instanceof ParseException) {
963             throw (ParseException)jjte000;
964           }
965           throw (Error)jjte000;
966         } finally {
967           if (jjtc000) {
968             jjtree.closeNodeScope(jjtn000, true);
969           }
970         }
971 /*@egen*/
974 LogicalOperator UnionClause() : {/*@bgen(jjtree) UnionClause */
975                                  SimpleNode jjtn000 = new SimpleNode(JJTUNIONCLAUSE);
976                                  boolean jjtc000 = true;
977                                  jjtree.openNodeScope(jjtn000);
978 /*@egen*/LogicalOperator op; ArrayList<LogicalOperator> inputs = new ArrayList<LogicalOperator>();}
979 {/*@bgen(jjtree) UnionClause */
980         try {
981 /*@egen*/
982         (op = NestedExpr() { inputs.add(op); }
983         ("," op = NestedExpr() { inputs.add(op); })*)/*@bgen(jjtree)*/
984         {
985           jjtree.closeNodeScope(jjtn000, true);
986           jjtc000 = false;
987         }
988 /*@egen*/
989         {return new LOUnion(pigContext, inputs);}/*@bgen(jjtree)*/
990         } catch (Throwable jjte000) {
991           if (jjtc000) {
992             jjtree.clearNodeScope(jjtn000);
993             jjtc000 = false;
994           } else {
995             jjtree.popNode();
996           }
997           if (jjte000 instanceof RuntimeException) {
998             throw (RuntimeException)jjte000;
999           }
1000           if (jjte000 instanceof ParseException) {
1001             throw (ParseException)jjte000;
1002           }
1003           throw (Error)jjte000;
1004         } finally {
1005           if (jjtc000) {
1006             jjtree.closeNodeScope(jjtn000, true);
1007           }
1008         }
1009 /*@egen*/
1013 LogicalOperator ForEachClause() : {/*@bgen(jjtree) ForEachClause */
1014                                    SimpleNode jjtn000 = new SimpleNode(JJTFOREACHCLAUSE);
1015                                    boolean jjtc000 = true;
1016                                    jjtree.openNodeScope(jjtn000);
1017 /*@egen*/EvalSpecPipeAndSchema specPipeAndSchema = null; LogicalOperator input, op; }
1018 {/*@bgen(jjtree) ForEachClause */
1019         try {
1020 /*@egen*/
1021         (
1022         input = NestedExpr()
1023         specPipeAndSchema = NestedBlock(input.outputSchema())
1024         )/*@bgen(jjtree)*/
1025         {
1026           jjtree.closeNodeScope(jjtn000, true);
1027           jjtc000 = false;
1028         }
1029 /*@egen*/
1030         {
1031                 op = new LOEval(pigContext, input, specPipeAndSchema.pipe);
1032                 op.schema = specPipeAndSchema.schema;
1033                 return op;
1034         }/*@bgen(jjtree)*/
1035         } catch (Throwable jjte000) {
1036           if (jjtc000) {
1037             jjtree.clearNodeScope(jjtn000);
1038             jjtc000 = false;
1039           } else {
1040             jjtree.popNode();
1041           }
1042           if (jjte000 instanceof RuntimeException) {
1043             throw (RuntimeException)jjte000;
1044           }
1045           if (jjte000 instanceof ParseException) {
1046             throw (ParseException)jjte000;
1047           }
1048           throw (Error)jjte000;
1049         } finally {
1050           if (jjtc000) {
1051             jjtree.closeNodeScope(jjtn000, true);
1052           }
1053         }
1054 /*@egen*/
1057 EvalSpecPipeAndSchema NestedBlock(SchemaItem over):
1058 {/*@bgen(jjtree) NestedBlock */
1059  SimpleNode jjtn000 = new SimpleNode(JJTNESTEDBLOCK);
1060  boolean jjtc000 = true;
1061  jjtree.openNodeScope(jjtn000);
1062 /*@egen*/EvalSpecPipeAndSchema pipeAndSchema; Map<String, EvalItem> pipes = new HashMap<String, EvalItem>();}
1063 {/*@bgen(jjtree) NestedBlock */
1064         try {
1065 /*@egen*/
1066         (
1067         pipeAndSchema = GenerateStatement(over,pipes)
1068 |       ("{" (NestedCommand(over,pipes) ";")* pipeAndSchema = GenerateStatement(over,pipes)      ";" "}")
1069         )/*@bgen(jjtree)*/
1070         {
1071           jjtree.closeNodeScope(jjtn000, true);
1072           jjtc000 = false;
1073         }
1074 /*@egen*/
1075         {return pipeAndSchema;}/*@bgen(jjtree)*/
1076         } catch (Throwable jjte000) {
1077           if (jjtc000) {
1078             jjtree.clearNodeScope(jjtn000);
1079             jjtc000 = false;
1080           } else {
1081             jjtree.popNode();
1082           }
1083           if (jjte000 instanceof RuntimeException) {
1084             throw (RuntimeException)jjte000;
1085           }
1086           if (jjte000 instanceof ParseException) {
1087             throw (ParseException)jjte000;
1088           }
1089           throw (Error)jjte000;
1090         } finally {
1091           if (jjtc000) {
1092             jjtree.closeNodeScope(jjtn000, true);
1093           }
1094         }
1095 /*@egen*/
1098 void NestedCommand(SchemaItem over, Map<String, EvalItem> pipes):
1099 {/*@bgen(jjtree) NestedCommand */
1100  SimpleNode jjtn000 = new SimpleNode(JJTNESTEDCOMMAND);
1101  boolean jjtc000 = true;
1102  jjtree.openNodeScope(jjtn000);
1103 /*@egen*/Token t; EvalItem item;}
1104 {/*@bgen(jjtree) NestedCommand */
1105         try {
1106 /*@egen*/
1107         (
1108         t = <IDENTIFIER> "="
1109         (
1110         item = InfixExpr(over,pipes)
1111 |       item = NestedFilter(over,pipes)  
1112 |       item = NestedSortOrArrange(over,pipes)
1113 |       item = NestedDistinct(over,pipes)       
1114         )
1115         )/*@bgen(jjtree)*/
1116         {
1117           jjtree.closeNodeScope(jjtn000, true);
1118           jjtc000 = false;
1119         }
1120 /*@egen*/       
1121         {pipes.put(t.image,item);}/*@bgen(jjtree)*/
1122         } catch (Throwable jjte000) {
1123           if (jjtc000) {
1124             jjtree.clearNodeScope(jjtn000);
1125             jjtc000 = false;
1126           } else {
1127             jjtree.popNode();
1128           }
1129           if (jjte000 instanceof RuntimeException) {
1130             throw (RuntimeException)jjte000;
1131           }
1132           if (jjte000 instanceof ParseException) {
1133             throw (ParseException)jjte000;
1134           }
1135           throw (Error)jjte000;
1136         } finally {
1137           if (jjtc000) {
1138             jjtree.closeNodeScope(jjtn000, true);
1139           }
1140         }
1141 /*@egen*/
1142 }               
1144 EvalItem NestedFilter(SchemaItem over, Map<String, EvalItem> pipes):
1145 {/*@bgen(jjtree) NestedFilter */
1146  SimpleNode jjtn000 = new SimpleNode(JJTNESTEDFILTER);
1147  boolean jjtc000 = true;
1148  jjtree.openNodeScope(jjtn000);
1149 /*@egen*/Cond cond; EvalItem item; SchemaItem subSchema = null;}
1150 {/*@bgen(jjtree) NestedFilter */
1151         try {
1152 /*@egen*/
1153         <FILTER> item = BaseEvalItem(over,pipes) { subSchema = item.mapInputSchema(over); }
1154         <BY> cond = PCond(subSchema,null)/*@bgen(jjtree)*/
1155         {
1156           jjtree.closeNodeScope(jjtn000, true);
1157           jjtc000 = false;
1158         }
1159 /*@egen*/
1160         { return copyItemAndAddSpec(item,new FilterSpec(cond)); }/*@bgen(jjtree)*/
1161         } catch (Throwable jjte000) {
1162           if (jjtc000) {
1163             jjtree.clearNodeScope(jjtn000);
1164             jjtc000 = false;
1165           } else {
1166             jjtree.popNode();
1167           }
1168           if (jjte000 instanceof RuntimeException) {
1169             throw (RuntimeException)jjte000;
1170           }
1171           if (jjte000 instanceof ParseException) {
1172             throw (ParseException)jjte000;
1173           }
1174           throw (Error)jjte000;
1175         } finally {
1176           if (jjtc000) {
1177             jjtree.closeNodeScope(jjtn000, true);
1178           }
1179         }
1180 /*@egen*/
1183 EvalItem NestedSortOrArrange(SchemaItem over, Map<String, EvalItem> pipes):
1184 {/*@bgen(jjtree) NestedSortOrArrange */
1185  SimpleNode jjtn000 = new SimpleNode(JJTNESTEDSORTORARRANGE);
1186  boolean jjtc000 = true;
1187  jjtree.openNodeScope(jjtn000);
1188 /*@egen*/EvalItemList list; EvalItem item; SchemaItem subSchema = null; Token t;}
1189 {/*@bgen(jjtree) NestedSortOrArrange */
1190         try {
1191 /*@egen*/
1192         (
1193         ( t = <ORDER> | t = <ARRANGE> )
1194         item = BaseEvalItem(over,pipes) { subSchema = item.mapInputSchema(over); }
1195         <BY> list = SimpleProj(subSchema)
1196         )/*@bgen(jjtree)*/
1197         {
1198           jjtree.closeNodeScope(jjtn000, true);
1199           jjtc000 = false;
1200         }
1201 /*@egen*/
1202         { return copyItemAndAddSpec(item,new SortArrangeSpec(list,t.image.equalsIgnoreCase("arrange"))); }/*@bgen(jjtree)*/
1203         } catch (Throwable jjte000) {
1204           if (jjtc000) {
1205             jjtree.clearNodeScope(jjtn000);
1206             jjtc000 = false;
1207           } else {
1208             jjtree.popNode();
1209           }
1210           if (jjte000 instanceof RuntimeException) {
1211             throw (RuntimeException)jjte000;
1212           }
1213           if (jjte000 instanceof ParseException) {
1214             throw (ParseException)jjte000;
1215           }
1216           throw (Error)jjte000;
1217         } finally {
1218           if (jjtc000) {
1219             jjtree.closeNodeScope(jjtn000, true);
1220           }
1221         }
1222 /*@egen*/
1224         
1225 EvalItem NestedDistinct(SchemaItem over, Map<String, EvalItem> pipes):
1226 {/*@bgen(jjtree) NestedDistinct */
1227  SimpleNode jjtn000 = new SimpleNode(JJTNESTEDDISTINCT);
1228  boolean jjtc000 = true;
1229  jjtree.openNodeScope(jjtn000);
1230 /*@egen*/EvalItemList list; EvalItem item; LogicalOperator subOp = null; Token t;}
1231 {/*@bgen(jjtree) NestedDistinct */
1232         try {
1233 /*@egen*/
1234         (
1235         <DISTINCT>
1236         item = BaseEvalItem(over,pipes)
1237         )/*@bgen(jjtree)*/
1238         {
1239           jjtree.closeNodeScope(jjtn000, true);
1240           jjtc000 = false;
1241         }
1242 /*@egen*/
1243         { 
1244                 list = new EvalItemList(pigContext); list.add(new StarEvalItem(pigContext));
1245                 return copyItemAndAddSpec(item,new DistinctSpec(list)); 
1246         }/*@bgen(jjtree)*/
1247         } catch (Throwable jjte000) {
1248           if (jjtc000) {
1249             jjtree.clearNodeScope(jjtn000);
1250             jjtc000 = false;
1251           } else {
1252             jjtree.popNode();
1253           }
1254           if (jjte000 instanceof RuntimeException) {
1255             throw (RuntimeException)jjte000;
1256           }
1257           if (jjte000 instanceof ParseException) {
1258             throw (ParseException)jjte000;
1259           }
1260           throw (Error)jjte000;
1261         } finally {
1262           if (jjtc000) {
1263             jjtree.closeNodeScope(jjtn000, true);
1264           }
1265         }
1266 /*@egen*/
1268         
1269         
1270 EvalSpecPipeAndSchema GenerateStatement(SchemaItem over, Map<String, EvalItem> pipes):
1271 {/*@bgen(jjtree) GenerateStatement */
1272  SimpleNode jjtn000 = new SimpleNode(JJTGENERATESTATEMENT);
1273  boolean jjtc000 = true;
1274  jjtree.openNodeScope(jjtn000);
1275 /*@egen*/EvalSpecPipeAndSchema pipeAndSchema = new EvalSpecPipeAndSchema(); EvalSpecPipe pipe = null; SchemaItemList schema;}
1276 {/*@bgen(jjtree) GenerateStatement */
1277         try {
1278 /*@egen*/
1279         (
1280         <GENERATE>
1281         pipe = FlattenedGenerateItemList(over,pipes)
1282         )/*@bgen(jjtree)*/
1283         {
1284           jjtree.closeNodeScope(jjtn000, true);
1285           jjtc000 = false;
1286         }
1287 /*@egen*/
1288         {
1289                 pipeAndSchema.pipe = pipe;
1290                 return pipeAndSchema;
1291         }/*@bgen(jjtree)*/
1292         } catch (Throwable jjte000) {
1293           if (jjtc000) {
1294             jjtree.clearNodeScope(jjtn000);
1295             jjtc000 = false;
1296           } else {
1297             jjtree.popNode();
1298           }
1299           if (jjte000 instanceof RuntimeException) {
1300             throw (RuntimeException)jjte000;
1301           }
1302           if (jjte000 instanceof ParseException) {
1303             throw (ParseException)jjte000;
1304           }
1305           throw (Error)jjte000;
1306         } finally {
1307           if (jjtc000) {
1308             jjtree.closeNodeScope(jjtn000, true);
1309           }
1310         }
1311 /*@egen*/
1314 EvalSpecPipe FlattenedGenerateItemList(SchemaItem over, Map<String, EvalItem> pipes):
1315 {/*@bgen(jjtree) FlattenedGenerateItemList */
1316  SimpleNode jjtn000 = new SimpleNode(JJTFLATTENEDGENERATEITEMLIST);
1317  boolean jjtc000 = true;
1318  jjtree.openNodeScope(jjtn000);
1319 /*@egen*/EvalSpecPipe pipe = new EvalSpecPipe(pigContext); EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
1320 {/*@bgen(jjtree) FlattenedGenerateItemList */
1321         try {
1322 /*@egen*/
1323         (
1324         item = FlattenedGenerateItem(over,pipes) {list.add(item);}
1325         ("," item = FlattenedGenerateItem(over,pipes) {list.add(item);})*
1326         )/*@bgen(jjtree)*/
1327         {
1328           jjtree.closeNodeScope(jjtn000, true);
1329           jjtc000 = false;
1330         }
1331 /*@egen*/
1332         {pipe.add(list); return pipe;}/*@bgen(jjtree)*/
1333         } catch (Throwable jjte000) {
1334           if (jjtc000) {
1335             jjtree.clearNodeScope(jjtn000);
1336             jjtc000 = false;
1337           } else {
1338             jjtree.popNode();
1339           }
1340           if (jjte000 instanceof RuntimeException) {
1341             throw (RuntimeException)jjte000;
1342           }
1343           if (jjte000 instanceof ParseException) {
1344             throw (ParseException)jjte000;
1345           }
1346           throw (Error)jjte000;
1347         } finally {
1348           if (jjtc000) {
1349             jjtree.closeNodeScope(jjtn000, true);
1350           }
1351         }
1352 /*@egen*/
1354         
1356 EvalItem FlattenedGenerateItem(SchemaItem over, Map<String, EvalItem> pipes): 
1357 {/*@bgen(jjtree) FlattenedGenerateItem */
1358  SimpleNode jjtn000 = new SimpleNode(JJTFLATTENEDGENERATEITEM);
1359  boolean jjtc000 = true;
1360  jjtree.openNodeScope(jjtn000);
1361 /*@egen*/EvalItem item; SchemaItem schema = null;}
1362 {/*@bgen(jjtree) FlattenedGenerateItem */
1363         try {
1364 /*@egen*/
1365         (
1366         (
1367         (       <FLATTEN> "(" item = GenerateItem(over,pipes) ")" 
1368                 {
1369                         if (!(item instanceof NestableEvalItem) || 
1370                                         (item instanceof AtomFuncEvalItem) ){
1371                                 throw new ParseException("Cannot flatten atom field");
1372                         }
1373                         
1374                         EvalItemList list = new EvalItemList(pigContext);
1375                         list.add(new StarEvalItem(pigContext));
1376                         ((NestableEvalItem)item).subColSpec = list;
1377                 }
1378         )
1379 |       (item = GenerateItem(over,pipes))
1380         )
1381         [ <AS> schema = SchemaElement() ]
1382         )/*@bgen(jjtree)*/
1383         {
1384           jjtree.closeNodeScope(jjtn000, true);
1385           jjtc000 = false;
1386         }
1387 /*@egen*/
1388         {
1389                 item.schema = schema;
1390                 return item;
1391         }/*@bgen(jjtree)*/
1392         } catch (Throwable jjte000) {
1393           if (jjtc000) {
1394             jjtree.clearNodeScope(jjtn000);
1395             jjtc000 = false;
1396           } else {
1397             jjtree.popNode();
1398           }
1399           if (jjte000 instanceof RuntimeException) {
1400             throw (RuntimeException)jjte000;
1401           }
1402           if (jjte000 instanceof ParseException) {
1403             throw (ParseException)jjte000;
1404           }
1405           throw (Error)jjte000;
1406         } finally {
1407           if (jjtc000) {
1408             jjtree.closeNodeScope(jjtn000, true);
1409           }
1410         }
1411 /*@egen*/
1414 EvalItem GenerateItem(SchemaItem over, Map<String, EvalItem> pipes):
1415 {/*@bgen(jjtree) GenerateItem */
1416  SimpleNode jjtn000 = new SimpleNode(JJTGENERATEITEM);
1417  boolean jjtc000 = true;
1418  jjtree.openNodeScope(jjtn000);
1419 /*@egen*/EvalItem item;}
1420 {/*@bgen(jjtree) GenerateItem */
1421         try {
1422 /*@egen*/
1423         (
1424         item = InfixExpr(over,pipes)
1425 |       item = Star()
1426         )/*@bgen(jjtree)*/
1427         {
1428           jjtree.closeNodeScope(jjtn000, true);
1429           jjtc000 = false;
1430         }
1431 /*@egen*/
1432         {return item;}/*@bgen(jjtree)*/
1433         } catch (Throwable jjte000) {
1434           if (jjtc000) {
1435             jjtree.clearNodeScope(jjtn000);
1436             jjtc000 = false;
1437           } else {
1438             jjtree.popNode();
1439           }
1440           if (jjte000 instanceof RuntimeException) {
1441             throw (RuntimeException)jjte000;
1442           }
1443           if (jjte000 instanceof ParseException) {
1444             throw (ParseException)jjte000;
1445           }
1446           throw (Error)jjte000;
1447         } finally {
1448           if (jjtc000) {
1449             jjtree.closeNodeScope(jjtn000, true);
1450           }
1451         }
1452 /*@egen*/
1453 }       
1454         
1456 EvalItem InfixExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) InfixExpr */
1457                                                                      SimpleNode jjtn000 = new SimpleNode(JJTINFIXEXPR);
1458                                                                      boolean jjtc000 = true;
1459                                                                      jjtree.openNodeScope(jjtn000);
1460 /*@egen*/ EvalItem expr; }
1461 {/*@bgen(jjtree) InfixExpr */
1462         try {
1463 /*@egen*/
1464         expr = AdditiveExpr(over,pipes)/*@bgen(jjtree)*/
1465         {
1466           jjtree.closeNodeScope(jjtn000, true);
1467           jjtc000 = false;
1468         }
1469 /*@egen*/ 
1470         {return expr;}/*@bgen(jjtree)*/
1471         } catch (Throwable jjte000) {
1472           if (jjtc000) {
1473             jjtree.clearNodeScope(jjtn000);
1474             jjtc000 = false;
1475           } else {
1476             jjtree.popNode();
1477           }
1478           if (jjte000 instanceof RuntimeException) {
1479             throw (RuntimeException)jjte000;
1480           }
1481           if (jjte000 instanceof ParseException) {
1482             throw (ParseException)jjte000;
1483           }
1484           throw (Error)jjte000;
1485         } finally {
1486           if (jjtc000) {
1487             jjtree.closeNodeScope(jjtn000, true);
1488           }
1489         }
1490 /*@egen*/
1493 EvalItem AdditiveExpr(SchemaItem over,  Map<String, EvalItem> pipes) : {/*@bgen(jjtree) AdditiveExpr */
1494                                                                          SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPR);
1495                                                                          boolean jjtc000 = true;
1496                                                                          jjtree.openNodeScope(jjtn000);
1497 /*@egen*/ Token t; EvalItem lhs, rhs; EvalItemList args;  }
1498 {/*@bgen(jjtree) AdditiveExpr */
1499         try {
1500 /*@egen*/
1501         (
1502         lhs = MultiplicativeExpr(over,pipes)    
1503                 (
1504                 ( t = "+" | t = "-" ) rhs = MultiplicativeExpr(over,pipes)
1505                         
1506                 {
1507                         assertAtomic(lhs,true);
1508                         assertAtomic(rhs,true);
1509                         args = new EvalItemList(pigContext);
1510                         args.add(lhs);
1511                         args.add(rhs);
1512                         if (t.image.equals("+")){
1513                                 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("ADD"), args);
1514                         }else{
1515                                 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("SUBTRACT"), args);
1516                         }
1517                 }
1518                 )*
1519         )/*@bgen(jjtree)*/
1520         {
1521           jjtree.closeNodeScope(jjtn000, true);
1522           jjtc000 = false;
1523         }
1524 /*@egen*/
1525         {return lhs;}/*@bgen(jjtree)*/
1526         } catch (Throwable jjte000) {
1527           if (jjtc000) {
1528             jjtree.clearNodeScope(jjtn000);
1529             jjtc000 = false;
1530           } else {
1531             jjtree.popNode();
1532           }
1533           if (jjte000 instanceof RuntimeException) {
1534             throw (RuntimeException)jjte000;
1535           }
1536           if (jjte000 instanceof ParseException) {
1537             throw (ParseException)jjte000;
1538           }
1539           throw (Error)jjte000;
1540         } finally {
1541           if (jjtc000) {
1542             jjtree.closeNodeScope(jjtn000, true);
1543           }
1544         }
1545 /*@egen*/               
1548 EvalItem MultiplicativeExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) MultiplicativeExpr */
1549                                                                               SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPR);
1550                                                                               boolean jjtc000 = true;
1551                                                                               jjtree.openNodeScope(jjtn000);
1552 /*@egen*/ Token t; EvalItem lhs, rhs; EvalItemList args; }
1553 {/*@bgen(jjtree) MultiplicativeExpr */
1554                 try {
1555 /*@egen*/
1556                 (
1557                 lhs = UnaryExpr(over,pipes)
1558                 (
1559                 ( t = <STAR> | t = "/" ) rhs = UnaryExpr(over,pipes)                    
1560                 {
1561                         assertAtomic(lhs,true);
1562                         assertAtomic(rhs,true);
1563                         args = new EvalItemList(pigContext);
1564                         args.add(lhs);
1565                         args.add(rhs);
1566                         if (t.image.equals("*")){
1567                                 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("MULTIPLY"), args);
1568                         }else{
1569                                 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("DIVIDE"), args);
1570                         }
1571                 }
1572                 )*
1573                 )/*@bgen(jjtree)*/
1574                 {
1575                   jjtree.closeNodeScope(jjtn000, true);
1576                   jjtc000 = false;
1577                 }
1578 /*@egen*/
1579                 {return lhs;}/*@bgen(jjtree)*/
1580                 } catch (Throwable jjte000) {
1581                   if (jjtc000) {
1582                     jjtree.clearNodeScope(jjtn000);
1583                     jjtc000 = false;
1584                   } else {
1585                     jjtree.popNode();
1586                   }
1587                   if (jjte000 instanceof RuntimeException) {
1588                     throw (RuntimeException)jjte000;
1589                   }
1590                   if (jjte000 instanceof ParseException) {
1591                     throw (ParseException)jjte000;
1592                   }
1593                   throw (Error)jjte000;
1594                 } finally {
1595                   if (jjtc000) {
1596                     jjtree.closeNodeScope(jjtn000, true);
1597                   }
1598                 }
1599 /*@egen*/
1602 EvalItem UnaryExpr(SchemaItem over,  Map<String, EvalItem> pipes) : {/*@bgen(jjtree) UnaryExpr */
1603                                                                       SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPR);
1604                                                                       boolean jjtc000 = true;
1605                                                                       jjtree.openNodeScope(jjtn000);
1606 /*@egen*/ EvalItem expr; }
1607 {/*@bgen(jjtree) UnaryExpr */
1608         try {
1609 /*@egen*/
1610         (
1611         LOOKAHEAD(BaseEvalItem(over,pipes)) expr = BaseEvalItem(over,pipes)
1612 |       ( "(" expr = InfixExpr(over,pipes) ")" )
1613         )/*@bgen(jjtree)*/
1614         {
1615           jjtree.closeNodeScope(jjtn000, true);
1616           jjtc000 = false;
1617         }
1618 /*@egen*/
1619         {return expr;}/*@bgen(jjtree)*/
1620         } catch (Throwable jjte000) {
1621           if (jjtc000) {
1622             jjtree.clearNodeScope(jjtn000);
1623             jjtc000 = false;
1624           } else {
1625             jjtree.popNode();
1626           }
1627           if (jjte000 instanceof RuntimeException) {
1628             throw (RuntimeException)jjte000;
1629           }
1630           if (jjte000 instanceof ParseException) {
1631             throw (ParseException)jjte000;
1632           }
1633           throw (Error)jjte000;
1634         } finally {
1635           if (jjtc000) {
1636             jjtree.closeNodeScope(jjtn000, true);
1637           }
1638         }
1639 /*@egen*/
1642         
1643 EvalItem BaseEvalItem(SchemaItem over, Map<String, EvalItem> pipes) :
1644 {/*@bgen(jjtree) BaseEvalItem */
1645  SimpleNode jjtn000 = new SimpleNode(JJTBASEEVALITEM);
1646  boolean jjtc000 = true;
1647  jjtree.openNodeScope(jjtn000);
1648 /*@egen*/EvalItem item;EvalItemList projection; SchemaItem subSchema = null;}
1649 {/*@bgen(jjtree) BaseEvalItem */
1650         try {
1651 /*@egen*/
1652         (
1653         item = Const()
1654 |       (
1655         (
1656                 LOOKAHEAD(FuncEvalItem(over,pipes))
1657                 item = FuncEvalItem(over,pipes)
1658         |       item = PColEvalItem(over,pipes) 
1659         |       item = BinCond(over,pipes)
1660         )
1661                 { subSchema = item.mapInputSchema(over); }      
1662                 [ 
1663                         "." projection = BracketedSimpleProj(subSchema) 
1664                         {
1665                                 assertAtomic(item,false); 
1666                                 ((NestableEvalItem)item).addNestedEvalSpec(projection);
1667                         }
1668                 ]
1669         )
1670         )/*@bgen(jjtree)*/
1671         {
1672           jjtree.closeNodeScope(jjtn000, true);
1673           jjtc000 = false;
1674         }
1675 /*@egen*/
1676         {return item;}/*@bgen(jjtree)*/
1677         } catch (Throwable jjte000) {
1678           if (jjtc000) {
1679             jjtree.clearNodeScope(jjtn000);
1680             jjtc000 = false;
1681           } else {
1682             jjtree.popNode();
1683           }
1684           if (jjte000 instanceof RuntimeException) {
1685             throw (RuntimeException)jjte000;
1686           }
1687           if (jjte000 instanceof ParseException) {
1688             throw (ParseException)jjte000;
1689           }
1690           throw (Error)jjte000;
1691         } finally {
1692           if (jjtc000) {
1693             jjtree.closeNodeScope(jjtn000, true);
1694           }
1695         }
1696 /*@egen*/
1701 NestableEvalItem BinCond(SchemaItem over, Map<String, EvalItem> pipes):
1702 {/*@bgen(jjtree) BinCond */
1703  SimpleNode jjtn000 = new SimpleNode(JJTBINCOND);
1704  boolean jjtc000 = true;
1705  jjtree.openNodeScope(jjtn000);
1706 /*@egen*/Cond cond; EvalItem ifTrue, ifFalse; NestableEvalItem ret = null;}
1707 {/*@bgen(jjtree) BinCond */
1708         try {
1709 /*@egen*/       
1710         (
1711         "(" cond = PCond(over,pipes) "?" ifTrue = BaseEvalItem(over,pipes) 
1712         ":" ifFalse = BaseEvalItem(over,pipes) ")"
1713         )/*@bgen(jjtree)*/
1714         {
1715           jjtree.closeNodeScope(jjtn000, true);
1716           jjtc000 = false;
1717         }
1718 /*@egen*/
1719         { return new BinCond(pigContext, cond,ifTrue,ifFalse);}/*@bgen(jjtree)*/
1720         } catch (Throwable jjte000) {
1721           if (jjtc000) {
1722             jjtree.clearNodeScope(jjtn000);
1723             jjtc000 = false;
1724           } else {
1725             jjtree.popNode();
1726           }
1727           if (jjte000 instanceof RuntimeException) {
1728             throw (RuntimeException)jjte000;
1729           }
1730           if (jjte000 instanceof ParseException) {
1731             throw (ParseException)jjte000;
1732           }
1733           throw (Error)jjte000;
1734         } finally {
1735           if (jjtc000) {
1736             jjtree.closeNodeScope(jjtn000, true);
1737           }
1738         }
1739 /*@egen*/
1743 NestableEvalItem FuncEvalItem(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) FuncEvalItem */
1744                                                                                SimpleNode jjtn000 = new SimpleNode(JJTFUNCEVALITEM);
1745                                                                                boolean jjtc000 = true;
1746                                                                                jjtree.openNodeScope(jjtn000);
1747 /*@egen*/EvalFunc func; EvalItemList args; NestableEvalItem i;}
1748 {/*@bgen(jjtree) FuncEvalItem */
1749         try {
1750 /*@egen*/
1751         func=EvalFunction() "(" args=EvalArgs(over,pipes) ")" {i = newFuncEvalItem(func, args);}/*@bgen(jjtree)*/
1752         {
1753           jjtree.closeNodeScope(jjtn000, true);
1754           jjtc000 = false;
1755         }
1756 /*@egen*/
1757         {return i;}/*@bgen(jjtree)*/
1758         } catch (Throwable jjte000) {
1759           if (jjtc000) {
1760             jjtree.clearNodeScope(jjtn000);
1761             jjtc000 = false;
1762           } else {
1763             jjtree.popNode();
1764           }
1765           if (jjte000 instanceof RuntimeException) {
1766             throw (RuntimeException)jjte000;
1767           }
1768           if (jjte000 instanceof ParseException) {
1769             throw (ParseException)jjte000;
1770           }
1771           throw (Error)jjte000;
1772         } finally {
1773           if (jjtc000) {
1774             jjtree.closeNodeScope(jjtn000, true);
1775           }
1776         }
1777 /*@egen*/
1780 EvalItemList EvalArgs(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) EvalArgs */
1781                                                                        SimpleNode jjtn000 = new SimpleNode(JJTEVALARGS);
1782                                                                        boolean jjtc000 = true;
1783                                                                        jjtree.openNodeScope(jjtn000);
1784 /*@egen*/EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
1785 {/*@bgen(jjtree) EvalArgs */
1786         try {
1787 /*@egen*/
1788         (
1789         (item=EvalArgsItem(over,pipes)  {list.add(item);}
1790         ("," item=EvalArgsItem(over,pipes) {list.add(item);})*)
1791         | {list = new EvalItemList(pigContext);}
1792         )/*@bgen(jjtree)*/
1793         {
1794           jjtree.closeNodeScope(jjtn000, true);
1795           jjtc000 = false;
1796         }
1797 /*@egen*/
1798         {
1799                 if (!list.isSimple()){
1800                         throw new ParseException("Cannot have non-jave function as an argument");
1801                 }
1802                 return list;
1803         }/*@bgen(jjtree)*/
1804         } catch (Throwable jjte000) {
1805           if (jjtc000) {
1806             jjtree.clearNodeScope(jjtn000);
1807             jjtc000 = false;
1808           } else {
1809             jjtree.popNode();
1810           }
1811           if (jjte000 instanceof RuntimeException) {
1812             throw (RuntimeException)jjte000;
1813           }
1814           if (jjte000 instanceof ParseException) {
1815             throw (ParseException)jjte000;
1816           }
1817           throw (Error)jjte000;
1818         } finally {
1819           if (jjtc000) {
1820             jjtree.closeNodeScope(jjtn000, true);
1821           }
1822         }
1823 /*@egen*/
1826 EvalItem EvalArgsItem(SchemaItem over, Map<String, EvalItem> pipes):
1827 {/*@bgen(jjtree) EvalArgsItem */
1828  SimpleNode jjtn000 = new SimpleNode(JJTEVALARGSITEM);
1829  boolean jjtc000 = true;
1830  jjtree.openNodeScope(jjtn000);
1831 /*@egen*/EvalItem item;}
1832 {/*@bgen(jjtree) EvalArgsItem */
1833         try {
1834 /*@egen*/
1835         (
1836         item = InfixExpr(over,pipes)
1837 |       item = Star()
1838         )/*@bgen(jjtree)*/
1839         {
1840           jjtree.closeNodeScope(jjtn000, true);
1841           jjtc000 = false;
1842         }
1843 /*@egen*/
1844         {return item;}/*@bgen(jjtree)*/
1845         } catch (Throwable jjte000) {
1846           if (jjtc000) {
1847             jjtree.clearNodeScope(jjtn000);
1848             jjtc000 = false;
1849           } else {
1850             jjtree.popNode();
1851           }
1852           if (jjte000 instanceof RuntimeException) {
1853             throw (RuntimeException)jjte000;
1854           }
1855           if (jjte000 instanceof ParseException) {
1856             throw (ParseException)jjte000;
1857           }
1858           throw (Error)jjte000;
1859         } finally {
1860           if (jjtc000) {
1861             jjtree.closeNodeScope(jjtn000, true);
1862           }
1863         }
1864 /*@egen*/
1867                 
1870 // Map a user schema onto a LogicalOperator
1871 SchemaItemList AsClause() : {/*@bgen(jjtree) AsClause */
1872                              SimpleNode jjtn000 = new SimpleNode(JJTASCLAUSE);
1873                              boolean jjtc000 = true;
1874                              jjtree.openNodeScope(jjtn000);
1875 /*@egen*/Token t1; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); Token t = null;}
1876 {/*@bgen(jjtree) AsClause */
1877         try {
1878 /*@egen*/
1879         (
1880         [ ( t = <IDENTIFIER> | t = <GROUP> ) ":" ] "("
1881         ( 
1882         (
1883         item=SchemaElement() { list.add(item); }
1884          ( "," item=SchemaElement() { list.add(item); } )* 
1885          
1886         )
1887 |       {list = new SchemaItemList();}
1888         )
1889         ")"
1890         )/*@bgen(jjtree)*/
1891         {
1892           jjtree.closeNodeScope(jjtn000, true);
1893           jjtc000 = false;
1894         }
1895 /*@egen*/
1896         {
1897                 if (t!=null)
1898                         list.alias = t.image;
1899                 return list;
1900         }/*@bgen(jjtree)*/
1901         } catch (Throwable jjte000) {
1902           if (jjtc000) {
1903             jjtree.clearNodeScope(jjtn000);
1904             jjtc000 = false;
1905           } else {
1906             jjtree.popNode();
1907           }
1908           if (jjte000 instanceof RuntimeException) {
1909             throw (RuntimeException)jjte000;
1910           }
1911           if (jjte000 instanceof ParseException) {
1912             throw (ParseException)jjte000;
1913           }
1914           throw (Error)jjte000;
1915         } finally {
1916           if (jjtc000) {
1917             jjtree.closeNodeScope(jjtn000, true);
1918           }
1919         }
1920 /*@egen*/
1923 SchemaItem SchemaElement() : {/*@bgen(jjtree) SchemaElement */
1924                                SimpleNode jjtn000 = new SimpleNode(JJTSCHEMAELEMENT);
1925                                boolean jjtc000 = true;
1926                                jjtree.openNodeScope(jjtn000);
1927 /*@egen*/ Token t1; SchemaItem item = null;}
1928 {/*@bgen(jjtree) SchemaElement */
1929         try {
1930 /*@egen*/
1931         (LOOKAHEAD(SchemaBag()) item = SchemaBag()
1932 |        LOOKAHEAD(SchemaTuple()) item = SchemaTuple()
1933 |    LOOKAHEAD(SchemaField()) item = SchemaField() )/*@bgen(jjtree)*/
1934         {
1935           jjtree.closeNodeScope(jjtn000, true);
1936           jjtc000 = false;
1937         }
1938 /*@egen*/
1939         {return item;}/*@bgen(jjtree)*/
1940         } catch (Throwable jjte000) {
1941           if (jjtc000) {
1942             jjtree.clearNodeScope(jjtn000);
1943             jjtc000 = false;
1944           } else {
1945             jjtree.popNode();
1946           }
1947           if (jjte000 instanceof RuntimeException) {
1948             throw (RuntimeException)jjte000;
1949           }
1950           if (jjte000 instanceof ParseException) {
1951             throw (ParseException)jjte000;
1952           }
1953           throw (Error)jjte000;
1954         } finally {
1955           if (jjtc000) {
1956             jjtree.closeNodeScope(jjtn000, true);
1957           }
1958         }
1959 /*@egen*/
1962 SchemaItem SchemaField() : {/*@bgen(jjtree) SchemaField */
1963                             SimpleNode jjtn000 = new SimpleNode(JJTSCHEMAFIELD);
1964                             boolean jjtc000 = true;
1965                             jjtree.openNodeScope(jjtn000);
1966 /*@egen*/Token t1;}
1967 {/*@bgen(jjtree) SchemaField */
1968         try {
1969 /*@egen*/
1970         (  ( t1 = <IDENTIFIER> | t1 = <GROUP> )/*@bgen(jjtree)*/
1971                                                 {
1972                                                   jjtree.closeNodeScope(jjtn000, true);
1973                                                   jjtc000 = false;
1974                                                 }
1975 /*@egen*/ { return new SchemaField(t1.image); } )/*@bgen(jjtree)*/
1976         } finally {
1977           if (jjtc000) {
1978             jjtree.closeNodeScope(jjtn000, true);
1979           }
1980         }
1981 /*@egen*/
1984 SchemaItem SchemaTuple() : {/*@bgen(jjtree) SchemaTuple */
1985                             SimpleNode jjtn000 = new SimpleNode(JJTSCHEMATUPLE);
1986                             boolean jjtc000 = true;
1987                             jjtree.openNodeScope(jjtn000);
1988 /*@egen*/Token t1 = null; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); }
1989 {/*@bgen(jjtree) SchemaTuple */
1990         try {
1991 /*@egen*/
1992         ( 
1993         [( t1 = <IDENTIFIER> | t1 = <GROUP> ) ":"] "(" 
1994         (       
1995         (       item=SchemaElement() { list.add(item); } 
1996                 ( "," item=SchemaElement() {list.add(item);} )* 
1997         )
1998 |               {}
1999         )
2000         ")"
2001         )/*@bgen(jjtree)*/
2002         {
2003           jjtree.closeNodeScope(jjtn000, true);
2004           jjtc000 = false;
2005         }
2006 /*@egen*/ 
2007         {
2008                 if (t1!=null)
2009                         list.alias = t1.image; 
2010                 list.setIsBag(false);
2011                 return list;
2012         }/*@bgen(jjtree)*/
2013         } catch (Throwable jjte000) {
2014           if (jjtc000) {
2015             jjtree.clearNodeScope(jjtn000);
2016             jjtc000 = false;
2017           } else {
2018             jjtree.popNode();
2019           }
2020           if (jjte000 instanceof RuntimeException) {
2021             throw (RuntimeException)jjte000;
2022           }
2023           if (jjte000 instanceof ParseException) {
2024             throw (ParseException)jjte000;
2025           }
2026           throw (Error)jjte000;
2027         } finally {
2028           if (jjtc000) {
2029             jjtree.closeNodeScope(jjtn000, true);
2030           }
2031         }
2032 /*@egen*/ 
2035 SchemaItem SchemaBag() : {/*@bgen(jjtree) SchemaBag */
2036                           SimpleNode jjtn000 = new SimpleNode(JJTSCHEMABAG);
2037                           boolean jjtc000 = true;
2038                           jjtree.openNodeScope(jjtn000);
2039 /*@egen*/Token t1=null; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); }
2040 {/*@bgen(jjtree) SchemaBag */
2041         try {
2042 /*@egen*/
2043         ( 
2044         [ t1 = <IDENTIFIER> ":" ] "[" 
2045         (
2046         (       item=SchemaElement() { list.add(item); } 
2047                 ( "," item=SchemaElement() {list.add(item);} )* 
2048         )
2049 |       {}
2050         )
2051         "]"
2052         )/*@bgen(jjtree)*/
2053         {
2054           jjtree.closeNodeScope(jjtn000, true);
2055           jjtc000 = false;
2056         }
2057 /*@egen*/ 
2058         {
2059                 if (t1!=null)
2060                         list.alias = t1.image; 
2061                 list.setIsBag(true);
2062                 return list;
2063         }/*@bgen(jjtree)*/
2064         } catch (Throwable jjte000) {
2065           if (jjtc000) {
2066             jjtree.clearNodeScope(jjtn000);
2067             jjtc000 = false;
2068           } else {
2069             jjtree.popNode();
2070           }
2071           if (jjte000 instanceof RuntimeException) {
2072             throw (RuntimeException)jjte000;
2073           }
2074           if (jjte000 instanceof ParseException) {
2075             throw (ParseException)jjte000;
2076           }
2077           throw (Error)jjte000;
2078         } finally {
2079           if (jjtc000) {
2080             jjtree.closeNodeScope(jjtn000, true);
2081           }
2082         }
2083 /*@egen*/
2091 // Used in serialization and deserialization
2093 EvalSpecPipe PEvalSpecPipe() : {/*@bgen(jjtree) PEvalSpecPipe */
2094                                 SimpleNode jjtn000 = new SimpleNode(JJTPEVALSPECPIPE);
2095                                 boolean jjtc000 = true;
2096                                 jjtree.openNodeScope(jjtn000);
2097 /*@egen*/EvalSpecPipe pipe = new EvalSpecPipe(pigContext); EvalSpec spec;}
2098 {/*@bgen(jjtree) PEvalSpecPipe */
2099 try {
2100 /*@egen*/
2101 (("["spec=PEvalSpec()"]" {pipe.add(spec);})*)/*@bgen(jjtree)*/
2102         {
2103           jjtree.closeNodeScope(jjtn000, true);
2104           jjtc000 = false;
2105         }
2106 /*@egen*/
2107         {return pipe;}/*@bgen(jjtree)*/
2108 } catch (Throwable jjte000) {
2109   if (jjtc000) {
2110     jjtree.clearNodeScope(jjtn000);
2111     jjtc000 = false;
2112   } else {
2113     jjtree.popNode();
2114   }
2115   if (jjte000 instanceof RuntimeException) {
2116     throw (RuntimeException)jjte000;
2117   }
2118   if (jjte000 instanceof ParseException) {
2119     throw (ParseException)jjte000;
2120   }
2121   throw (Error)jjte000;
2122 } finally {
2123   if (jjtc000) {
2124     jjtree.closeNodeScope(jjtn000, true);
2125   }
2127 /*@egen*/
2130 EvalSpec PEvalSpec() : {/*@bgen(jjtree) PEvalSpec */
2131                         SimpleNode jjtn000 = new SimpleNode(JJTPEVALSPEC);
2132                         boolean jjtc000 = true;
2133                         jjtree.openNodeScope(jjtn000);
2134 /*@egen*/EvalSpec spec;}
2135 {/*@bgen(jjtree) PEvalSpec */
2136         try {
2137 /*@egen*/
2138         (<FILTER> spec=PFilter() | <EVAL> spec=PEvalItemList() | spec=PSAD())/*@bgen(jjtree)*/
2139         {
2140           jjtree.closeNodeScope(jjtn000, true);
2141           jjtc000 = false;
2142         }
2143 /*@egen*/
2144         {return spec;}/*@bgen(jjtree)*/
2145         } catch (Throwable jjte000) {
2146           if (jjtc000) {
2147             jjtree.clearNodeScope(jjtn000);
2148             jjtc000 = false;
2149           } else {
2150             jjtree.popNode();
2151           }
2152           if (jjte000 instanceof RuntimeException) {
2153             throw (RuntimeException)jjte000;
2154           }
2155           if (jjte000 instanceof ParseException) {
2156             throw (ParseException)jjte000;
2157           }
2158           throw (Error)jjte000;
2159         } finally {
2160           if (jjtc000) {
2161             jjtree.closeNodeScope(jjtn000, true);
2162           }
2163         }
2164 /*@egen*/
2167 EvalSpec PFilter() : 
2168 {/*@bgen(jjtree) PFilter */
2169  SimpleNode jjtn000 = new SimpleNode(JJTPFILTER);
2170  boolean jjtc000 = true;
2171  jjtree.openNodeScope(jjtn000);
2172 /*@egen*/Cond cond;}
2173 {/*@bgen(jjtree) PFilter */
2174         try {
2175 /*@egen*/
2176         cond = PCond(null,null)/*@bgen(jjtree)*/
2177         {
2178           jjtree.closeNodeScope(jjtn000, true);
2179           jjtc000 = false;
2180         }
2181 /*@egen*/ 
2182         {return new FilterSpec(cond);}/*@bgen(jjtree)*/
2183         } catch (Throwable jjte000) {
2184           if (jjtc000) {
2185             jjtree.clearNodeScope(jjtn000);
2186             jjtc000 = false;
2187           } else {
2188             jjtree.popNode();
2189           }
2190           if (jjte000 instanceof RuntimeException) {
2191             throw (RuntimeException)jjte000;
2192           }
2193           if (jjte000 instanceof ParseException) {
2194             throw (ParseException)jjte000;
2195           }
2196           throw (Error)jjte000;
2197         } finally {
2198           if (jjtc000) {
2199             jjtree.closeNodeScope(jjtn000, true);
2200           }
2201         }
2202 /*@egen*/
2205 EvalSpec PSAD() : {/*@bgen(jjtree) PSAD */
2206                    SimpleNode jjtn000 = new SimpleNode(JJTPSAD);
2207                    boolean jjtc000 = true;
2208                    jjtree.openNodeScope(jjtn000);
2209 /*@egen*/EvalSpec sad; EvalItemList proj;}
2210 {/*@bgen(jjtree) PSAD */
2211         try {
2212 /*@egen*/
2213         ((<ORDER> <BY> proj=SimpleProj(null) {sad = new SortArrangeSpec(proj, false);})
2214 |       (<ARRANGE> <BY> proj=SimpleProj(null) {sad = new SortArrangeSpec(proj, true);})
2215 |       (<DISTINCT> proj=SimpleProj(null) {sad = new DistinctSpec(proj);}))/*@bgen(jjtree)*/
2216         {
2217           jjtree.closeNodeScope(jjtn000, true);
2218           jjtc000 = false;
2219         }
2220 /*@egen*/
2221         {return sad;}/*@bgen(jjtree)*/
2222         } catch (Throwable jjte000) {
2223           if (jjtc000) {
2224             jjtree.clearNodeScope(jjtn000);
2225             jjtc000 = false;
2226           } else {
2227             jjtree.popNode();
2228           }
2229           if (jjte000 instanceof RuntimeException) {
2230             throw (RuntimeException)jjte000;
2231           }
2232           if (jjte000 instanceof ParseException) {
2233             throw (ParseException)jjte000;
2234           }
2235           throw (Error)jjte000;
2236         } finally {
2237           if (jjtc000) {
2238             jjtree.closeNodeScope(jjtn000, true);
2239           }
2240         }
2241 /*@egen*/
2244 EvalItemList PEvalItemList() : {/*@bgen(jjtree) PEvalItemList */
2245                                 SimpleNode jjtn000 = new SimpleNode(JJTPEVALITEMLIST);
2246                                 boolean jjtc000 = true;
2247                                 jjtree.openNodeScope(jjtn000);
2248 /*@egen*/EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
2249 {/*@bgen(jjtree) PEvalItemList */
2250         try {
2251 /*@egen*/
2252         (item=PEvalItem()       {list.add(item);}
2253         ("," item=PEvalItem() {list.add(item);})*)/*@bgen(jjtree)*/
2254         {
2255           jjtree.closeNodeScope(jjtn000, true);
2256           jjtc000 = false;
2257         }
2258 /*@egen*/
2259         {return list;}/*@bgen(jjtree)*/
2260         } catch (Throwable jjte000) {
2261           if (jjtc000) {
2262             jjtree.clearNodeScope(jjtn000);
2263             jjtc000 = false;
2264           } else {
2265             jjtree.popNode();
2266           }
2267           if (jjte000 instanceof RuntimeException) {
2268             throw (RuntimeException)jjte000;
2269           }
2270           if (jjte000 instanceof ParseException) {
2271             throw (ParseException)jjte000;
2272           }
2273           throw (Error)jjte000;
2274         } finally {
2275           if (jjtc000) {
2276             jjtree.closeNodeScope(jjtn000, true);
2277           }
2278         }
2279 /*@egen*/
2282 EvalItem PEvalItem() : {/*@bgen(jjtree) PEvalItem */
2283                         SimpleNode jjtn000 = new SimpleNode(JJTPEVALITEM);
2284                         boolean jjtc000 = true;
2285                         jjtree.openNodeScope(jjtn000);
2286 /*@egen*/EvalItem item; EvalSpec subSpec; EvalItemList subProj; LogicalOperator subOp = null;}
2287 {/*@bgen(jjtree) PEvalItem */
2288         try {
2289 /*@egen*/
2290         (
2291         item=Const()
2292 |       item = Star()
2293 |       (
2294         item=PNestableEvalItem()  
2295         ( "["subSpec=PEvalSpec()"]" {((NestableEvalItem) item).addNestedEvalSpec(subSpec);})*
2296                 [
2297                 "." "(" Star() ")"
2298                 {
2299                         EvalItemList list = new EvalItemList(pigContext);
2300                         list.add(new StarEvalItem(pigContext));
2301                         ((NestableEvalItem) item).subColSpec = list;
2302                 }
2303                 ]
2304         ) 
2305         )/*@bgen(jjtree)*/
2306         {
2307           jjtree.closeNodeScope(jjtn000, true);
2308           jjtc000 = false;
2309         }
2310 /*@egen*/
2311         {return item;}/*@bgen(jjtree)*/
2312         } catch (Throwable jjte000) {
2313           if (jjtc000) {
2314             jjtree.clearNodeScope(jjtn000);
2315             jjtc000 = false;
2316           } else {
2317             jjtree.popNode();
2318           }
2319           if (jjte000 instanceof RuntimeException) {
2320             throw (RuntimeException)jjte000;
2321           }
2322           if (jjte000 instanceof ParseException) {
2323             throw (ParseException)jjte000;
2324           }
2325           throw (Error)jjte000;
2326         } finally {
2327           if (jjtc000) {
2328             jjtree.closeNodeScope(jjtn000, true);
2329           }
2330         }
2331 /*@egen*/
2335 NestableEvalItem PNestableEvalItem() : {/*@bgen(jjtree) PNestableEvalItem */
2336                                         SimpleNode jjtn000 = new SimpleNode(JJTPNESTABLEEVALITEM);
2337                                         boolean jjtc000 = true;
2338                                         jjtree.openNodeScope(jjtn000);
2339 /*@egen*/NestableEvalItem item;}
2340 {/*@bgen(jjtree) PNestableEvalItem */
2341         try {
2342 /*@egen*/
2344         (LOOKAHEAD(EvalFunctionItem()) item=EvalFunctionItem()
2345 |       LOOKAHEAD(DollarVar()) item=DollarVar()
2346 |       LOOKAHEAD(SerializedBinCond()) item = SerializedBinCond())/*@bgen(jjtree)*/
2347         {
2348           jjtree.closeNodeScope(jjtn000, true);
2349           jjtc000 = false;
2350         }
2351 /*@egen*/
2352         {return item;}/*@bgen(jjtree)*/
2353         } catch (Throwable jjte000) {
2354           if (jjtc000) {
2355             jjtree.clearNodeScope(jjtn000);
2356             jjtc000 = false;
2357           } else {
2358             jjtree.popNode();
2359           }
2360           if (jjte000 instanceof RuntimeException) {
2361             throw (RuntimeException)jjte000;
2362           }
2363           if (jjte000 instanceof ParseException) {
2364             throw (ParseException)jjte000;
2365           }
2366           throw (Error)jjte000;
2367         } finally {
2368           if (jjtc000) {
2369             jjtree.closeNodeScope(jjtn000, true);
2370           }
2371         }
2372 /*@egen*/
2375 NestableEvalItem EvalFunctionItem() : {/*@bgen(jjtree) EvalFunctionItem */
2376                                        SimpleNode jjtn000 = new SimpleNode(JJTEVALFUNCTIONITEM);
2377                                        boolean jjtc000 = true;
2378                                        jjtree.openNodeScope(jjtn000);
2379 /*@egen*/EvalFunc func; EvalItemList args; NestableEvalItem i;}
2380 {/*@bgen(jjtree) EvalFunctionItem */
2381         try {
2382 /*@egen*/
2383         func=EvalFunction() "(" args=PEvalItemList() ")" {i = newFuncEvalItem(func, args);}/*@bgen(jjtree)*/
2384         {
2385           jjtree.closeNodeScope(jjtn000, true);
2386           jjtc000 = false;
2387         }
2388 /*@egen*/
2389         {return i;}/*@bgen(jjtree)*/
2390         } catch (Throwable jjte000) {
2391           if (jjtc000) {
2392             jjtree.clearNodeScope(jjtn000);
2393             jjtc000 = false;
2394           } else {
2395             jjtree.popNode();
2396           }
2397           if (jjte000 instanceof RuntimeException) {
2398             throw (RuntimeException)jjte000;
2399           }
2400           if (jjte000 instanceof ParseException) {
2401             throw (ParseException)jjte000;
2402           }
2403           throw (Error)jjte000;
2404         } finally {
2405           if (jjtc000) {
2406             jjtree.closeNodeScope(jjtn000, true);
2407           }
2408         }
2409 /*@egen*/
2413 NestableEvalItem SerializedBinCond():
2414 {/*@bgen(jjtree) SerializedBinCond */
2415  SimpleNode jjtn000 = new SimpleNode(JJTSERIALIZEDBINCOND);
2416  boolean jjtc000 = true;
2417  jjtree.openNodeScope(jjtn000);
2418 /*@egen*/Cond cond; EvalItem ifTrue, ifFalse; NestableEvalItem ret = null;}
2419 {/*@bgen(jjtree) SerializedBinCond */
2420         try {
2421 /*@egen*/       
2422         (
2423         "(" cond = PSerializedCond() "?" ifTrue = PEvalItem() 
2424         ":" ifFalse = PEvalItem() ")"
2425         )/*@bgen(jjtree)*/
2426         {
2427           jjtree.closeNodeScope(jjtn000, true);
2428           jjtc000 = false;
2429         }
2430 /*@egen*/
2431         {       
2432                 return new BinCond(pigContext, cond,ifTrue,ifFalse);
2433         }/*@bgen(jjtree)*/
2434         } catch (Throwable jjte000) {
2435           if (jjtc000) {
2436             jjtree.clearNodeScope(jjtn000);
2437             jjtc000 = false;
2438           } else {
2439             jjtree.popNode();
2440           }
2441           if (jjte000 instanceof RuntimeException) {
2442             throw (RuntimeException)jjte000;
2443           }
2444           if (jjte000 instanceof ParseException) {
2445             throw (ParseException)jjte000;
2446           }
2447           throw (Error)jjte000;
2448         } finally {
2449           if (jjtc000) {
2450             jjtree.closeNodeScope(jjtn000, true);
2451           }
2452         }
2453 /*@egen*/       
2457 Cond PSerializedCond() : {/*@bgen(jjtree) PSerializedCond */
2458                           SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDCOND);
2459                           boolean jjtc000 = true;
2460                           jjtree.openNodeScope(jjtn000);
2461 /*@egen*/Cond cond = null;}
2462 {/*@bgen(jjtree) PSerializedCond */
2463         try {
2464 /*@egen*/
2465         cond = PSerializedOrCond()/*@bgen(jjtree)*/
2466         {
2467           jjtree.closeNodeScope(jjtn000, true);
2468           jjtc000 = false;
2469         }
2470 /*@egen*/
2471         {return cond;}/*@bgen(jjtree)*/
2472         } catch (Throwable jjte000) {
2473           if (jjtc000) {
2474             jjtree.clearNodeScope(jjtn000);
2475             jjtc000 = false;
2476           } else {
2477             jjtree.popNode();
2478           }
2479           if (jjte000 instanceof RuntimeException) {
2480             throw (RuntimeException)jjte000;
2481           }
2482           if (jjte000 instanceof ParseException) {
2483             throw (ParseException)jjte000;
2484           }
2485           throw (Error)jjte000;
2486         } finally {
2487           if (jjtc000) {
2488             jjtree.closeNodeScope(jjtn000, true);
2489           }
2490         }
2491 /*@egen*/
2494 Cond PSerializedOrCond() : {/*@bgen(jjtree) PSerializedOrCond */
2495                             SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDORCOND);
2496                             boolean jjtc000 = true;
2497                             jjtree.openNodeScope(jjtn000);
2498 /*@egen*/Cond cond; List<Cond> cList = new ArrayList<Cond>();}
2499 {/*@bgen(jjtree) PSerializedOrCond */
2500         try {
2501 /*@egen*/
2502         (
2503         cond = PSerializedAndCond() {cList.add(cond);}
2504         ( <OR> cond = PSerializedAndCond() {cList.add(cond);})* 
2505         )/*@bgen(jjtree)*/
2506         {
2507           jjtree.closeNodeScope(jjtn000, true);
2508           jjtc000 = false;
2509         }
2510 /*@egen*/
2511         {
2512                 if (cList.size()==1)
2513                         return cond;
2514                 else    
2515                         return new OrCond(cList);
2516         }/*@bgen(jjtree)*/
2517         } catch (Throwable jjte000) {
2518           if (jjtc000) {
2519             jjtree.clearNodeScope(jjtn000);
2520             jjtc000 = false;
2521           } else {
2522             jjtree.popNode();
2523           }
2524           if (jjte000 instanceof RuntimeException) {
2525             throw (RuntimeException)jjte000;
2526           }
2527           if (jjte000 instanceof ParseException) {
2528             throw (ParseException)jjte000;
2529           }
2530           throw (Error)jjte000;
2531         } finally {
2532           if (jjtc000) {
2533             jjtree.closeNodeScope(jjtn000, true);
2534           }
2535         }
2536 /*@egen*/
2538         
2539 Cond PSerializedAndCond() : {/*@bgen(jjtree) PSerializedAndCond */
2540                              SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDANDCOND);
2541                              boolean jjtc000 = true;
2542                              jjtree.openNodeScope(jjtn000);
2543 /*@egen*/Cond cond = null; List<Cond> cList = new ArrayList<Cond>();}
2544 {/*@bgen(jjtree) PSerializedAndCond */
2545         try {
2546 /*@egen*/
2547         (
2548         cond = PSerializedUnaryCond() {cList.add(cond);}
2549         ( <AND> cond = PSerializedUnaryCond() {cList.add(cond);} )*
2550         )/*@bgen(jjtree)*/
2551         {
2552           jjtree.closeNodeScope(jjtn000, true);
2553           jjtc000 = false;
2554         }
2555 /*@egen*/
2556         {
2557                 if (cList.size()==1)
2558                         return cond;
2559                 else    
2560                         return new AndCond(cList);
2561         }/*@bgen(jjtree)*/
2562         } catch (Throwable jjte000) {
2563           if (jjtc000) {
2564             jjtree.clearNodeScope(jjtn000);
2565             jjtc000 = false;
2566           } else {
2567             jjtree.popNode();
2568           }
2569           if (jjte000 instanceof RuntimeException) {
2570             throw (RuntimeException)jjte000;
2571           }
2572           if (jjte000 instanceof ParseException) {
2573             throw (ParseException)jjte000;
2574           }
2575           throw (Error)jjte000;
2576         } finally {
2577           if (jjtc000) {
2578             jjtree.closeNodeScope(jjtn000, true);
2579           }
2580         }
2581 /*@egen*/       
2584 Cond PSerializedUnaryCond() : {/*@bgen(jjtree) PSerializedUnaryCond */
2585                                SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDUNARYCOND);
2586                                boolean jjtc000 = true;
2587                                jjtree.openNodeScope(jjtn000);
2588 /*@egen*/Cond cond = null; EvalItem c1, c2; Token t1; FilterFunc func; EvalItemList args;}
2589 {/*@bgen(jjtree) PSerializedUnaryCond */
2590         try {
2591 /*@egen*/
2592         (
2593         LOOKAHEAD("(" PSerializedCond() ")")
2594         ("(" cond = PSerializedCond() ")")
2595 |       cond = PSerializedNotCond()
2596 |       LOOKAHEAD(PEvalItem() <FILTEROP>) 
2597                 (c1=PEvalItem() t1=<FILTEROP> c2=PEvalItem() {cond = new CompCond(c1, t1.image, c2);})
2598 |       LOOKAHEAD(PEvalItem() <MATCHES>) 
2599                 (c1=PEvalItem() <MATCHES> t1=<QUOTEDSTRING> {cond = new RegexpCond(c1, unquote(t1.image));})
2600 |       (func=FilterFunction() "(" args=PEvalItemList() ")" {cond = new FuncCond(func, args);})
2601         )/*@bgen(jjtree)*/
2602         {
2603           jjtree.closeNodeScope(jjtn000, true);
2604           jjtc000 = false;
2605         }
2606 /*@egen*/
2607         {return cond;}/*@bgen(jjtree)*/
2608         } catch (Throwable jjte000) {
2609           if (jjtc000) {
2610             jjtree.clearNodeScope(jjtn000);
2611             jjtc000 = false;
2612           } else {
2613             jjtree.popNode();
2614           }
2615           if (jjte000 instanceof RuntimeException) {
2616             throw (RuntimeException)jjte000;
2617           }
2618           if (jjte000 instanceof ParseException) {
2619             throw (ParseException)jjte000;
2620           }
2621           throw (Error)jjte000;
2622         } finally {
2623           if (jjtc000) {
2624             jjtree.closeNodeScope(jjtn000, true);
2625           }
2626         }
2627 /*@egen*/
2630 Cond PSerializedNotCond() : {/*@bgen(jjtree) PSerializedNotCond */
2631                              SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDNOTCOND);
2632                              boolean jjtc000 = true;
2633                              jjtree.openNodeScope(jjtn000);
2634 /*@egen*/Cond c1;}
2635 {/*@bgen(jjtree) PSerializedNotCond */
2636         try {
2637 /*@egen*/
2638         <NOT> c1=PSerializedUnaryCond()/*@bgen(jjtree)*/
2639         {
2640           jjtree.closeNodeScope(jjtn000, true);
2641           jjtc000 = false;
2642         }
2643 /*@egen*/
2644         {return new NotCond(c1);}/*@bgen(jjtree)*/
2645         } catch (Throwable jjte000) {
2646           if (jjtc000) {
2647             jjtree.clearNodeScope(jjtn000);
2648             jjtc000 = false;
2649           } else {
2650             jjtree.popNode();
2651           }
2652           if (jjte000 instanceof RuntimeException) {
2653             throw (RuntimeException)jjte000;
2654           }
2655           if (jjte000 instanceof ParseException) {
2656             throw (ParseException)jjte000;
2657           }
2658           throw (Error)jjte000;
2659         } finally {
2660           if (jjtc000) {
2661             jjtree.closeNodeScope(jjtn000, true);
2662           }
2663         }
2664 /*@egen*/
2673 //CQ stuff
2675 EvalSpec PWindow() : {/*@bgen(jjtree) PWindow */
2676                       SimpleNode jjtn000 = new SimpleNode(JJTPWINDOW);
2677                       boolean jjtc000 = true;
2678                       jjtree.openNodeScope(jjtn000);
2679 /*@egen*/EvalSpec spec; int numTuples; double time;}
2680 {/*@bgen(jjtree) PWindow */
2681         try {
2682 /*@egen*/
2683         ( <WINDOW> 
2684                 ( LOOKAHEAD(2)
2685                   time = PTimeWindow() { spec = new TimeWindowSpec(WindowSpec.windowType.SLIDING, time); } |
2686                   numTuples = PTupleWindow() { spec = new TupleWindowSpec(WindowSpec.windowType.SLIDING, numTuples);}
2687                 )
2688         )/*@bgen(jjtree)*/
2689         {
2690           jjtree.closeNodeScope(jjtn000, true);
2691           jjtc000 = false;
2692         }
2693 /*@egen*/         
2694         {return spec;}/*@bgen(jjtree)*/
2695         } catch (Throwable jjte000) {
2696           if (jjtc000) {
2697             jjtree.clearNodeScope(jjtn000);
2698             jjtc000 = false;
2699           } else {
2700             jjtree.popNode();
2701           }
2702           if (jjte000 instanceof RuntimeException) {
2703             throw (RuntimeException)jjte000;
2704           }
2705           if (jjte000 instanceof ParseException) {
2706             throw (ParseException)jjte000;
2707           }
2708           throw (Error)jjte000;
2709         } finally {
2710           if (jjtc000) {
2711             jjtree.closeNodeScope(jjtn000, true);
2712           }
2713         }
2714 /*@egen*/
2715 }       
2716         
2717 double PTimeWindow() : {/*@bgen(jjtree) PTimeWindow */
2718                         SimpleNode jjtn000 = new SimpleNode(JJTPTIMEWINDOW);
2719                         boolean jjtc000 = true;
2720                         jjtree.openNodeScope(jjtn000);
2721 /*@egen*/double n; Token t;}
2722 {/*@bgen(jjtree) PTimeWindow */
2723         try {
2724 /*@egen*/
2725         ( t = <NUMBER> { n = Double.parseDouble(t.image); }
2726                 ( <SECONDS> |
2727                   <MINUTES> { n = n*60; } |
2728                   <HOURS> { n = n * 3600; }
2729                 )
2730         )/*@bgen(jjtree)*/
2731         {
2732           jjtree.closeNodeScope(jjtn000, true);
2733           jjtc000 = false;
2734         }
2735 /*@egen*/
2736         {return n;}/*@bgen(jjtree)*/
2737         } finally {
2738           if (jjtc000) {
2739             jjtree.closeNodeScope(jjtn000, true);
2740           }
2741         }
2742 /*@egen*/
2743 }   
2745 int PTupleWindow() : {/*@bgen(jjtree) PTupleWindow */
2746                       SimpleNode jjtn000 = new SimpleNode(JJTPTUPLEWINDOW);
2747                       boolean jjtc000 = true;
2748                       jjtree.openNodeScope(jjtn000);
2749 /*@egen*/int n; Token t;}
2750 {/*@bgen(jjtree) PTupleWindow */
2751         try {
2752 /*@egen*/
2753         ( t = <NUMBER> { try{ 
2754                                                 n = Integer.parseInt(t.image); 
2755                                          }catch(NumberFormatException e){
2756                                                 throw new ParseException("Only whole number tuple windows allowed.");
2757                                          }
2758                                    } 
2759                  <TUPLES> 
2760         )/*@bgen(jjtree)*/
2761         {
2762           jjtree.closeNodeScope(jjtn000, true);
2763           jjtc000 = false;
2764         }
2765 /*@egen*/
2766         {return n;}/*@bgen(jjtree)*/
2767         } finally {
2768           if (jjtc000) {
2769             jjtree.closeNodeScope(jjtn000, true);
2770           }
2771         }
2772 /*@egen*/
2773 }   
2774         
2781 // These the simple non-terminals that are shared across many
2783 EvalFunc EvalFunction() : {/*@bgen(jjtree) EvalFunction */
2784                            SimpleNode jjtn000 = new SimpleNode(JJTEVALFUNCTION);
2785                            boolean jjtc000 = true;
2786                            jjtree.openNodeScope(jjtn000);
2787 /*@egen*/String funcName;}
2788 {/*@bgen(jjtree) EvalFunction */
2789         try {
2790 /*@egen*/
2791         funcName = QualifiedFunction()/*@bgen(jjtree)*/
2792         {
2793           jjtree.closeNodeScope(jjtn000, true);
2794           jjtc000 = false;
2795         }
2796 /*@egen*/
2797         {return (EvalFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2798         } catch (Throwable jjte000) {
2799           if (jjtc000) {
2800             jjtree.clearNodeScope(jjtn000);
2801             jjtc000 = false;
2802           } else {
2803             jjtree.popNode();
2804           }
2805           if (jjte000 instanceof RuntimeException) {
2806             throw (RuntimeException)jjte000;
2807           }
2808           if (jjte000 instanceof ParseException) {
2809             throw (ParseException)jjte000;
2810           }
2811           throw (Error)jjte000;
2812         } finally {
2813           if (jjtc000) {
2814             jjtree.closeNodeScope(jjtn000, true);
2815           }
2816         }
2817 /*@egen*/
2820 GroupFunc GroupFunction() : {/*@bgen(jjtree) GroupFunction */
2821                              SimpleNode jjtn000 = new SimpleNode(JJTGROUPFUNCTION);
2822                              boolean jjtc000 = true;
2823                              jjtree.openNodeScope(jjtn000);
2824 /*@egen*/String funcName;}
2825 {/*@bgen(jjtree) GroupFunction */
2826         try {
2827 /*@egen*/
2828         funcName = QualifiedFunction()/*@bgen(jjtree)*/
2829         {
2830           jjtree.closeNodeScope(jjtn000, true);
2831           jjtc000 = false;
2832         }
2833 /*@egen*/
2834         {return (GroupFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2835         } catch (Throwable jjte000) {
2836           if (jjtc000) {
2837             jjtree.clearNodeScope(jjtn000);
2838             jjtc000 = false;
2839           } else {
2840             jjtree.popNode();
2841           }
2842           if (jjte000 instanceof RuntimeException) {
2843             throw (RuntimeException)jjte000;
2844           }
2845           if (jjte000 instanceof ParseException) {
2846             throw (ParseException)jjte000;
2847           }
2848           throw (Error)jjte000;
2849         } finally {
2850           if (jjtc000) {
2851             jjtree.closeNodeScope(jjtn000, true);
2852           }
2853         }
2854 /*@egen*/
2857 StorageFunc LoadFunction() : {/*@bgen(jjtree) LoadFunction */
2858                               SimpleNode jjtn000 = new SimpleNode(JJTLOADFUNCTION);
2859                               boolean jjtc000 = true;
2860                               jjtree.openNodeScope(jjtn000);
2861 /*@egen*/String funcName;}
2862 {/*@bgen(jjtree) LoadFunction */
2863         try {
2864 /*@egen*/
2865         funcName = QualifiedFunction()/*@bgen(jjtree)*/
2866         {
2867           jjtree.closeNodeScope(jjtn000, true);
2868           jjtc000 = false;
2869         }
2870 /*@egen*/
2871         {return (StorageFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2872         } catch (Throwable jjte000) {
2873           if (jjtc000) {
2874             jjtree.clearNodeScope(jjtn000);
2875             jjtc000 = false;
2876           } else {
2877             jjtree.popNode();
2878           }
2879           if (jjte000 instanceof RuntimeException) {
2880             throw (RuntimeException)jjte000;
2881           }
2882           if (jjte000 instanceof ParseException) {
2883             throw (ParseException)jjte000;
2884           }
2885           throw (Error)jjte000;
2886         } finally {
2887           if (jjtc000) {
2888             jjtree.closeNodeScope(jjtn000, true);
2889           }
2890         }
2891 /*@egen*/
2894 FilterFunc FilterFunction() : {/*@bgen(jjtree) FilterFunction */
2895                                SimpleNode jjtn000 = new SimpleNode(JJTFILTERFUNCTION);
2896                                boolean jjtc000 = true;
2897                                jjtree.openNodeScope(jjtn000);
2898 /*@egen*/String funcName;}
2899 {/*@bgen(jjtree) FilterFunction */
2900         try {
2901 /*@egen*/
2902         funcName = QualifiedFunction()/*@bgen(jjtree)*/
2903         {
2904           jjtree.closeNodeScope(jjtn000, true);
2905           jjtc000 = false;
2906         }
2907 /*@egen*/
2908         {return (FilterFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2909         } catch (Throwable jjte000) {
2910           if (jjtc000) {
2911             jjtree.clearNodeScope(jjtn000);
2912             jjtc000 = false;
2913           } else {
2914             jjtree.popNode();
2915           }
2916           if (jjte000 instanceof RuntimeException) {
2917             throw (RuntimeException)jjte000;
2918           }
2919           if (jjte000 instanceof ParseException) {
2920             throw (ParseException)jjte000;
2921           }
2922           throw (Error)jjte000;
2923         } finally {
2924           if (jjtc000) {
2925             jjtree.closeNodeScope(jjtn000, true);
2926           }
2927         }
2928 /*@egen*/
2932  * Bug 831620 - '$' support
2933  */
2934 void ClassName()       : {} { <IDENTIFIER> (("."  <IDENTIFIER>)|("$"  <IDENTIFIER>))* }
2937  * Bug 831620 - '$' support
2938  */
2939 String QualifiedFunction()       : {Token t1;StringBuffer s=new StringBuffer();}
2941         ((t1=<IDENTIFIER> { s.append(t1.image);}
2942          (("." t1=<IDENTIFIER> {s.append("." + t1.image);})| 
2943           ("$" t1=<IDENTIFIER> {s.append("$" + t1.image);}))*)) 
2944          {return s.toString();}
2948 // If there is one time it may not be bracketed, but if multiple, they must be bracketed
2949 EvalItemList BracketedSimpleProj(SchemaItem over) : {/*@bgen(jjtree) BracketedSimpleProj */
2950                                                      SimpleNode jjtn000 = new SimpleNode(JJTBRACKETEDSIMPLEPROJ);
2951                                                      boolean jjtc000 = true;
2952                                                      jjtree.openNodeScope(jjtn000);
2953 /*@egen*/EvalItem i = null; EvalItemList proj = new EvalItemList(pigContext);}
2954 {/*@bgen(jjtree) BracketedSimpleProj */
2955         try {
2956 /*@egen*/
2957         (
2958         i = PSimpleProjItem(over) {proj.add(i);}
2959 |       ("(" i = PSimpleProjItem(over) {proj.add(i);}   
2960                 ("," i = PSimpleProjItem(over) {proj.add(i);})*
2961         ")")    
2962         )/*@bgen(jjtree)*/
2963         {
2964           jjtree.closeNodeScope(jjtn000, true);
2965           jjtc000 = false;
2966         }
2967 /*@egen*/
2968         {return proj;}/*@bgen(jjtree)*/
2969         } catch (Throwable jjte000) {
2970           if (jjtc000) {
2971             jjtree.clearNodeScope(jjtn000);
2972             jjtc000 = false;
2973           } else {
2974             jjtree.popNode();
2975           }
2976           if (jjte000 instanceof RuntimeException) {
2977             throw (RuntimeException)jjte000;
2978           }
2979           if (jjte000 instanceof ParseException) {
2980             throw (ParseException)jjte000;
2981           }
2982           throw (Error)jjte000;
2983         } finally {
2984           if (jjtc000) {
2985             jjtree.closeNodeScope(jjtn000, true);
2986           }
2987         }
2988 /*@egen*/       
2991 EvalItemList SimpleProjOrEmpty(SchemaItem over) : {/*@bgen(jjtree) SimpleProjOrEmpty */
2992                                                    SimpleNode jjtn000 = new SimpleNode(JJTSIMPLEPROJOREMPTY);
2993                                                    boolean jjtc000 = true;
2994                                                    jjtree.openNodeScope(jjtn000);
2995 /*@egen*/EvalItemList list;}
2996 {/*@bgen(jjtree) SimpleProjOrEmpty */
2997         try {
2998 /*@egen*/
2999         (
3000         list = SimpleProj(over)
3001 |       {list = new EvalItemList(pigContext);}
3002         )/*@bgen(jjtree)*/
3003         {
3004           jjtree.closeNodeScope(jjtn000, true);
3005           jjtc000 = false;
3006         }
3007 /*@egen*/
3008         {return list;}/*@bgen(jjtree)*/
3009         } catch (Throwable jjte000) {
3010           if (jjtc000) {
3011             jjtree.clearNodeScope(jjtn000);
3012             jjtc000 = false;
3013           } else {
3014             jjtree.popNode();
3015           }
3016           if (jjte000 instanceof RuntimeException) {
3017             throw (RuntimeException)jjte000;
3018           }
3019           if (jjte000 instanceof ParseException) {
3020             throw (ParseException)jjte000;
3021           }
3022           throw (Error)jjte000;
3023         } finally {
3024           if (jjtc000) {
3025             jjtree.closeNodeScope(jjtn000, true);
3026           }
3027         }
3028 /*@egen*/
3029 }       
3031 //Just a simple list of projection items
3032 EvalItemList SimpleProj(SchemaItem over) : {/*@bgen(jjtree) SimpleProj */
3033                                             SimpleNode jjtn000 = new SimpleNode(JJTSIMPLEPROJ);
3034                                             boolean jjtc000 = true;
3035                                             jjtree.openNodeScope(jjtn000);
3036 /*@egen*/EvalItem i = null; EvalItemList proj = new EvalItemList(pigContext);}
3037 {/*@bgen(jjtree) SimpleProj */
3038         try {
3039 /*@egen*/
3040         (
3041         i = PSimpleProjItem(over) {proj.add(i);}        
3042                 ("," i = PSimpleProjItem(over) {proj.add(i);})*
3043         )/*@bgen(jjtree)*/
3044         {
3045           jjtree.closeNodeScope(jjtn000, true);
3046           jjtc000 = false;
3047         }
3048 /*@egen*/
3049         {return proj;}/*@bgen(jjtree)*/
3050         } catch (Throwable jjte000) {
3051           if (jjtc000) {
3052             jjtree.clearNodeScope(jjtn000);
3053             jjtc000 = false;
3054           } else {
3055             jjtree.popNode();
3056           }
3057           if (jjte000 instanceof RuntimeException) {
3058             throw (RuntimeException)jjte000;
3059           }
3060           if (jjte000 instanceof ParseException) {
3061             throw (ParseException)jjte000;
3062           }
3063           throw (Error)jjte000;
3064         } finally {
3065           if (jjtc000) {
3066             jjtree.closeNodeScope(jjtn000, true);
3067           }
3068         }
3069 /*@egen*/       
3072 EvalItem PSimpleProjItem(SchemaItem over):
3073 {/*@bgen(jjtree) PSimpleProjItem */
3074  SimpleNode jjtn000 = new SimpleNode(JJTPSIMPLEPROJITEM);
3075  boolean jjtc000 = true;
3076  jjtree.openNodeScope(jjtn000);
3077 /*@egen*/EvalItem item;}
3078 {/*@bgen(jjtree) PSimpleProjItem */
3079         try {
3080 /*@egen*/
3081         (
3082         item = Const()
3083 |       item = PColEvalItem(over,null)
3084 |       item = Star()
3085         )/*@bgen(jjtree)*/
3086         {
3087           jjtree.closeNodeScope(jjtn000, true);
3088           jjtc000 = false;
3089         }
3090 /*@egen*/
3091         {return item;}/*@bgen(jjtree)*/
3092         } catch (Throwable jjte000) {
3093           if (jjtc000) {
3094             jjtree.clearNodeScope(jjtn000);
3095             jjtc000 = false;
3096           } else {
3097             jjtree.popNode();
3098           }
3099           if (jjte000 instanceof RuntimeException) {
3100             throw (RuntimeException)jjte000;
3101           }
3102           if (jjte000 instanceof ParseException) {
3103             throw (ParseException)jjte000;
3104           }
3105           throw (Error)jjte000;
3106         } finally {
3107           if (jjtc000) {
3108             jjtree.closeNodeScope(jjtn000, true);
3109           }
3110         }
3111 /*@egen*/
3112 }               
3115 EvalItem Star() : {/*@bgen(jjtree) Star */
3116                    SimpleNode jjtn000 = new SimpleNode(JJTSTAR);
3117                    boolean jjtc000 = true;
3118                    jjtree.openNodeScope(jjtn000);
3119 /*@egen*/Token t1;}
3120 {/*@bgen(jjtree) Star */
3121         try {
3122 /*@egen*/
3123         t1=<STAR>/*@bgen(jjtree)*/
3124         {
3125           jjtree.closeNodeScope(jjtn000, true);
3126           jjtc000 = false;
3127         }
3128 /*@egen*/
3129         {return new StarEvalItem(pigContext);}/*@bgen(jjtree)*/
3130         } finally {
3131           if (jjtc000) {
3132             jjtree.closeNodeScope(jjtn000, true);
3133           }
3134         }
3135 /*@egen*/       
3138 EvalItem Const() : {/*@bgen(jjtree) Const */
3139                     SimpleNode jjtn000 = new SimpleNode(JJTCONST);
3140                     boolean jjtc000 = true;
3141                     jjtree.openNodeScope(jjtn000);
3142 /*@egen*/Token t1;}
3143 {/*@bgen(jjtree) Const */
3144         try {
3145 /*@egen*/
3146         t1=<QUOTEDSTRING>/*@bgen(jjtree)*/
3147         {
3148           jjtree.closeNodeScope(jjtn000, true);
3149           jjtc000 = false;
3150         }
3151 /*@egen*/ 
3152         {return new ConstEvalItem(pigContext, unquote(t1.image));}/*@bgen(jjtree)*/
3153         } finally {
3154           if (jjtc000) {
3155             jjtree.closeNodeScope(jjtn000, true);
3156           }
3157         }
3158 /*@egen*/
3161 EvalItem PColEvalItem(SchemaItem over, Map<String, EvalItem> pipes):
3162 {/*@bgen(jjtree) PColEvalItem */
3163  SimpleNode jjtn000 = new SimpleNode(JJTPCOLEVALITEM);
3164  boolean jjtc000 = true;
3165  jjtree.openNodeScope(jjtn000);
3166 /*@egen*/EvalItem item;}
3167 {/*@bgen(jjtree) PColEvalItem */
3168         try {
3169 /*@egen*/
3170         (
3171         item = DollarVar()
3172 |       item = AliasField(over, pipes)
3173         )/*@bgen(jjtree)*/
3174         {
3175           jjtree.closeNodeScope(jjtn000, true);
3176           jjtc000 = false;
3177         }
3178 /*@egen*/
3179         {
3180                 return item;
3181         }/*@bgen(jjtree)*/
3182         } catch (Throwable jjte000) {
3183           if (jjtc000) {
3184             jjtree.clearNodeScope(jjtn000);
3185             jjtc000 = false;
3186           } else {
3187             jjtree.popNode();
3188           }
3189           if (jjte000 instanceof RuntimeException) {
3190             throw (RuntimeException)jjte000;
3191           }
3192           if (jjte000 instanceof ParseException) {
3193             throw (ParseException)jjte000;
3194           }
3195           throw (Error)jjte000;
3196         } finally {
3197           if (jjtc000) {
3198             jjtree.closeNodeScope(jjtn000, true);
3199           }
3200         }
3201 /*@egen*/
3204 ColEvalItem DollarVar() : {/*@bgen(jjtree) DollarVar */
3205                            SimpleNode jjtn000 = new SimpleNode(JJTDOLLARVAR);
3206                            boolean jjtc000 = true;
3207                            jjtree.openNodeScope(jjtn000);
3208 /*@egen*/Token t1;}
3209 {/*@bgen(jjtree) DollarVar */
3210         try {
3211 /*@egen*/
3212         t1=<DOLLARVAR>/*@bgen(jjtree)*/
3213         {
3214           jjtree.closeNodeScope(jjtn000, true);
3215           jjtc000 = false;
3216         }
3217 /*@egen*/       
3218         {return new ColEvalItem(pigContext, undollar(t1.image));}/*@bgen(jjtree)*/
3219         } finally {
3220           if (jjtc000) {
3221             jjtree.closeNodeScope(jjtn000, true);
3222           }
3223         }
3224 /*@egen*/
3227 EvalItem AliasField(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) AliasField */
3228                                                                      SimpleNode jjtn000 = new SimpleNode(JJTALIASFIELD);
3229                                                                      boolean jjtc000 = true;
3230                                                                      jjtree.openNodeScope(jjtn000);
3231 /*@egen*/Token t1;}
3232 {/*@bgen(jjtree) AliasField */
3233         try {
3234 /*@egen*/
3235         (t1=<GROUP> | t1=<IDENTIFIER>)/*@bgen(jjtree)*/
3236         {
3237           jjtree.closeNodeScope(jjtn000, true);
3238           jjtc000 = false;
3239         }
3240 /*@egen*/ 
3241         {       int i; EvalItem item = null;
3242                 if (pipes!=null)
3243                         item = pipes.get(t1.image);
3244                 
3245                 if (item == null){
3246                         if ( over == null ||  (i = over.colFor(t1.image)) == -1)
3247                                 throw new ParseException("Invalid alias: " + t1.image + " in " + over.alias + "--> " + over); 
3248                         item = new ColEvalItem(pigContext, i);          
3249                 }
3250                 return item;
3251         }/*@bgen(jjtree)*/
3252         } finally {
3253           if (jjtc000) {
3254             jjtree.closeNodeScope(jjtn000, true);
3255           }
3256         }
3257 /*@egen*/