KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xquery > parser > XQueryParser


1 /* Generated By:JavaCC: Do not edit this line. XQueryParser.java */
2 package org.xquark.xquery.parser;
3
4 import java.util.*;
5 import org.xquark.xquery.*;
6 import org.xquark.xquery.typing.*;
7 import org.xquark.xquery.parser.util.*;
8 import org.xquark.xquery.parser.primitivefunctions.fnfunctions.*;
9 import org.xquark.xquery.parser.primitivefunctions.xsfunctions.*;
10 import org.xquark.xquery.parser.hinttree.*;
11 import org.xquark.xquery.normalize.*;
12 import org.xquark.util.*;
13 import org.xquark.xpath.*;
14 import org.xquark.xquery.metadata.*;
15 import org.xquark.schema.*;
16 import org.xquark.xquery.metadata.resolver.*;
17 import java.net.*;
18 import org.xml.sax.SAXException;
19
20 public class XQueryParser implements XQueryParserConstants {
21         private static final String RCSRevision = "$Revision: 1.14 $";
22         private static final String RCSName = "$Name: $";
23
24         // to restrict parser, by default: true
25
private boolean restriction = true;
26
27         private Token currentToken = null;
28         private StaticContext staticcontext = null;
29         private SchemaManager initialSchemamanager = null;
30         //private TypeVisitor typevisitor = null;
31
private XQueryModule parentModule = null;
32
33         private final String VAR_NAME = "var";
34         private final String XMLNS = "xmlns";
35         private final String XML = "xml";
36         private final String XS = "xs";
37         private final String XSI = "xsi";
38         private final String FN = "fn";
39         private final String XDT = "xdt";
40         private final String LOCAL = "local";
41         private final String XMLURI = "http://www.w3.org/XML/1998/namespace";
42         private final String XSURI = "http://www.w3.org/2001/XMLSchema";
43         private final String XSIURI = "http://www.w3.org/2001/XMLSchema-instance";
44         private final String FNURI = "http://www.w3.org/2003/11/xpath-functions";
45         private final String XDTURI = "http://www.w3.org/2003/11/xpath-datatypes";
46         private final String LOCALURI = "http://www.w3.org/2003/11/xquery-local-functions";
47
48         private ParserFactoryInterface factory = null;
49
50         /* a Map from view name to view definition(String)*/
51         private Map viewDefinitions = null;
52
53         private HashMap varDefNames = new HashMap();
54         private HashMap linkMap = new HashMap();
55
56         private NamespaceContextStack namespaceContextStack = new NamespaceContextStack();
57
58         private ArrayList declList = new ArrayList();
59
60         private HashMap hashDeclVarList = new HashMap();
61         private HashMap hashExtVar = new HashMap();
62
63         private HashMap hashDeclFuncList = new HashMap();
64
65         private HashMap importSchemas = new HashMap();
66         private ArrayList schemaList = new ArrayList();
67
68         private HashMap importModules = new HashMap();
69         private ArrayList moduleList = new ArrayList();
70
71         private String defaultElementNameSpace = null;
72         private String defaultFunctionNameSpace = null;
73
74         private String defaultCollation = null;
75         private String baseURI = null;
76         private boolean hasDeclaredBaseURI = false;
77         private int xmlspace = Constants.NOTHING; // "strip" default value (preserve -> false)
78
private int validation = Constants.NOTHING;
79
80         private boolean inPredicate = false;
81
82         private String libraryPrefix = null;
83
84         public void reset() {
85                 varDefNames.clear();
86                 namespaceContextStack.reset();
87
88                 declList = new ArrayList();
89                 hashDeclVarList = new HashMap();
90                 hashDeclFuncList = new HashMap();
91                 importSchemas = new HashMap();
92                 importModules = new HashMap();
93                 schemaList = new ArrayList();
94                 moduleList = new ArrayList();
95                 hashExtVar = new HashMap();
96
97                 defaultElementNameSpace = null;
98                 defaultFunctionNameSpace = null;
99                 defaultCollation = null;
100                 xmlspace = Constants.NOTHING;
101                 validation = Constants.NOTHING;
102                 inPredicate = false;
103                 token_source.getStateStack().clear();
104         }
105
106         public void setBaseURI(String uri) {
107                 baseURI = uri;
108         }
109
110         private String unquote(String s) {
111                 return s.substring(1, s.length()-1);
112         }
113
114         private String getNameSpace(String prefixname) {
115                 if (prefixname == null) return null;
116                 String str = namespaceContextStack.getNamespaceURI(prefixname);
117                 if (str == null) {
118                         if (prefixname.equals(XML))
119                                 str = XMLURI;
120                                 //namespaceContextStack.declarePrefix(XML,"http://www.w3.org/XML/1998/namespace");
121
else if (prefixname.equals(XS))
122                                 str = XSURI;
123                                 //namespaceContextStack.declarePrefix(XS,"http://www.w3.org/2001/XMLSchema");
124
else if (prefixname.equals(XSI))
125                                 str = XSIURI;
126                                 //namespaceContextStack.declarePrefix(XSI,"http://www.w3.org/2001/XMLSchema-instance");
127
else if (prefixname.equals(FN))
128                                 str = FNURI;
129                                 //namespaceContextStack.declarePrefix(FN,"http://www.w3.org/2003/11/xpath-functions");
130
else if (prefixname.equals(XDT))
131                                 str = XDTURI;
132                                 //namespaceContextStack.declarePrefix(XDT,"http://www.w3.org/2003/11/xpath-datatypes");
133
else if (prefixname.equals(LOCAL))
134                                 str =LOCALURI;
135                                 //namespaceContextStack.declarePrefix(LOCAL,"http://www.w3.org/2003/11/xquery-local-functions");
136
//str = namespaceContextStack.getNamespaceURI(prefixname);
137
}
138                 return str;
139         }
140
141         public TypeVisitor getTypeVisitor() {
142                 return staticcontext.getTypeVisitor();
143         }
144
145         public SchemaManager getSchemaManager() {
146                 return initialSchemamanager;
147         }
148
149         public void setFactory(String factoryClassName) throws ParseException {
150                 try {
151                         Class c = Class.forName (factoryClassName) ;
152                         factory = (ParserFactoryInterface) c.newInstance () ;
153                 }
154                 catch (ClassNotFoundException e) {
155                         throw new ParseException("Could not find class " + factoryClassName);
156                 }
157         catch (IllegalAccessException e) {
158                 throw new ParseException("Could not access factory builder");
159         }
160                 catch (InstantiationException e) {
161                                 throw new ParseException("Could not instantiate factory");
162                 }
163         }
164
165
166         public void setViewDefinitions(Map viewDefinitions) {
167                 this.viewDefinitions = viewDefinitions;
168         }
169
170         private char parsePredefinedEntityRef(String predefinedEntityRef) throws ParseException {
171                 if (predefinedEntityRef.equals("&lt;")) return '<';
172                 if (predefinedEntityRef.equals("&gt;")) return '>';
173                 if (predefinedEntityRef.equals("&amp;")) return '&';
174                 if (predefinedEntityRef.equals("&quot;")) return '"';
175                 if (predefinedEntityRef.equals("&apos;")) return '\'';
176                 throw new ParseException("Invalid token error.");
177         }
178
179         private static char parseCharRef(String charRef) {
180                 int value = -1;
181                 if (charRef.startsWith("&#x")) value = Integer.parseInt(charRef.substring(3, charRef.length() - 1), 16);
182                 else value = Integer.parseInt(charRef.substring(2, charRef.length() - 1));
183                 switch(value) {
184                         case(9):
185                                 return '\t';
186                         case(10):
187                                 return '\n';
188                         case(13):
189                                 return '\r';
190                         default:
191                                 return (new Character((char)value)).charValue();
192                 }
193         }
194
195         private String extractName(String image,String left, String right) {
196                 int index;
197                 if (left != null) {
198                         index = image.indexOf(left);
199                         if (index != -1)
200                                 image = image.substring(index+left.length()).trim();
201                 }
202                 if (right != null) {
203                         index = image.indexOf(right);
204                         if (index != -1)
205                                 image = image.substring(0,index).trim();
206                 }
207                 return image;
208         }
209
210         /**************************************************************************************
211     [21] QName ::= [http://www.w3.org/TR/REC-xml-names/#NT-QName] Names
212     [6] QName ::= (Prefix ':')? LocalPart
213     [7] Prefix ::= NCName
214     [8] LocalPart ::= NCName
215     **************************************************************************************/

216         private QName QName(String image) throws ParseException, TypeException, XQueryException {
217                 return QName(image,true,false);
218         }
219         private QName QName(String image, boolean check) throws ParseException, TypeException, XQueryException {
220                 return QName(image,check,false);
221         }
222         private QName QName(String image, boolean check, boolean isFunction) throws ParseException, TypeException, XQueryException {
223                 return QName(image,check,null,false);
224         }
225         private QName QName(String image, boolean check, String prefix, boolean isFunction) throws ParseException, TypeException, XQueryException {
226                 String namespace = null;
227                 String prefixname = null;
228                 String typeName = null;
229
230                 // calculate above values from image
231
int index = image.indexOf(':');
232         if (index == -1)
233                         typeName = image;
234                 else {
235                         prefixname = image.substring(0,index);
236                         typeName = image.substring(index+1);
237                 }
238                 if (prefix != null && !prefix.equals(prefixname)) {
239                         throw new TypeException("Incorrect prefix [ " + prefixname + " ], expected [ " + prefix + " ]" , currentToken.beginLine, currentToken.beginColumn);
240                 }
241                 try {
242                         String tmpStr = null;
243                         if (prefixname == null)
244                         {
245                                 if (isFunction)
246                                         namespace = defaultFunctionNameSpace;
247 // AM: Why is this check needed? It prevents default namespace resolution!
248
// else if (!check)
249
else
250                                         namespace = defaultElementNameSpace;
251                         }
252                         else
253                         {
254                                 if (!prefixname.equals(XMLNS) && check)
255                                 {
256                                         tmpStr = getNameSpace(prefixname);
257                                         if (tmpStr == null)
258                                                 throw new TypeException("Could not match prefix [ " + prefixname + " ]" , currentToken.beginLine, currentToken.beginColumn);
259                                         namespace = tmpStr;
260                                 }
261                         }
262                         return factory.createQName(namespace, prefixname, typeName, parentModule, namespaceContextStack.getNamespaceContext());
263                 } catch (TypeException te)
264                 {
265                         throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);
266                 }
267         }
268
269         /**************************************************************************************
270     [20] VarName ::= QName
271     **************************************************************************************/

272         private XQueryExpression VarName(String varname) throws ParseException, TypeException, XQueryException {
273                 return VarName(varname, true, null, true);
274         }
275         private XQueryExpression VarName(String varname, String prefix) throws ParseException, TypeException, XQueryException {
276                 return VarName(varname, true, prefix, true);
277         }
278         private XQueryExpression VarName(String varname, boolean isnew) throws ParseException, TypeException, XQueryException {
279                 return VarName(varname, isnew, null, true);
280         }
281         private XQueryExpression VarName(String varname, boolean isnew, String prefix, boolean rename) throws ParseException, TypeException, XQueryException {
282                 Variable var = null;
283
284                 String varStr = "$" + varname;
285                 String namespace = null;
286                 String prefixname = null;
287                 String localName = null;
288
289                 // calculate above values from image
290
int index = varname.indexOf(':');
291         if (index == -1)
292                         localName = varname;
293                 else {
294                         prefixname = varname.substring(0,index);
295                         localName = varname.substring(index+1);
296                 }
297                 if (prefix != null && !prefix.equals(prefixname)) {
298                         throw new TypeException("Incorrect prefix [ " + prefixname + " ], expected [ " + prefix + " ]" , currentToken.beginLine, currentToken.beginColumn);
299                 }
300                 if (prefixname != null)
301                 {
302                         String tmpStr = getNameSpace(prefixname);
303                         if (tmpStr == null)
304                                 throw new TypeException("Could not match prefix [ " + prefixname + " ]" , currentToken.beginLine, currentToken.beginColumn);
305                         namespace = tmpStr;
306                 }
307                 String varStringValue = localName;
308                 if (namespace != null) {
309                         varStringValue = "${"+namespace+"}"+varStringValue;
310                 } else {
311                         varStringValue = "$"+varStringValue;
312                 }
313                 // calculate above values from image
314
if (isnew)
315                 {
316                         if (varDefNames.containsKey(varStr) || hashDeclVarList.containsKey(varStr))
317                         {
318                                 throw new ParseException("Error : Variable $" + varname + " already defined!");
319                         }
320                         if (rename) {
321                                         localName = staticcontext.getVarName(parentModule).getLocalName();
322                                         String varNewStringValue = localName;
323                                         if (namespace != null) {
324                                                 varNewStringValue = "${"+namespace+"}"+varNewStringValue;
325                                         } else {
326                                                 varNewStringValue = "$"+varNewStringValue;
327                                         }
328                                         linkMap.put(varNewStringValue,varStringValue);
329                         }
330                         try
331                         {
332                                 var = factory.createVariable(factory.createQName(namespace, prefixname, localName, parentModule, namespaceContextStack.getNamespaceContext()), parentModule);
333                                 addVarDefinition(varStringValue,var);
334                         }
335                         catch (TypeException te)
336                         {
337                                 throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);
338                         }
339                 }
340                 else
341                 {
342                         /*
343             HashMap map = (HashMap)hashDeclVarList.get(namespace);
344             if (map != null && var != null)
345                 var = (Variable)map.get(var.getVarName().getLocalName());
346             if (var == null)
347             */

348                                 var = getVarDefinition(varStringValue);
349                         if (var == null)
350                         {
351                                 throw new TypeException("Error : Variable $" + varname + " not defined!", currentToken.beginLine, currentToken.beginColumn);
352                         }
353                         ExternalVariable extVar = (ExternalVariable)hashExtVar.get(var);
354                         if (extVar != null)
355                                 return extVar;
356                 }
357                 return var;
358         }
359
360         private void addVarDefinition(String varStr, Variable var) {
361                 Stack st = (Stack)varDefNames.get(varStr);
362                 if (st == null) {
363                         st = new Stack();
364                         varDefNames.put(varStr,st);
365                 }
366                 st.push(var);
367         }
368
369         private void removeVarDefinition(String varStr) {
370                 String str = (String)linkMap.get(varStr);
371                 if (str == null) str = varStr;
372                 Stack st = (Stack)varDefNames.get(str);
373                 st.pop();
374                 if (st.isEmpty())
375                         varDefNames.remove(str);
376         }
377
378         private Variable getVarDefinition(String varStr) {
379                 Stack st = (Stack)varDefNames.get(varStr);
380                 if (st == null || st.isEmpty())
381                         return null;
382                 return (Variable)st.peek();
383         }
384
385         public XQueryModule Start(MetadataAccess metadata, SchemaManager schemamanager, ModuleManager modulemanager, VarCounter varCounter, boolean qaOnly) throws ParseException, TypeException, XQueryException {
386                 return Start(metadata, schemamanager, modulemanager, varCounter, qaOnly, true);
387         }
388
389         public XQueryModule Start(MetadataAccess metadata, SchemaManager schemamanager, ModuleManager modulemanager, VarCounter varCounter) throws ParseException, TypeException, XQueryException {
390                 return Start(metadata, schemamanager, modulemanager, varCounter, false, true);
391         }
392
393   final public XQueryModule Start(MetadataAccess metadata, SchemaManager schemamanager, ModuleManager modulemanager, VarCounter varCounter, boolean qaOnly, boolean restriction) throws ParseException, TypeException, XQueryException {
394         this.restriction = restriction;
395         if (factory == null) factory = new ParserFactory();
396         parentModule = factory.createXQueryModule();
397         initialSchemamanager = schemamanager;
398         staticcontext = new StaticContext(metadata,initialSchemamanager,modulemanager,varCounter);
399         staticcontext.setTypeVisitor(new TypeVisitor(staticcontext, qaOnly));
400         parentModule.setStaticContext(staticcontext);
401         reset();
402     try {
403       XQueryModule();
404       jj_consume_token(0);
405     } catch (TypeException te) {
406                 String strmsg = te.getMessage();
407         Iterator it = linkMap.keySet().iterator();
408         while (it.hasNext())
409         {
410                 String search = (String)it.next();
411                 int index=-1;
412                 while ((index = strmsg.indexOf(search, index+1)) != -1)
413                 {
414                         strmsg = strmsg.substring(0, index)+(String)linkMap.get(search)+strmsg.substring(index+search.length());
415                 }
416         }
417                 {if (true) throw new TypeException(strmsg);}
418     } catch (TokenMgrError tme) {
419                 {if (true) throw new ParseException(tme.getMessage());}
420     }
421                         {if (true) return parentModule;}
422     throw new Error("Missing return statement in function");
423   }
424
425 /***************************************************************************************
426 [30] Module ::= VersionDecl? (MainModule | LibraryModule)
427 [36] VersionDecl ::= <"xquery" "version" StringLiteral> Separator
428 ***************************************************************************************/

429   final public void XQueryModule() throws ParseException, TypeException, XQueryException {
430         String version = null;
431     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
432     case XQUERY_VERSION:
433       currentToken = jj_consume_token(XQUERY_VERSION);
434       currentToken = jj_consume_token(StringLiteral);
435                         version = unquote(currentToken.image);
436                         // added LARS
437
token_source.switchState(DEFAULT);
438       currentToken = jj_consume_token(SEMI_COLON);
439       break;
440     default:
441       jj_la1[0] = jj_gen;
442       ;
443     }
444     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
445     case ELEMENT_L_PAREN:
446     case ATTRIBUTE_L_PAREN:
447     case COMMENT_L_PAREN:
448     case TEXT_L_PAREN:
449     case NODE_L_PAREN:
450     case DOCUMENT_NODE_L_PAREN:
451     case PROCESSING_INSTRUCTION_L_PAREN:
452     case STAR:
453     case DECLARE_VALIDATION:
454     case DECLARE_NAMESPACE:
455     case DECLARE_BASE_URI:
456     case DECLARE_VARIABLE_$:
457     case XMLCOMMENT_START:
458     case XMLPROCESSING_START:
459     case CDATA_START:
460     case TAG_START:
461     case DECLARE_XMLSPACE:
462     case VALIDATE_GLOBAL:
463     case VALIDATE_CONTEXT:
464     case VALIDATE_LAX:
465     case VALIDATE_STRICT:
466     case VALIDATE_SKIP:
467     case ELEMENT_QNAME_L_BRACE:
468     case ELEMENT_L_BRACE:
469     case ATTRIBUTE_L_BRACE:
470     case ATTRIBUTE_QNAME_L_BRACE:
471     case NAMESPACE_NCNAME_L_BRACE:
472     case DOCUMENT_L_BRACE:
473     case TEXT_L_BRACE:
474     case PROCESSING_INSTRUCTION_L_BRACE:
475     case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
476     case COMMENT_L_BRACE:
477     case DECLARE_FUNCTION:
478     case AROBASE:
479     case ANCESTOR_OR_SELF_DCOLON:
480     case ANCESTOR_DCOLON:
481     case ATTRIBUTE_DCOLON:
482     case CHILD_DCOLON:
483     case DESCENDANT_SELF_DCOLON:
484     case DESCENDANT_DCOLON:
485     case FOLLOWING_SIBLING_DCOLON:
486     case FOLLOWING_DCOLON:
487     case PARENT_DCOLON:
488     case PRECEDING_SIBLING_DCOLON:
489     case PRECEDING_DCOLON:
490     case SELF_DCOLON:
491     case IF_L_PAREN:
492     case QNAME_L_PAREN:
493     case DOLLAR:
494     case FOR_$:
495     case LET_$:
496     case SOME_$:
497     case EVERY_$:
498     case DECLARE_DEFAULT_COLLATION:
499     case DECLARE_DEFAULT_ELEMENT:
500     case DECLARE_DEFAULT_FUNCTION:
501     case IMPORT_SCHEMA:
502     case IMPORT_MODULE:
503     case VALIDATE_L_BRACE:
504     case TYPESWITCH_L_PAREN:
505     case L_PAREN:
506     case MINUS:
507     case PLUS:
508     case SLASH_SLASH:
509     case SLASH:
510     case DecimalLiteral:
511     case DOTDOT:
512     case DOT:
513     case DoubleLiteral:
514     case IntegerLiteral:
515     case NCNAME_STAR:
516     case STAR_NCNAME:
517     case StringLiteral:
518     case QNAME:
519     case KINDTEST_ELEMENT_L_PAREN:
520     case ELEMENT_CONTENT_ELT_LESS:
521     case ELEMENT_CONTENT_XMLCOMMENT_START:
522     case ELEMENT_CONTENT_XMLPROCESSING_START:
523     case ELEMENT_CONTENT_CDATA_START:
524       MainModule();
525       break;
526     case MODULE_NAMESPACE:
527       LibraryModule();
528       break;
529     default:
530       jj_la1[1] = jj_gen;
531       jj_consume_token(-1);
532       throw new ParseException();
533     }
534         if (version != null)
535                 parentModule.setVersion(version);
536   }
537
538 /***************************************************************************************
539 [31] MainModule ::= Prolog QueryBody
540 [39] QueryBody ::= Expr
541 [40] Expr ::= ExprSingle ("," ExprSingle)*
542 ***************************************************************************************/

543   final public void MainModule() throws ParseException, TypeException, XQueryException {
544         XQueryExpression expression = null;
545         ArrayList tmpVect = new ArrayList();
546     Prolog();
547     expression = ExprSingle();
548         if (expression != null)
549                 tmpVect.add(expression);
550     label_1:
551     while (true) {
552       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
553       case COMMA:
554         ;
555         break;
556       default:
557         jj_la1[2] = jj_gen;
558         break label_1;
559       }
560       currentToken = jj_consume_token(COMMA);
561       expression = ExprSingle();
562                 if (expression != null)
563                         tmpVect.add(expression);
564     }
565                 if (hashDeclVarList.isEmpty()) { hashDeclVarList = null; }
566                 if (hashDeclFuncList.isEmpty()) { hashDeclFuncList = null; }
567                 if (importSchemas.isEmpty()) { importSchemas = null; schemaList = null; }
568                 if (importModules.isEmpty()) { importModules = null; moduleList = null; }
569                 if (declList.isEmpty()) { declList = null; }
570
571                 parentModule.setExpressions(tmpVect);
572                 parentModule.setDefaultCollation(defaultCollation);
573                 if (hasDeclaredBaseURI) parentModule.setBaseURI(baseURI);
574                 parentModule.setDefaultFunctionNamespace(defaultFunctionNameSpace);
575                 parentModule.setDeclarations(namespaceContextStack);
576                 parentModule.setVariables(hashDeclVarList);
577                 parentModule.setExternalVariables(hashExtVar);
578                 parentModule.setFunctions(hashDeclFuncList);
579                 parentModule.setImportSchemas(importSchemas);
580                 parentModule.setImportModules(importModules);
581                 parentModule.setDeclList(declList);
582                 parentModule.setSchemaList(schemaList);
583                 parentModule.setModuleList(moduleList);
584                 if (xmlspace != Constants.NOTHING) parentModule.setXmlSpace(xmlspace);
585                 if (validation != Constants.NOTHING) parentModule.setValidation(validation);
586                 parentModule.setSchemaManager(staticcontext.getSchemaManager());
587   }
588
589 /***************************************************************************************
590 [32] LibraryModule ::= ModuleDecl Prolog
591 [33] ModuleDecl ::= <"module" "namespace"> NCName "=" StringLiteral Separator
592 ***************************************************************************************/

593   final public void LibraryModule() throws ParseException, TypeException, XQueryException {
594         String modulePrefix = null;
595         String moduleNamespace = null;
596     currentToken = jj_consume_token(MODULE_NAMESPACE);
597     currentToken = jj_consume_token(NAMESPACEDECL_NCNAME);
598                 modulePrefix = currentToken.image;
599                 libraryPrefix = modulePrefix;
600     currentToken = jj_consume_token(NAMESPACEDECL_EQUAL);
601     currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
602                 moduleNamespace = unquote(currentToken.image);
603                 namespaceContextStack.declarePrefix(modulePrefix,moduleNamespace);
604     currentToken = jj_consume_token(SEMI_COLON);
605     Prolog();
606                 if (hashDeclVarList.isEmpty()) { hashDeclVarList = null; }
607                 if (hashDeclFuncList.isEmpty()) { hashDeclFuncList = null; }
608                 if (importSchemas.isEmpty()) { importSchemas = null; schemaList = null; }
609                 if (importModules.isEmpty()) { importModules = null; moduleList = null; }
610                 if (declList.isEmpty()) { declList = null; }
611
612                 parentModule.setPrefix(modulePrefix);
613                 parentModule.setNamespace(moduleNamespace);
614                 parentModule.setDefaultCollation(defaultCollation);
615                 if (hasDeclaredBaseURI) parentModule.setBaseURI(baseURI);
616                 parentModule.setDefaultFunctionNamespace(defaultFunctionNameSpace);
617                 parentModule.setDeclarations(namespaceContextStack);
618                 parentModule.setVariables(hashDeclVarList);
619                 parentModule.setExternalVariables(hashExtVar);
620                 parentModule.setFunctions(hashDeclFuncList);
621                 parentModule.setImportSchemas(importSchemas);
622                 parentModule.setImportModules(importModules);
623                 parentModule.setDeclList(declList);
624                 parentModule.setSchemaList(schemaList);
625                 parentModule.setModuleList(moduleList);
626                 if (xmlspace != Constants.NOTHING) parentModule.setXmlSpace(xmlspace);
627                 if (validation != Constants.NOTHING) parentModule.setValidation(validation);
628                 parentModule.setSchemaManager(staticcontext.getSchemaManager());
629   }
630
631 /***************************************************************************************
632 [34] Prolog ::= (
633                             (
634                               NamespaceDecl
635                             | XMLSpaceDecl
636                             | DefaultNamespaceDecl
637                             | DefaultCollationDecl
638                             | BaseURIDecl
639                             | SchemaImport
640                             | ModuleImport
641                             | VarDecl
642                             | ValidationDecl
643                             | FunctionDecl
644                             )
645                             Separator
646                         )*
647 ***************************************************************************************/

648   final public void Prolog() throws ParseException, TypeException, XQueryException {
649     label_2:
650     while (true) {
651       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
652       case DECLARE_VALIDATION:
653       case DECLARE_NAMESPACE:
654       case DECLARE_BASE_URI:
655       case DECLARE_VARIABLE_$:
656       case DECLARE_XMLSPACE:
657       case DECLARE_FUNCTION:
658       case DECLARE_DEFAULT_COLLATION:
659       case DECLARE_DEFAULT_ELEMENT:
660       case DECLARE_DEFAULT_FUNCTION:
661       case IMPORT_SCHEMA:
662       case IMPORT_MODULE:
663         ;
664         break;
665       default:
666         jj_la1[3] = jj_gen;
667         break label_2;
668       }
669       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
670       case DECLARE_NAMESPACE:
671         NamespaceDecl();
672         break;
673       case DECLARE_XMLSPACE:
674         XMLSpaceDecl();
675         break;
676       case DECLARE_DEFAULT_ELEMENT:
677       case DECLARE_DEFAULT_FUNCTION:
678         DefaultNamespaceDecl();
679         break;
680       case DECLARE_DEFAULT_COLLATION:
681         DefaultCollationDecl();
682         break;
683       case DECLARE_BASE_URI:
684         BaseURIDecl();
685         break;
686       case IMPORT_SCHEMA:
687         SchemaImport();
688         break;
689       case IMPORT_MODULE:
690         ModuleImport();
691         break;
692       case DECLARE_VARIABLE_$:
693         VarDecl();
694         break;
695       case DECLARE_VALIDATION:
696         ValidationDecl();
697         break;
698       case DECLARE_FUNCTION:
699         FunctionDecl();
700         break;
701       default:
702         jj_la1[4] = jj_gen;
703         jj_consume_token(-1);
704         throw new ParseException();
705       }
706       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
707       case SEMI_COLON:
708         currentToken = jj_consume_token(SEMI_COLON);
709         break;
710       default:
711         jj_la1[5] = jj_gen;
712         ;
713       }
714     }
715   }
716
717 /***************************************************************************************
718 [118] NamespaceDecl ::= <"declare" "namespace"> NCName "=" StringLiteral
719 ***************************************************************************************/

720   final public void NamespaceDecl() throws ParseException, TypeException, XQueryException {
721         String prefix = null;
722         String uri = null;
723     currentToken = jj_consume_token(DECLARE_NAMESPACE);
724     currentToken = jj_consume_token(NAMESPACEDECL_NCNAME);
725                         prefix = currentToken.image;
726     currentToken = jj_consume_token(NAMESPACEDECL_EQUAL);
727     currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
728                         uri = unquote(currentToken.image);
729                 namespaceContextStack.declarePrefix(prefix, uri);
730   }
731
732 /***************************************************************************************
733 [115] XMLSpaceDecl ::= <"declare" "xmlspace"> ("preserve" | "strip")
734 ***************************************************************************************/

735   final public void XMLSpaceDecl() throws ParseException, TypeException, XQueryException {
736     currentToken = jj_consume_token(DECLARE_XMLSPACE);
737     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
738     case XMLSPACE_DECL_PRESERVE:
739       currentToken = jj_consume_token(XMLSPACE_DECL_PRESERVE);
740                                 xmlspace = Constants.XMLSPACE_PRESERVE;
741       break;
742     case XMLSPACE_DECL_STRIP:
743       currentToken = jj_consume_token(XMLSPACE_DECL_STRIP);
744                                 xmlspace = Constants.XMLSPACE_STRIP;
745       break;
746     default:
747       jj_la1[6] = jj_gen;
748       jj_consume_token(-1);
749       throw new ParseException();
750     }
751   }
752
753 /***************************************************************************************
754 [119] DefaultNamespaceDecl ::= (<"declare" "default" "element"> | <"declare" "default" "function">) "namespace" StringLiteral
755 ***************************************************************************************/

756   final public void DefaultNamespaceDecl() throws ParseException, TypeException, XQueryException {
757         String uri = null;
758         boolean forFunction = false;
759     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
760     case DECLARE_DEFAULT_ELEMENT:
761       currentToken = jj_consume_token(DECLARE_DEFAULT_ELEMENT);
762       break;
763     case DECLARE_DEFAULT_FUNCTION:
764       currentToken = jj_consume_token(DECLARE_DEFAULT_FUNCTION);
765                                 forFunction = true;
766       break;
767     default:
768       jj_la1[7] = jj_gen;
769       jj_consume_token(-1);
770       throw new ParseException();
771     }
772     currentToken = jj_consume_token(NAMESPACEKEYWORD_NAMESPACE);
773     currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
774                         uri = unquote(currentToken.image);
775                 if (forFunction) {
776                         if (defaultFunctionNameSpace != null)
777                         {
778                                 {if (true) throw new TypeException("Default function namespace defined more than once", currentToken.beginLine, currentToken.beginColumn);}
779                         }
780                         defaultFunctionNameSpace = uri;
781                 } else {
782                         if (defaultElementNameSpace != null) {
783                                 {if (true) throw new TypeException("Default element namespace defined more than once", currentToken.beginLine, currentToken.beginColumn);}
784                         }
785                         defaultElementNameSpace = uri;
786                         namespaceContextStack.declarePrefix("", uri);
787                 }
788   }
789
790 /***************************************************************************************
791 [116] DefaultCollationDecl ::= <"declare" "default" "collation"> StringLiteral
792 ***************************************************************************************/

793   final public void DefaultCollationDecl() throws ParseException, TypeException, XQueryException {
794     currentToken = jj_consume_token(DECLARE_DEFAULT_COLLATION);
795     currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
796                         defaultCollation = unquote(currentToken.image);
797   }
798
799 /***************************************************************************************
800 [117] BaseURIDecl ::= <"declare" "base-uri"> StringLiteral
801 ***************************************************************************************/

802   final public void BaseURIDecl() throws ParseException, TypeException, XQueryException {
803     currentToken = jj_consume_token(DECLARE_BASE_URI);
804     currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
805                         baseURI = unquote(currentToken.image);
806                         hasDeclaredBaseURI = true;
807   }
808
809 /***************************************************************************************
810 [146] SchemaImport ::= <"import" "schema"> SchemaPrefix? StringLiteral <"at" StringLiteral>?
811 [147] SchemaPrefix ::= ("namespace" NCName "=") | (<"default" "element"> "namespace")
812 ***************************************************************************************/

813   final public void SchemaImport() throws ParseException, TypeException, XQueryException {
814         boolean hasPrefix = false;
815         String prefix = null;
816         String name = null;
817         String location = null;
818     currentToken = jj_consume_token(IMPORT_SCHEMA);
819     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
820     case NAMESPACEKEYWORD_NAMESPACE:
821     case NAMESPACEKEYWORD_DEFAULT_ELEMENT:
822       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
823       case NAMESPACEKEYWORD_NAMESPACE:
824         currentToken = jj_consume_token(NAMESPACEKEYWORD_NAMESPACE);
825         currentToken = jj_consume_token(NAMESPACEDECL_NCNAME);
826                                         prefix = currentToken.image;
827                                         hasPrefix = true;
828         currentToken = jj_consume_token(NAMESPACEDECL_EQUAL);
829         break;
830       case NAMESPACEKEYWORD_DEFAULT_ELEMENT:
831         currentToken = jj_consume_token(NAMESPACEKEYWORD_DEFAULT_ELEMENT);
832                                         prefix = null;
833                                         hasPrefix = true;
834         currentToken = jj_consume_token(NAMESPACEKEYWORD_NAMESPACE);
835         break;
836       default:
837         jj_la1[8] = jj_gen;
838         jj_consume_token(-1);
839         throw new ParseException();
840       }
841       break;
842     default:
843       jj_la1[9] = jj_gen;
844       ;
845     }
846     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
847     case NAMESPACEDECL_StringLiteral:
848       currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
849                                 name = unquote(currentToken.image);
850       break;
851     case NAMESPACEKEYWORD_StringLiteral:
852       currentToken = jj_consume_token(NAMESPACEKEYWORD_StringLiteral);
853                                 name = unquote(currentToken.image);
854       break;
855     default:
856       jj_la1[10] = jj_gen;
857       jj_consume_token(-1);
858       throw new ParseException();
859     }
860     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
861     case AT:
862       currentToken = jj_consume_token(AT);
863       currentToken = jj_consume_token(NAMESPACEKEYWORD_StringLiteral);
864                         location = unquote(currentToken.image);
865       break;
866     default:
867       jj_la1[11] = jj_gen;
868       ;
869     }
870                 try {
871                         if (staticcontext.getTypeVisitor() != null)
872                         {
873                                 if (baseURI != null && location != null)
874                                         location = (new URL(new URL(baseURI),location)).toString();
875                                 if (name.length() == 0)
876                                         name = null;
877                                 staticcontext.getTypeVisitor().getSchemaManager().addSchemaLocation(name, location);
878                                 staticcontext.getTypeVisitor().getSchemaManager().loadSchema(staticcontext.getTypeVisitor().getSchemaLocator(), name);
879                                 if (staticcontext.getTypeVisitor().getSchemaManager().getSchema(name) == null) {
880                                         {if (true) throw new ParseException("Could not load schema at location : " + location);}
881                                 }
882                         }
883                 } catch (MalformedURLException mue) {
884                         {if (true) throw new ParseException(mue.getMessage());}
885                 } catch (SAXException saxe) {
886                         {if (true) throw new ParseException(saxe.getMessage());}
887                 }
888                 if (hasPrefix) {
889                         if (prefix != null) {
890                                 namespaceContextStack.declarePrefix(prefix, name);
891                         } else {
892                                 if (defaultElementNameSpace != null) {
893                                         {if (true) throw new TypeException("Default element namespace defined more than once", currentToken.beginLine, currentToken.beginColumn);}
894                                 }
895                                 defaultElementNameSpace = name;
896                                 namespaceContextStack.declarePrefix("", name);
897                         }
898                 }
899                 importSchemas.put(name,factory.createImportSchema(hasPrefix,prefix,name,location));
900                 schemaList.add(name);
901   }
902
903 /***************************************************************************************
904 [37] ModuleImport ::= <"import" "module"> ("namespace" NCName "=")? StringLiteral <"at" StringLiteral>?
905 ***************************************************************************************/

906   final public void ModuleImport() throws ParseException, TypeException, XQueryException {
907         String prefix = null;
908         String name = null;
909         String location = null;
910     currentToken = jj_consume_token(IMPORT_MODULE);
911     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
912     case NAMESPACEKEYWORD_NAMESPACE:
913       currentToken = jj_consume_token(NAMESPACEKEYWORD_NAMESPACE);
914       currentToken = jj_consume_token(NAMESPACEDECL_NCNAME);
915                                 prefix = currentToken.image;
916       currentToken = jj_consume_token(NAMESPACEDECL_EQUAL);
917       break;
918     default:
919       jj_la1[12] = jj_gen;
920       ;
921     }
922     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
923     case NAMESPACEDECL_StringLiteral:
924       currentToken = jj_consume_token(NAMESPACEDECL_StringLiteral);
925                                 name = unquote(currentToken.image);
926       break;
927     case NAMESPACEKEYWORD_StringLiteral:
928       currentToken = jj_consume_token(NAMESPACEKEYWORD_StringLiteral);
929                                 name = unquote(currentToken.image);
930       break;
931     default:
932       jj_la1[13] = jj_gen;
933       jj_consume_token(-1);
934       throw new ParseException();
935     }
936     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
937     case AT:
938       currentToken = jj_consume_token(AT);
939       currentToken = jj_consume_token(NAMESPACEKEYWORD_StringLiteral);
940                         location = unquote(currentToken.image);
941       break;
942     default:
943       jj_la1[14] = jj_gen;
944       ;
945     }
946                 XQueryModule mod = null;
947                 if (staticcontext.getTypeVisitor() != null)
948                 {
949                         try {
950                                 if (baseURI != null && location != null)
951                                         location = (new URL(new URL(baseURI),location)).toString();
952                                 if (name.length() == 0)
953                                         name = null;
954                                 staticcontext.getModuleManager().addModuleLocation(name, location);
955                                 mod = staticcontext.getModuleManager().loadModule(name,initialSchemamanager,staticcontext.getTypeVisitor(),staticcontext.getVarCounter());
956                                 // add schemas from imported module to module ???
957
if (mod.getVariables() != null) {
958                         hashDeclVarList.putAll(mod.getVariables());
959                 }
960                 if (mod.getFunctions() != null) {
961                         hashDeclFuncList.putAll(mod.getFunctions());
962                 }
963                 declList.addAll(mod.getDeclList());
964                         } catch (MalformedURLException mue) {
965                                 {if (true) throw new ParseException(mue.getMessage());}
966                         }
967                 }
968                 if (prefix != null)
969                         namespaceContextStack.declarePrefix(prefix, name);
970                 importModules.put(name,factory.createImportModule(prefix,name,location,mod));
971                 moduleList.add(name);
972   }
973
974 /***************************************************************************************
975 [38] VarDecl ::= <"declare" "variable" "$"> VarName TypeDeclaration? (( ":=" "{" Expr "}") | "external")
976 ***************************************************************************************/

977   final public void VarDecl() throws ParseException, TypeException, XQueryException {
978         XQueryExpression expression = null;
979         Variable var = null;
980         SequenceType sequenceType = null;
981         boolean isExternal = false;
982     currentToken = jj_consume_token(DECLARE_VARIABLE_$);
983     currentToken = jj_consume_token(VARNAME_QNAME);
984                         var = (Variable)VarName(currentToken.image,true,libraryPrefix,false);
985                         var.setBindingType(Constants.DECLARATION_BINDINGTYPE);
986     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
987     case OPERATOR_AS:
988       sequenceType = TypeDeclaration();
989                                 var.setTypeDeclaration(sequenceType);
990       break;
991     default:
992       jj_la1[15] = jj_gen;
993       ;
994     }
995     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
996     case OPERATOR_COLON_EQUAL:
997       currentToken = jj_consume_token(OPERATOR_COLON_EQUAL);
998       expression = EnclosedExpr(true);
999                                 var.setExpression(expression, true);
1000      break;
1001    case OPERATOR_EXTERNAL:
1002      currentToken = jj_consume_token(OPERATOR_EXTERNAL);
1003                                isExternal = true;
1004      break;
1005    default:
1006      jj_la1[16] = jj_gen;
1007      jj_consume_token(-1);
1008      throw new ParseException();
1009    }
1010                HashMap map = (HashMap)hashDeclVarList.get(var.getVarName().getNameSpace());
1011                if (map == null) {
1012                        map = new HashMap();
1013                        hashDeclVarList.put(var.getVarName().getNameSpace(),map);
1014                } else {
1015                        if (map.get(var.getStringValue()) != null)
1016                                {if (true) throw new ParseException("Variable " + var.getVarName().getName() + " defined more than once.");}
1017                }
1018                map.put(var.getVarName().getLocalName(),var);
1019                declList.add(var.getVarName());
1020                if (isExternal) {
1021                        try {
1022                                ExternalVariable extVar = factory.createExternalVariable(var,parentModule);
1023                                hashExtVar.put(var,extVar);
1024                        }
1025                        catch (TypeException te) {
1026                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1027                        }
1028                }
1029  }
1030
1031/***************************************************************************************
1032[145] ValidationDecl ::= <"declare" "validation"> SchemaMode
1033***************************************************************************************/

1034  final public void ValidationDecl() throws ParseException, TypeException, XQueryException {
1035        int mode = Constants.NOTHING;
1036    currentToken = jj_consume_token(DECLARE_VALIDATION);
1037    mode = SchemaMode();
1038                validation = mode;
1039  }
1040
1041/***************************************************************************************
1042[12] SchemaMode ::= "lax" | "strict" | "skip"
1043***************************************************************************************/

1044  final public int SchemaMode() throws ParseException, TypeException, XQueryException {
1045    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1046    case OPERATOR_LAX:
1047      currentToken = jj_consume_token(OPERATOR_LAX);
1048                {if (true) return Constants.VALIDATION_LAX;}
1049      break;
1050    case OPERATOR_STRICT:
1051      currentToken = jj_consume_token(OPERATOR_STRICT);
1052                {if (true) return Constants.VALIDATION_STRICT;}
1053      break;
1054    case OPERATOR_SKIP:
1055      currentToken = jj_consume_token(OPERATOR_SKIP);
1056                {if (true) return Constants.VALIDATION_SKIP;}
1057      break;
1058    case OPERATOR_PRESERVE:
1059      currentToken = jj_consume_token(OPERATOR_PRESERVE);
1060                {if (true) return Constants.VALIDATION_PRESERVE;}
1061      break;
1062    default:
1063      jj_la1[17] = jj_gen;
1064      jj_consume_token(-1);
1065      throw new ParseException();
1066    }
1067    throw new Error("Missing return statement in function");
1068  }
1069
1070/***************************************************************************************
1071[120] FunctionDecl ::= <"declare" "function"> <QName "("> ParamList? (")" | (<")" "as"> SequenceType)) (EnclosedExpr | "external")
1072***************************************************************************************/

1073  final public void FunctionDecl() throws ParseException, TypeException, XQueryException {
1074        QName funcName = null;
1075        ArrayList paramList = null;
1076        SequenceType sequenceType = null;
1077        XQueryExpression enclosedExpr = null;
1078        FunctionDeclaration functionDeclaration = null;
1079        HashMap map = null;
1080    currentToken = jj_consume_token(DECLARE_FUNCTION);
1081    currentToken = jj_consume_token(QNAME_L_PAREN);
1082                        String str = extractName(currentToken.image,null,"(");
1083                        funcName = QName(str,true,libraryPrefix,true);
1084                        // test funcName has prefix
1085
if (funcName.getPrefixName() == null)
1086                                {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Function " + funcName.toString() + " should have a prefix.");}
1087                        // verify that prefix is not predefined prefix
1088
if (funcName.getPrefixName().equals(XML) ||
1089                                funcName.getPrefixName().equals(XS) ||
1090                                funcName.getPrefixName().equals(FN) ||
1091                                funcName.getPrefixName().equals(XDT) ||
1092                                funcName.getPrefixName().equals(XSI))
1093                                {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Function " + funcName.toString() + " has incorrect predefined prefix.");}
1094                        map = (HashMap)hashDeclFuncList.get(funcName.getNameSpace());
1095                        if (map != null) {
1096                                functionDeclaration = (FunctionDeclaration)map.get(funcName.getLocalName());
1097                                if (functionDeclaration != null)
1098                                        {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Function " + funcName.toString() + " already defined.");}
1099                        }
1100    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1101    case DOLLAR:
1102      paramList = ParamList();
1103      break;
1104    default:
1105      jj_la1[18] = jj_gen;
1106      ;
1107    }
1108    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1109    case R_PAREN:
1110      currentToken = jj_consume_token(R_PAREN);
1111      break;
1112    case R_PAREN_AS:
1113      currentToken = jj_consume_token(R_PAREN_AS);
1114      sequenceType = SequenceType();
1115      break;
1116    default:
1117      jj_la1[19] = jj_gen;
1118      jj_consume_token(-1);
1119      throw new ParseException();
1120    }
1121    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1122    case L_BRACE:
1123    case ELEMENT_CONTENT_L_BRACE:
1124      enclosedExpr = EnclosedExpr(true);
1125      break;
1126    case OPERATOR_EXTERNAL:
1127      currentToken = jj_consume_token(OPERATOR_EXTERNAL);
1128                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". External Function Declaration is not supported yet.");}
1129      break;
1130    default:
1131      jj_la1[20] = jj_gen;
1132      jj_consume_token(-1);
1133      throw new ParseException();
1134    }
1135                try
1136                {
1137                        functionDeclaration = factory.createFunctionDeclaration(funcName, paramList, sequenceType, (enclosedExpr==null)?null:((XQueryExpressionSequence)enclosedExpr).getSubExpressions(), parentModule);
1138                        map = (HashMap)hashDeclFuncList.get(functionDeclaration.getFuncName().getNameSpace());
1139                        if (map == null) {
1140                                map = new HashMap();
1141                                hashDeclFuncList.put(functionDeclaration.getFuncName().getNameSpace(),map);
1142                        } else {
1143                                if (map.get(functionDeclaration.getFuncName().getLocalName()) != null)
1144                                        {if (true) throw new ParseException("Function " + functionDeclaration.getFuncName().getLocalName() + " defined more than once.");}
1145                        }
1146                        map.put(functionDeclaration.getFuncName().getLocalName(),functionDeclaration);
1147                        declList.add(functionDeclaration.getFuncName());
1148                        ArrayList params = functionDeclaration.getParameters();
1149                        if (params != null)
1150                                for (int i=0;i<params.size();i++) {
1151                                        removeVarDefinition(((Variable)params.get(i)).getStringValue());
1152                                }
1153                }
1154                catch (TypeException te)
1155                {
1156                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1157                }
1158  }
1159
1160/***************************************************************************************
1161[121] ParamList ::= Param ("," Param)*
1162***************************************************************************************/

1163  final public ArrayList ParamList() throws ParseException, TypeException, XQueryException {
1164        ArrayList params = new ArrayList();
1165        XQueryExpression expression = null;
1166    currentToken = jj_consume_token(DOLLAR);
1167    expression = Param();
1168                        params.add(expression);
1169    label_3:
1170    while (true) {
1171      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1172      case COMMA:
1173        ;
1174        break;
1175      default:
1176        jj_la1[21] = jj_gen;
1177        break label_3;
1178      }
1179      currentToken = jj_consume_token(COMMA);
1180      currentToken = jj_consume_token(DOLLAR);
1181      expression = Param();
1182                                params.add(expression);
1183    }
1184                {if (true) return params;}
1185    throw new Error("Missing return statement in function");
1186  }
1187
1188/***************************************************************************************
1189[122] Param ::= "$" VarName TypeDeclaration?
1190***************************************************************************************/

1191  final public Variable Param() throws ParseException, TypeException, XQueryException {
1192        Variable var = null;
1193        SequenceType sequenceType = null;
1194    currentToken = jj_consume_token(VARNAME_QNAME);
1195                        var = (Variable)VarName(currentToken.image);
1196                        //addVarDefinition(var);
1197

1198    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1199    case OPERATOR_AS:
1200      sequenceType = TypeDeclaration();
1201                                var.setTypeDeclaration(sequenceType);
1202      break;
1203    default:
1204      jj_la1[22] = jj_gen;
1205      ;
1206    }
1207                var.setBindingType(Constants.PARAMETER_BINDINGTYPE);
1208                var.accept(staticcontext.getTypeVisitor());
1209                {if (true) return var;}
1210    throw new Error("Missing return statement in function");
1211  }
1212
1213/***************************************************************************************
1214[123] TypeDeclaration ::= "as" SequenceType
1215***************************************************************************************/

1216  final public SequenceType TypeDeclaration() throws ParseException, TypeException, XQueryException {
1217        SequenceType sequenceType = null;
1218    currentToken = jj_consume_token(OPERATOR_AS);
1219    sequenceType = SequenceType();
1220                {if (true) return sequenceType;}
1221    throw new Error("Missing return statement in function");
1222  }
1223
1224/***************************************************************************************
1225[125] SequenceType ::= (ItemType OccurrenceIndicator?) | ("empty" "(" ")")
1226[144] OccurrenceIndicator ::= "?" | "*" | "+"
1227[127] ItemType ::= AtomicType | KindTest | ("item" "(" ")")
1228[126] AtomicType ::= QName
1229***************************************************************************************/

1230  final public SequenceType SequenceType() throws ParseException, TypeException, XQueryException {
1231        ItemType itemType = null;
1232        QName atomicType = null;
1233        int occurrenceIndicator = Constants.NOTHING;
1234        XQueryExpression nodeType = null;
1235    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1236    case ELEMENT_L_PAREN:
1237    case ATTRIBUTE_L_PAREN:
1238    case COMMENT_L_PAREN:
1239    case TEXT_L_PAREN:
1240    case NODE_L_PAREN:
1241    case DOCUMENT_NODE_L_PAREN:
1242    case PROCESSING_INSTRUCTION_L_PAREN:
1243    case ITEMTYPE_QNAME:
1244    case ITEMTYPE_ITEM_L_PAREN_R_PAREN:
1245    case KINDTEST_ELEMENT_L_PAREN:
1246      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1247      case ITEMTYPE_QNAME:
1248        currentToken = jj_consume_token(ITEMTYPE_QNAME);
1249                                        QName qname = QName(currentToken.image);
1250                                        try
1251                                        {
1252                                                itemType = factory.createItemType((XQueryExpression)qname,parentModule);
1253                                        }
1254                                        catch (TypeException te)
1255                                        {
1256                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1257                                        }
1258        break;
1259      case ELEMENT_L_PAREN:
1260      case ATTRIBUTE_L_PAREN:
1261      case COMMENT_L_PAREN:
1262      case TEXT_L_PAREN:
1263      case NODE_L_PAREN:
1264      case DOCUMENT_NODE_L_PAREN:
1265      case PROCESSING_INSTRUCTION_L_PAREN:
1266      case KINDTEST_ELEMENT_L_PAREN:
1267        nodeType = KindTest();
1268                                        try
1269                                        {
1270                                                itemType = factory.createItemType((XQueryExpression)nodeType,parentModule);
1271                                        }
1272                                        catch (TypeException te)
1273                                        {
1274                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1275                                        }
1276        break;
1277      case ITEMTYPE_ITEM_L_PAREN_R_PAREN:
1278        currentToken = jj_consume_token(ITEMTYPE_ITEM_L_PAREN_R_PAREN);
1279                                        try
1280                                        {
1281                                                itemType = factory.createItemType((XQueryExpression)null,parentModule);
1282                                        }
1283                                        catch (TypeException te)
1284                                        {
1285                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1286                                        }
1287        break;
1288      default:
1289        jj_la1[23] = jj_gen;
1290        jj_consume_token(-1);
1291        throw new ParseException();
1292      }
1293
1294      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1295      case OPERATOR_STAR:
1296      case OPERATOR_QUESTION_MARK:
1297      case PLUS:
1298        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1299        case OPERATOR_STAR:
1300          currentToken = jj_consume_token(OPERATOR_STAR);
1301                                        occurrenceIndicator = Constants.OCCURRENCE_STAR;
1302                                        token_source.SwitchTo(OPERATOR);
1303          break;
1304        case PLUS:
1305          currentToken = jj_consume_token(PLUS);
1306                                        occurrenceIndicator = Constants.OCCURRENCE_PLUS;
1307                                        token_source.SwitchTo(OPERATOR);
1308          break;
1309        case OPERATOR_QUESTION_MARK:
1310          currentToken = jj_consume_token(OPERATOR_QUESTION_MARK);
1311                                        occurrenceIndicator = Constants.OCCURRENCE_QUESTION_MARK;
1312                                        token_source.SwitchTo(OPERATOR);
1313          break;
1314        default:
1315          jj_la1[24] = jj_gen;
1316          jj_consume_token(-1);
1317          throw new ParseException();
1318        }
1319        break;
1320      default:
1321        jj_la1[25] = jj_gen;
1322        ;
1323      }
1324      break;
1325    case ITEMTYPE_EMPTY_L_PAREN_R_PAREN:
1326      currentToken = jj_consume_token(ITEMTYPE_EMPTY_L_PAREN_R_PAREN);
1327      break;
1328    default:
1329      jj_la1[26] = jj_gen;
1330      jj_consume_token(-1);
1331      throw new ParseException();
1332    }
1333                try
1334                {
1335                        {if (true) return factory.createSequenceType(itemType, occurrenceIndicator, parentModule);}
1336                }
1337                catch (TypeException te)
1338                {
1339                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1340                }
1341    throw new Error("Missing return statement in function");
1342  }
1343
1344/***************************************************************************************
1345[128] KindTest ::= DocumentTest | ElementTest | AttributeTest | PITest | CommentTest | TextTest | AnyKindTest
1346[137] PITest ::= <"processing-instruction" "("> (NCName | StringLiteral)? ")"
1347[138] DocumentTest ::= <"document-node" "("> ElementTest? ")"
1348[139] CommentTest ::= <"comment" "("> ")"
1349[140] TextTest ::= <"text" "("> ")"
1350[141] AnyKindTest ::= <"node" "("> ")"
1351***************************************************************************************/

1352  final public XQueryExpression KindTest() throws ParseException, TypeException, XQueryException {
1353        XQueryExpression nodeType = null;
1354        String value = null;
1355        byte nodeKind = Constants.NOTHING;
1356    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1357    case DOCUMENT_NODE_L_PAREN:
1358      currentToken = jj_consume_token(DOCUMENT_NODE_L_PAREN);
1359                                nodeKind = NodeKind.DOCUMENT;
1360      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1361      case ELEMENT_L_PAREN:
1362      case KINDTEST_ELEMENT_L_PAREN:
1363        nodeType = ElementTest();
1364        break;
1365      default:
1366        jj_la1[27] = jj_gen;
1367        ;
1368      }
1369      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1370      break;
1371    case ELEMENT_L_PAREN:
1372    case KINDTEST_ELEMENT_L_PAREN:
1373      nodeType = ElementTest();
1374      break;
1375    case ATTRIBUTE_L_PAREN:
1376      nodeType = AttributeTest();
1377      break;
1378    case PROCESSING_INSTRUCTION_L_PAREN:
1379      currentToken = jj_consume_token(PROCESSING_INSTRUCTION_L_PAREN);
1380                                nodeKind = NodeKind.PI;
1381      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1382      case KINDTESTFORPI_NCNAME:
1383      case KINDTESTFORPI_StringLiteral:
1384        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1385        case KINDTESTFORPI_NCNAME:
1386          currentToken = jj_consume_token(KINDTESTFORPI_NCNAME);
1387                                        value = unquote(currentToken.image);
1388          break;
1389        case KINDTESTFORPI_StringLiteral:
1390          currentToken = jj_consume_token(KINDTESTFORPI_StringLiteral);
1391                                        value = currentToken.image;
1392          break;
1393        default:
1394          jj_la1[28] = jj_gen;
1395          jj_consume_token(-1);
1396          throw new ParseException();
1397        }
1398        break;
1399      default:
1400        jj_la1[29] = jj_gen;
1401        ;
1402      }
1403      currentToken = jj_consume_token(KINDTESTFORPI_R_PAREN);
1404      break;
1405    case COMMENT_L_PAREN:
1406      currentToken = jj_consume_token(COMMENT_L_PAREN);
1407                                nodeKind = NodeKind.COMMENT;
1408      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1409      break;
1410    case TEXT_L_PAREN:
1411      currentToken = jj_consume_token(TEXT_L_PAREN);
1412                                nodeKind = NodeKind.TEXT;
1413      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1414      break;
1415    case NODE_L_PAREN:
1416      currentToken = jj_consume_token(NODE_L_PAREN);
1417                                nodeKind = NodeKind.NODE;
1418      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1419      break;
1420    default:
1421      jj_la1[30] = jj_gen;
1422      jj_consume_token(-1);
1423      throw new ParseException();
1424    }
1425                if (nodeType != null)
1426                        {if (true) return nodeType;}
1427                try
1428                {
1429                        {if (true) return factory.createNodeTest(nodeKind, (value == null)?null:factory.createValueString(value, parentModule), parentModule);}
1430                }
1431                catch (TypeException te)
1432                {
1433                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1434                }
1435    throw new Error("Missing return statement in function");
1436  }
1437
1438/***************************************************************************************
1439[129] ElementTest ::= "element" "(" ((SchemaContextPath ElementName)| (ElementNameOrWildcard ("," TypeNameOrWildcard "nillable"?)?))? ")"
1440[131] ElementName ::= QName
1441[133] TypeName ::= QName
1442[134] ElementNameOrWildcard ::= ElementName | "*"
1443[136] TypeNameOrWildcard ::= TypeName | "*"
1444***************************************************************************************/

1445  final public XQueryExpression ElementTest() throws ParseException, TypeException, XQueryException {
1446        SchemaContextPath schemaContextPath = null;
1447        boolean nillable = false;
1448        QName elementQName = null;
1449        QName typeQName = null;
1450    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1451    case ELEMENT_L_PAREN:
1452      currentToken = jj_consume_token(ELEMENT_L_PAREN);
1453      break;
1454    case KINDTEST_ELEMENT_L_PAREN:
1455      currentToken = jj_consume_token(KINDTEST_ELEMENT_L_PAREN);
1456      break;
1457    default:
1458      jj_la1[31] = jj_gen;
1459      jj_consume_token(-1);
1460      throw new ParseException();
1461    }
1462    if (jj_2_1(4)) {
1463      schemaContextPath = SchemaContextPath(false);
1464    } else {
1465      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1466      case KINDTEST_STAR:
1467      case KINDTEST_QNAME:
1468        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1469        case KINDTEST_QNAME:
1470          currentToken = jj_consume_token(KINDTEST_QNAME);
1471          break;
1472        case KINDTEST_STAR:
1473          currentToken = jj_consume_token(KINDTEST_STAR);
1474          break;
1475        default:
1476          jj_la1[32] = jj_gen;
1477          jj_consume_token(-1);
1478          throw new ParseException();
1479        }
1480                        elementQName = QName(currentToken.image);
1481        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1482        case CLOSEKINDTEST_COMMA:
1483          currentToken = jj_consume_token(CLOSEKINDTEST_COMMA);
1484          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1485          case KINDTEST_QNAME:
1486            currentToken = jj_consume_token(KINDTEST_QNAME);
1487            break;
1488          case KINDTEST_STAR:
1489            currentToken = jj_consume_token(KINDTEST_STAR);
1490            break;
1491          default:
1492            jj_la1[33] = jj_gen;
1493            jj_consume_token(-1);
1494            throw new ParseException();
1495          }
1496                                typeQName = QName(currentToken.image);
1497          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1498          case CLOSEKINDTEST_NILLABLE:
1499            currentToken = jj_consume_token(CLOSEKINDTEST_NILLABLE);
1500                                        nillable = true;
1501            break;
1502          default:
1503            jj_la1[34] = jj_gen;
1504            ;
1505          }
1506          break;
1507        default:
1508          jj_la1[35] = jj_gen;
1509          ;
1510        }
1511        break;
1512      default:
1513        jj_la1[36] = jj_gen;
1514        ;
1515      }
1516    }
1517    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1518    case KINDTEST_R_PAREN:
1519      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1520      break;
1521    case CLOSEKINDTEST_R_PAREN:
1522      currentToken = jj_consume_token(CLOSEKINDTEST_R_PAREN);
1523      break;
1524    default:
1525      jj_la1[37] = jj_gen;
1526      jj_consume_token(-1);
1527      throw new ParseException();
1528    }
1529                try
1530                {
1531                        {if (true) return factory.createElementTest(schemaContextPath, elementQName, typeQName, nillable, parentModule);}
1532                }
1533                catch (TypeException te)
1534                {
1535                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1536                }
1537    throw new Error("Missing return statement in function");
1538  }
1539
1540/***************************************************************************************
1541[130] AttributeTest ::= "attribute" "(" ((SchemaContextPath AttributeName)| (AttribNameOrWildcard ("," TypeNameOrWildcard)?))? ")"
1542[132] AttributeName ::= QName
1543[133] TypeName ::= QName
1544[135] AttribNameOrWildcard ::= AttributeName | "*"
1545[136] TypeNameOrWildcard ::= TypeName | "*"
1546***************************************************************************************/

1547  final public XQueryExpression AttributeTest() throws ParseException, TypeException, XQueryException {
1548        SchemaContextPath schemaContextPath = null;
1549        QName elementQName = null;
1550        QName typeQName = null;
1551    currentToken = jj_consume_token(ATTRIBUTE_L_PAREN);
1552    if (jj_2_2(4)) {
1553      schemaContextPath = SchemaContextPath(false);
1554    } else {
1555      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1556      case KINDTEST_STAR:
1557      case KINDTEST_QNAME:
1558        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1559        case KINDTEST_QNAME:
1560          currentToken = jj_consume_token(KINDTEST_QNAME);
1561          break;
1562        case KINDTEST_STAR:
1563          currentToken = jj_consume_token(KINDTEST_STAR);
1564          break;
1565        default:
1566          jj_la1[38] = jj_gen;
1567          jj_consume_token(-1);
1568          throw new ParseException();
1569        }
1570                        elementQName = QName(currentToken.image);
1571        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1572        case CLOSEKINDTEST_COMMA:
1573          currentToken = jj_consume_token(CLOSEKINDTEST_COMMA);
1574          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1575          case KINDTEST_QNAME:
1576            currentToken = jj_consume_token(KINDTEST_QNAME);
1577            break;
1578          case KINDTEST_STAR:
1579            currentToken = jj_consume_token(KINDTEST_STAR);
1580            break;
1581          default:
1582            jj_la1[39] = jj_gen;
1583            jj_consume_token(-1);
1584            throw new ParseException();
1585          }
1586                                typeQName = QName(currentToken.image);
1587          break;
1588        default:
1589          jj_la1[40] = jj_gen;
1590          ;
1591        }
1592        break;
1593      default:
1594        jj_la1[41] = jj_gen;
1595        ;
1596      }
1597    }
1598    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1599    case KINDTEST_R_PAREN:
1600      currentToken = jj_consume_token(KINDTEST_R_PAREN);
1601      break;
1602    case CLOSEKINDTEST_R_PAREN:
1603      currentToken = jj_consume_token(CLOSEKINDTEST_R_PAREN);
1604      break;
1605    default:
1606      jj_la1[42] = jj_gen;
1607      jj_consume_token(-1);
1608      throw new ParseException();
1609    }
1610                try
1611                {
1612                        {if (true) return factory.createAttributeTest(schemaContextPath, elementQName, typeQName, parentModule);}
1613                }
1614                catch (TypeException te)
1615                {
1616                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1617                }
1618    throw new Error("Missing return statement in function");
1619  }
1620
1621/***************************************************************************************
1622[142] SchemaContextPath ::= SchemaGlobalContext "/" (SchemaContextStep "/")*
1623[15] SchemaContextStep ::= QName
1624[14] SchemaGlobalContext ::= QName | SchemaGlobalTypeName
1625[13] SchemaGlobalTypeName ::= "type" "(" QName ")"
1626// changed LARS
1627[142] SchemaContextPath ::= SchemaGlobalContext "/" (SchemaContextStep "/")* QName (in fact ElementName or AttributeName)
1628***************************************************************************************/

1629  final public SchemaContextPath SchemaContextPath(boolean attribute) throws ParseException, TypeException, XQueryException {
1630        XQueryExpression expression = null;
1631        ArrayList steps = new ArrayList();
1632        byte axis = Constants.NOAXIS;
1633    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1634    case KINDTEST_QNAME:
1635      currentToken = jj_consume_token(KINDTEST_QNAME);
1636                                expression = QName(currentToken.image);
1637      break;
1638    case KINDTEST_TYPE_L_PAREN:
1639      currentToken = jj_consume_token(KINDTEST_TYPE_L_PAREN);
1640      currentToken = jj_consume_token(KINDTEST_QNAME);
1641                                        expression = QName(currentToken.image);
1642                                        axis = Constants.WITHTYPE;
1643      currentToken = jj_consume_token(CLOSEKINDTEST_R_PAREN);
1644      break;
1645    default:
1646      jj_la1[43] = jj_gen;
1647      jj_consume_token(-1);
1648      throw new ParseException();
1649    }
1650                        try {
1651                                steps.add(factory.createSchemaContextStep(axis, expression, parentModule));
1652                        } catch (TypeException te) {
1653                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1654                        }
1655    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1656    case CLOSEKINDTEST_SLASH:
1657      currentToken = jj_consume_token(CLOSEKINDTEST_SLASH);
1658      break;
1659    case KINDTEST_SLASH:
1660      currentToken = jj_consume_token(KINDTEST_SLASH);
1661      break;
1662    default:
1663      jj_la1[44] = jj_gen;
1664      jj_consume_token(-1);
1665      throw new ParseException();
1666    }
1667                axis = Constants.WITHAXIS;
1668    label_4:
1669    while (true) {
1670      if (jj_2_3(2)) {
1671        ;
1672      } else {
1673        break label_4;
1674      }
1675      currentToken = jj_consume_token(KINDTEST_QNAME);
1676                                expression = QName(currentToken.image);
1677                                try {
1678                                        steps.add(factory.createSchemaContextStep(axis, expression, parentModule));
1679                                } catch (TypeException te) {
1680                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1681                                }
1682      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1683      case CLOSEKINDTEST_SLASH:
1684        currentToken = jj_consume_token(CLOSEKINDTEST_SLASH);
1685        break;
1686      case KINDTEST_SLASH:
1687        currentToken = jj_consume_token(KINDTEST_SLASH);
1688        break;
1689      default:
1690        jj_la1[45] = jj_gen;
1691        jj_consume_token(-1);
1692        throw new ParseException();
1693      }
1694    }
1695    currentToken = jj_consume_token(KINDTEST_QNAME);
1696                        if (attribute)
1697                                axis = Constants.WITHATTAXIS;
1698                        expression = QName(currentToken.image);
1699                        try {
1700                                steps.add(factory.createSchemaContextStep(axis, expression, parentModule));
1701                        } catch (TypeException te) {
1702                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1703                        }
1704                try {
1705                        {if (true) return factory.createSchemaContextPath(steps, parentModule);}
1706                } catch (TypeException te) {
1707                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1708                }
1709    throw new Error("Missing return statement in function");
1710  }
1711
1712/***************************************************************************************
1713[143] SchemaContextLoc ::= (SchemaContextPath? QName) | SchemaGlobalTypeName
1714[13] SchemaGlobalTypeName ::= "type" "(" QName ")"
1715***************************************************************************************/

1716  final public SchemaContextPath SchemaContextLoc() throws ParseException, TypeException, XQueryException {
1717        SchemaContextPath scp = null;
1718        XQueryExpression expression = null;
1719    if (jj_2_4(2)) {
1720      scp = SchemaContextPath(false);
1721    } else {
1722      ;
1723    }
1724                {if (true) return scp;}
1725    throw new Error("Missing return statement in function");
1726  }
1727
1728/***************************************************************************************
1729[114] EnclosedExpr ::= "{" Expr "}"
1730***************************************************************************************/

1731//XQueryExpressionSequence EnclosedExpr() throws TypeException, XQueryException :
1732
// change LARS 10/08/2003
1733
final public XQueryExpression EnclosedExpr(boolean forceSequence) throws ParseException, TypeException, XQueryException {
1734        XQueryExpression expression = null;
1735    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1736    case ELEMENT_CONTENT_L_BRACE:
1737      currentToken = jj_consume_token(ELEMENT_CONTENT_L_BRACE);
1738      break;
1739    case L_BRACE:
1740      currentToken = jj_consume_token(L_BRACE);
1741      break;
1742    default:
1743      jj_la1[46] = jj_gen;
1744      jj_consume_token(-1);
1745      throw new ParseException();
1746    }
1747    expression = Expr(false);
1748    currentToken = jj_consume_token(R_BRACE);
1749                if (forceSequence && !(expression instanceof XQueryExpressionSequence))
1750                {
1751                        ArrayList sequence = new ArrayList(1);
1752                        sequence.add(expression);
1753                        try
1754                        {
1755                                expression = factory.createXQueryExpressionSequence(sequence, parentModule);
1756                        }
1757                        catch (TypeException te)
1758                        {
1759                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1760                        }
1761                        //expression.setBrace(true);
1762
}
1763                {if (true) return expression;}
1764    throw new Error("Missing return statement in function");
1765  }
1766
1767/***************************************************************************************
1768[40] Expr ::= ExprSingle ("," ExprSingle)*
1769***************************************************************************************/

1770  final public XQueryExpression Expr(boolean forceSequence) throws ParseException, TypeException, XQueryException {
1771        XQueryExpression expression = null;
1772        ArrayList sequence = new ArrayList(1);
1773    expression = ExprSingle();
1774                        sequence.add(expression);
1775    label_5:
1776    while (true) {
1777      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1778      case COMMA:
1779        ;
1780        break;
1781      default:
1782        jj_la1[47] = jj_gen;
1783        break label_5;
1784      }
1785      currentToken = jj_consume_token(COMMA);
1786      expression = ExprSingle();
1787                                sequence.add(expression);
1788    }
1789                try
1790                {
1791                        if (forceSequence)
1792                        {
1793                                {if (true) return factory.createXQueryExpressionSequence(sequence, parentModule);}
1794                        }
1795                        if (sequence.size() > 1)
1796                        {
1797                                {if (true) return factory.createXQueryExpressionSequence(sequence, parentModule);}
1798                        }
1799                        else
1800                        {
1801                                {if (true) return expression;}
1802                        }
1803                }
1804                catch (TypeException te)
1805                {
1806                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1807                }
1808    throw new Error("Missing return statement in function");
1809  }
1810
1811/**************************************************************************************
1812// support of sort by for regression purposes !!!
1813[41] ExprSingle ::= FLWORExpr ( ( <"sortby" "("> | <"sort" "by" "("> ) SortSpecList ")" )* | QuantifiedExpr | TypeswitchExpr | IfExpr | OrExpr
1814**************************************************************************************/

1815  final public XQueryExpression ExprSingle() throws ParseException, TypeException, XQueryException {
1816        XQueryExpression expression = null;
1817        ArrayList tmpVect = null;
1818        ArrayList sortSpecList = new ArrayList(1);
1819        boolean oldInPredicate = false;
1820    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1821    case FOR_$:
1822    case LET_$:
1823      expression = FLWORExpr();
1824      if (jj_2_5(2)) {
1825        currentToken = jj_consume_token(SORTBY_L_PAREN);
1826                                                oldInPredicate = inPredicate;
1827                                                inPredicate = true;
1828        tmpVect = OrderSpecList();
1829                                                sortSpecList.addAll(tmpVect);
1830                                                inPredicate = oldInPredicate;
1831        currentToken = jj_consume_token(R_PAREN);
1832      } else {
1833        ;
1834      }
1835      break;
1836    case SOME_$:
1837    case EVERY_$:
1838      expression = QuantifiedExpr();
1839      break;
1840    case TYPESWITCH_L_PAREN:
1841      expression = TypeswitchExpr();
1842                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". TypeswitchExpr is not supported yet.");}
1843      break;
1844    case IF_L_PAREN:
1845      expression = IfExpr();
1846      break;
1847    case ELEMENT_L_PAREN:
1848    case ATTRIBUTE_L_PAREN:
1849    case COMMENT_L_PAREN:
1850    case TEXT_L_PAREN:
1851    case NODE_L_PAREN:
1852    case DOCUMENT_NODE_L_PAREN:
1853    case PROCESSING_INSTRUCTION_L_PAREN:
1854    case STAR:
1855    case XMLCOMMENT_START:
1856    case XMLPROCESSING_START:
1857    case CDATA_START:
1858    case TAG_START:
1859    case VALIDATE_GLOBAL:
1860    case VALIDATE_CONTEXT:
1861    case VALIDATE_LAX:
1862    case VALIDATE_STRICT:
1863    case VALIDATE_SKIP:
1864    case ELEMENT_QNAME_L_BRACE:
1865    case ELEMENT_L_BRACE:
1866    case ATTRIBUTE_L_BRACE:
1867    case ATTRIBUTE_QNAME_L_BRACE:
1868    case NAMESPACE_NCNAME_L_BRACE:
1869    case DOCUMENT_L_BRACE:
1870    case TEXT_L_BRACE:
1871    case PROCESSING_INSTRUCTION_L_BRACE:
1872    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
1873    case COMMENT_L_BRACE:
1874    case AROBASE:
1875    case ANCESTOR_OR_SELF_DCOLON:
1876    case ANCESTOR_DCOLON:
1877    case ATTRIBUTE_DCOLON:
1878    case CHILD_DCOLON:
1879    case DESCENDANT_SELF_DCOLON:
1880    case DESCENDANT_DCOLON:
1881    case FOLLOWING_SIBLING_DCOLON:
1882    case FOLLOWING_DCOLON:
1883    case PARENT_DCOLON:
1884    case PRECEDING_SIBLING_DCOLON:
1885    case PRECEDING_DCOLON:
1886    case SELF_DCOLON:
1887    case QNAME_L_PAREN:
1888    case DOLLAR:
1889    case VALIDATE_L_BRACE:
1890    case L_PAREN:
1891    case MINUS:
1892    case PLUS:
1893    case SLASH_SLASH:
1894    case SLASH:
1895    case DecimalLiteral:
1896    case DOTDOT:
1897    case DOT:
1898    case DoubleLiteral:
1899    case IntegerLiteral:
1900    case NCNAME_STAR:
1901    case STAR_NCNAME:
1902    case StringLiteral:
1903    case QNAME:
1904    case KINDTEST_ELEMENT_L_PAREN:
1905    case ELEMENT_CONTENT_ELT_LESS:
1906    case ELEMENT_CONTENT_XMLCOMMENT_START:
1907    case ELEMENT_CONTENT_XMLPROCESSING_START:
1908    case ELEMENT_CONTENT_CDATA_START:
1909      expression = OrExpr();
1910      break;
1911    default:
1912      jj_la1[48] = jj_gen;
1913      jj_consume_token(-1);
1914      throw new ParseException();
1915    }
1916                if (!sortSpecList.isEmpty())
1917                {
1918                        try
1919                        {
1920                                {if (true) return factory.createSortedExpression(expression, sortSpecList, false, parentModule);}
1921                        }
1922                        catch (TypeException te)
1923                        {
1924                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
1925                        }
1926                }
1927                {if (true) return expression;}
1928    throw new Error("Missing return statement in function");
1929  }
1930
1931/***************************************************************************************
1932[48] OrderSpecList ::= OrderSpec ("," OrderSpec)*
1933[49] OrderSpec ::= ExprSingle OrderModifier
1934***************************************************************************************/

1935  final public ArrayList OrderSpecList() throws ParseException, TypeException, XQueryException {
1936        ArrayList resVect = new ArrayList();
1937        ArrayList tmpVect = null;
1938        XQueryExpression expression = null;
1939        int[] order = {Constants.NOTHING, Constants.NOTHING};
1940    expression = ExprSingle();
1941    order = OrderModifier();
1942                        expression.setOrder(order);
1943                        resVect.add(expression);
1944    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1945    case COMMA:
1946      currentToken = jj_consume_token(COMMA);
1947      tmpVect = OrderSpecList();
1948                                resVect.addAll(tmpVect);
1949      break;
1950    default:
1951      jj_la1[49] = jj_gen;
1952      ;
1953    }
1954                {if (true) return resVect;}
1955    throw new Error("Missing return statement in function");
1956  }
1957
1958/***************************************************************************************
1959[50] OrderModifier ::= ("ascending" | "descending")? (<"empty" "greatest"> | <"empty" "least">)? ("collation" StringLiteral)?
1960***************************************************************************************/

1961  final public int[] OrderModifier() throws ParseException, TypeException, XQueryException {
1962        int[] order = {Constants.ASCENDING_ORDER, Constants.NOTHING};
1963    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1964    case OPERATOR_ASCENDING:
1965    case OPERATOR_DESCENDING:
1966    case OPERATOR_PLACE_ORDER:
1967      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1968      case OPERATOR_ASCENDING:
1969        currentToken = jj_consume_token(OPERATOR_ASCENDING);
1970                                order[0] = Constants.ASCENDING_ORDER;
1971        break;
1972      case OPERATOR_DESCENDING:
1973        currentToken = jj_consume_token(OPERATOR_DESCENDING);
1974                                order[0] = Constants.DESCENDING_ORDER;
1975        break;
1976      case OPERATOR_PLACE_ORDER:
1977        currentToken = jj_consume_token(OPERATOR_PLACE_ORDER);
1978                                order[0] = Constants.PLACE_ORDER;
1979        break;
1980      default:
1981        jj_la1[50] = jj_gen;
1982        jj_consume_token(-1);
1983        throw new ParseException();
1984      }
1985      break;
1986    default:
1987      jj_la1[51] = jj_gen;
1988      ;
1989    }
1990    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1991    case OPERATOR_EMPTY_GREATEST:
1992    case OPERATOR_EMPTY_LEAST:
1993      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1994      case OPERATOR_EMPTY_GREATEST:
1995        currentToken = jj_consume_token(OPERATOR_EMPTY_GREATEST);
1996                                        order[1] = Constants.GREATEST_ORDER;
1997        break;
1998      case OPERATOR_EMPTY_LEAST:
1999        currentToken = jj_consume_token(OPERATOR_EMPTY_LEAST);
2000                                        order[1] = Constants.LEAST_ORDER;
2001        break;
2002      default:
2003        jj_la1[52] = jj_gen;
2004        jj_consume_token(-1);
2005        throw new ParseException();
2006      }
2007                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Handling of empty sequence in SortModifier is not supported yet.");}
2008      break;
2009    default:
2010      jj_la1[53] = jj_gen;
2011      ;
2012    }
2013    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2014    case OPERATOR_COLLATION:
2015      currentToken = jj_consume_token(OPERATOR_COLLATION);
2016      currentToken = jj_consume_token(StringLiteral);
2017                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Handling of collation in SortModifier is not supported yet.");}
2018      break;
2019    default:
2020      jj_la1[54] = jj_gen;
2021      ;
2022    }
2023                {if (true) return order;}
2024    throw new Error("Missing return statement in function");
2025  }
2026
2027/***************************************************************************************
2028[42] FLWORExpr ::= (ForClause | LetClause)+ WhereClause? OrderByClause? "return" ExprSingle
2029***************************************************************************************/

2030  final public XQueryExpression FLWORExpr() throws ParseException, TypeException, XQueryException {
2031        XQueryExpression whereClause = null;
2032        XQueryExpression returnClause = null;
2033        ArrayList bindings = new ArrayList();
2034        ArrayList orderbys = null;
2035        ArrayList tmpVect = null;
2036        HintTree hintClause = null;
2037    label_6:
2038    while (true) {
2039      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2040      case FOR_$:
2041        tmpVect = ForClause();
2042        break;
2043      case LET_$:
2044        tmpVect = LetClause();
2045        break;
2046      default:
2047        jj_la1[55] = jj_gen;
2048        jj_consume_token(-1);
2049        throw new ParseException();
2050      }
2051                                bindings.addAll(tmpVect);
2052      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2053      case FOR_$:
2054      case LET_$:
2055        ;
2056        break;
2057      default:
2058        jj_la1[56] = jj_gen;
2059        break label_6;
2060      }
2061    }
2062                        whereClause = null;
2063                        orderbys = null;
2064    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2065    case OUTER_MERGE:
2066    case OUTER_NESTED:
2067    case END_EXT_KEY:
2068    case MERGE:
2069    case CARTESIAN_PRODUCT:
2070    case JOIN:
2071    case NESTED_LOOP:
2072      hintClause = HintClause();
2073      break;
2074    default:
2075      jj_la1[57] = jj_gen;
2076      ;
2077    }
2078    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2079    case OPERATOR_WHERE:
2080      whereClause = WhereClause();
2081      break;
2082    default:
2083      jj_la1[58] = jj_gen;
2084      ;
2085    }
2086    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2087    case OPERATOR_ORDER_BY:
2088    case OPERATOR_STABLE_ORDER_BY:
2089      orderbys = OrderByClause();
2090      break;
2091    default:
2092      jj_la1[59] = jj_gen;
2093      ;
2094    }
2095    currentToken = jj_consume_token(OPERATOR_RETURN);
2096    returnClause = ExprSingle();
2097                        for (int i = 0; i < bindings.size(); i++)
2098                        {
2099                                removeVarDefinition(((Variable) bindings.get(i)).getStringValue());
2100                        }
2101                        try
2102                        {
2103                                {if (true) return factory.createFLWRExpression(bindings, hintClause, whereClause, orderbys, returnClause, parentModule);}
2104                        }
2105                        catch (TypeException te)
2106                        {
2107                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2108                        }
2109    throw new Error("Missing return statement in function");
2110  }
2111
2112/***************************************************************************************
2113[43] ForClause ::= <"for" "$"> VarName TypeDeclaration? PositionalVar? "in" ExprSingle ("," "$" VarName TypeDeclaration? PositionalVar? "in" ExprSingle)*
2114***************************************************************************************/

2115  final public ArrayList ForClause() throws ParseException, TypeException, XQueryException {
2116        boolean hasTypeDeclaration = false;
2117        XQueryExpression positionVar = null;
2118        SequenceType typeDeclaration = null;
2119        ArrayList vectVar = new ArrayList(1);
2120        Variable var = null;
2121        XQueryExpression expression = null;
2122    currentToken = jj_consume_token(FOR_$);
2123    currentToken = jj_consume_token(VARNAME_QNAME);
2124                        var = (Variable)VarName(currentToken.image);
2125                        vectVar.add(var);
2126    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2127    case OPERATOR_AS:
2128      TypeDeclaration();
2129                        hasTypeDeclaration = true;
2130      break;
2131    default:
2132      jj_la1[60] = jj_gen;
2133      ;
2134    }
2135    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2136    case AT:
2137      positionVar = PositionalVar();
2138                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Positional Variable is not supported yet.");}
2139      break;
2140    default:
2141      jj_la1[61] = jj_gen;
2142      ;
2143    }
2144    currentToken = jj_consume_token(OPERATOR_IN);
2145    expression = ExprSingle();
2146                        var.setBindingType(Constants.FOR_BINDINGTYPE);
2147                        var.setExpression(expression, true);
2148                        //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2149
//addVarDefinition(var);
2150

2151    label_7:
2152    while (true) {
2153      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2154      case COMMA:
2155        ;
2156        break;
2157      default:
2158        jj_la1[62] = jj_gen;
2159        break label_7;
2160      }
2161      currentToken = jj_consume_token(COMMA);
2162                                hasTypeDeclaration = false;
2163                                positionVar = null;
2164      currentToken = jj_consume_token(DOLLAR);
2165      currentToken = jj_consume_token(VARNAME_QNAME);
2166                                var = (Variable)VarName(currentToken.image);
2167                                vectVar.add(var);
2168      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2169      case OPERATOR_AS:
2170        TypeDeclaration();
2171                                hasTypeDeclaration = true;
2172        break;
2173      default:
2174        jj_la1[63] = jj_gen;
2175        ;
2176      }
2177      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2178      case AT:
2179        positionVar = PositionalVar();
2180                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Positional Variable is not supported yet.");}
2181        break;
2182      default:
2183        jj_la1[64] = jj_gen;
2184        ;
2185      }
2186      currentToken = jj_consume_token(OPERATOR_IN);
2187      expression = ExprSingle();
2188                                var.setBindingType(Constants.FOR_BINDINGTYPE);
2189                                var.setExpression(expression, true);
2190                                //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2191
//addVarDefinition(var);
2192

2193    }
2194                {if (true) return vectVar;}
2195    throw new Error("Missing return statement in function");
2196  }
2197
2198/***************************************************************************************
2199[44] PositionalVar ::= "at" "$" VarName
2200***************************************************************************************/

2201  final public XQueryExpression PositionalVar() throws ParseException, TypeException, XQueryException {
2202        XQueryExpression var = null;
2203    currentToken = jj_consume_token(AT);
2204    currentToken = jj_consume_token(DOLLAR);
2205    currentToken = jj_consume_token(VARNAME_QNAME);
2206                var = (Variable)VarName(currentToken.image,false);
2207                {if (true) return var;}
2208    throw new Error("Missing return statement in function");
2209  }
2210
2211/***************************************************************************************
2212[45] LetClause ::= <"let" "$"> VarName TypeDeclaration? ":=" ExprSingle ("," "$" VarName TypeDeclaration? ":=" ExprSingle)*
2213***************************************************************************************/

2214  final public ArrayList LetClause() throws ParseException, TypeException, XQueryException {
2215        boolean hasTypeDeclaration = false;
2216        SequenceType typeDeclaration = null;
2217        ArrayList vectVar = new ArrayList();
2218        Variable var = null;
2219        XQueryExpression expression = null;
2220    currentToken = jj_consume_token(LET_$);
2221    currentToken = jj_consume_token(VARNAME_QNAME);
2222                        var = (Variable)VarName(currentToken.image);
2223                        vectVar.add(var);
2224    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2225    case OPERATOR_AS:
2226      TypeDeclaration();
2227                        hasTypeDeclaration = true;
2228      break;
2229    default:
2230      jj_la1[65] = jj_gen;
2231      ;
2232    }
2233    currentToken = jj_consume_token(OPERATOR_COLON_EQUAL);
2234    expression = ExprSingle();
2235                        var.setBindingType(Constants.LET_BINDINGTYPE);
2236                        var.setExpression(expression, true);
2237                        //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2238
//addVarDefinition(var);
2239

2240    label_8:
2241    while (true) {
2242      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2243      case COMMA:
2244        ;
2245        break;
2246      default:
2247        jj_la1[66] = jj_gen;
2248        break label_8;
2249      }
2250      currentToken = jj_consume_token(COMMA);
2251      currentToken = jj_consume_token(DOLLAR);
2252      currentToken = jj_consume_token(VARNAME_QNAME);
2253                                var = (Variable)VarName(currentToken.image);
2254                                vectVar.add(var);
2255      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2256      case OPERATOR_AS:
2257        TypeDeclaration();
2258                                hasTypeDeclaration = true;
2259        break;
2260      default:
2261        jj_la1[67] = jj_gen;
2262        ;
2263      }
2264      currentToken = jj_consume_token(OPERATOR_COLON_EQUAL);
2265      expression = ExprSingle();
2266                                var.setBindingType(Constants.LET_BINDINGTYPE);
2267                                var.setExpression(expression, true);
2268                                //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2269
//addVarDefinition(var);
2270

2271    }
2272                {if (true) return vectVar;}
2273    throw new Error("Missing return statement in function");
2274  }
2275
2276/***************************************************************************************
2277[46] WhereClause ::= "where" Expr
2278***************************************************************************************/

2279  final public XQueryExpression WhereClause() throws ParseException, TypeException, XQueryException {
2280        XQueryExpression expression = null;
2281    currentToken = jj_consume_token(OPERATOR_WHERE);
2282    expression = ExprSingle();
2283                {if (true) return expression;}
2284    throw new Error("Missing return statement in function");
2285  }
2286
2287/***************************************************************************************
2288ADDED LARS HintClause ::= <"hint ("> NodeClause ")"
2289***************************************************************************************/

2290  final public HintTree HintClause() throws ParseException, TypeException, XQueryException {
2291        HintTree hintTree = null;
2292        byte outertype = HintTree.NO_TYPE;
2293    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2294    case OUTER_MERGE:
2295    case OUTER_NESTED:
2296      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2297      case OUTER_MERGE:
2298        currentToken = jj_consume_token(OUTER_MERGE);
2299                                outertype = HintTree.MERGE_TYPE;
2300        break;
2301      case OUTER_NESTED:
2302        currentToken = jj_consume_token(OUTER_NESTED);
2303                                outertype = HintTree.NESTED_TYPE;
2304        break;
2305      default:
2306        jj_la1[68] = jj_gen;
2307        jj_consume_token(-1);
2308        throw new ParseException();
2309      }
2310      break;
2311    default:
2312      jj_la1[69] = jj_gen;
2313      ;
2314    }
2315    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2316    case MERGE:
2317    case CARTESIAN_PRODUCT:
2318    case JOIN:
2319    case NESTED_LOOP:
2320      hintTree = NodeClause();
2321      break;
2322    default:
2323      jj_la1[70] = jj_gen;
2324      ;
2325    }
2326    currentToken = jj_consume_token(END_EXT_KEY);
2327                if (hintTree == null && outertype != HintTree.NO_TYPE) {
2328                        hintTree = factory.createHintTree(HintTree.NO_TYPE, HintTree.NO_SIDE, null, null);
2329                }
2330                if (hintTree != null) {
2331                        hintTree.setOuterType(outertype);
2332                }
2333                {if (true) return hintTree;}
2334    throw new Error("Missing return statement in function");
2335  }
2336
2337/***************************************************************************************
2338ADDED LARS NodeClause ::= ( "merge" | "cartesian-product" | "join" | "nested-loop" ) "(" LeafClause "," LeafClause ")"
2339***************************************************************************************/

2340  final public HintTree NodeClause() throws ParseException, TypeException, XQueryException {
2341        Object left = null;
2342        Object right = null;
2343        byte type = Constants.NOTHING;
2344    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2345    case MERGE:
2346      currentToken = jj_consume_token(MERGE);
2347                                type = HintTree.MERGE_TYPE;
2348      break;
2349    case CARTESIAN_PRODUCT:
2350      currentToken = jj_consume_token(CARTESIAN_PRODUCT);
2351                                type = HintTree.CARTESIAN_PRODUCT_TYPE;
2352      break;
2353    case JOIN:
2354      currentToken = jj_consume_token(JOIN);
2355                                type = HintTree.JOIN_TYPE;
2356      break;
2357    case NESTED_LOOP:
2358      currentToken = jj_consume_token(NESTED_LOOP);
2359                                type = HintTree.NESTED_LOOP_TYPE;
2360      break;
2361    default:
2362      jj_la1[71] = jj_gen;
2363      jj_consume_token(-1);
2364      throw new ParseException();
2365    }
2366    currentToken = jj_consume_token(HINT_L_PAREN);
2367    left = LeafClause();
2368    currentToken = jj_consume_token(HINT_COMMA);
2369    right = LeafClause();
2370    currentToken = jj_consume_token(HINT_R_PAREN);
2371                {if (true) return factory.createHintTree(type, HintTree.NO_SIDE, left, right);}
2372    throw new Error("Missing return statement in function");
2373  }
2374
2375/***************************************************************************************
2376ADDED LARS LeafClause ::= NodeClause | VAR
2377***************************************************************************************/

2378  final public Object LeafClause() throws ParseException, TypeException, XQueryException {
2379        Object leaf = null;
2380    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2381    case MERGE:
2382    case CARTESIAN_PRODUCT:
2383    case JOIN:
2384    case NESTED_LOOP:
2385      leaf = NodeClause();
2386      break;
2387    case HINT_DOLLAR:
2388      currentToken = jj_consume_token(HINT_DOLLAR);
2389      currentToken = jj_consume_token(HINT_QNAME);
2390                                leaf = (Variable)VarName(currentToken.image,false);
2391      break;
2392    default:
2393      jj_la1[72] = jj_gen;
2394      jj_consume_token(-1);
2395      throw new ParseException();
2396    }
2397                {if (true) return leaf;}
2398    throw new Error("Missing return statement in function");
2399  }
2400
2401/***************************************************************************************
2402[47] OrderByClause ::= (<"order" "by"> | <"stable" "order" "by">) OrderSpecList
2403***************************************************************************************/

2404  final public ArrayList OrderByClause() throws ParseException, TypeException, XQueryException {
2405        XQueryExpression expression = null;
2406        boolean stable = false;
2407        ArrayList tmpVect = null;
2408        ArrayList sortSpecList = new ArrayList(1);
2409        boolean oldInPredicate = false;
2410    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2411    case OPERATOR_ORDER_BY:
2412      currentToken = jj_consume_token(OPERATOR_ORDER_BY);
2413      break;
2414    case OPERATOR_STABLE_ORDER_BY:
2415      currentToken = jj_consume_token(OPERATOR_STABLE_ORDER_BY);
2416                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". \"stable\" in SortExpr is not supported yet.");}
2417                                stable = true;
2418      break;
2419    default:
2420      jj_la1[73] = jj_gen;
2421      jj_consume_token(-1);
2422      throw new ParseException();
2423    }
2424                        oldInPredicate = inPredicate;
2425                        inPredicate = true;
2426    tmpVect = OrderSpecList();
2427                        sortSpecList.addAll(tmpVect);
2428                        inPredicate = oldInPredicate;
2429                {if (true) return sortSpecList;}
2430    throw new Error("Missing return statement in function");
2431  }
2432
2433/***************************************************************************************
2434[51] QuantifiedExpr ::= (<"some" "$"> | <"every" "$">) VarName TypeDeclaration? "in" ExprSingle ("," "$" VarName TypeDeclaration? "in" ExprSingle)* "satisfies" ExprSingle
2435***************************************************************************************/

2436  final public XQueryExpression QuantifiedExpr() throws ParseException, TypeException, XQueryException {
2437        int kind = Constants.NOTHING;
2438        Variable var = null;
2439        ArrayList varlist = new ArrayList();
2440        XQueryExpression expression = null;
2441        XQueryExpression satisfies = null;
2442    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2443    case SOME_$:
2444      currentToken = jj_consume_token(SOME_$);
2445                                kind = Constants.SOME_QUANTIFIER;
2446      break;
2447    case EVERY_$:
2448      currentToken = jj_consume_token(EVERY_$);
2449                                kind = Constants.EVERY_QUANTIFIER;
2450      break;
2451    default:
2452      jj_la1[74] = jj_gen;
2453      jj_consume_token(-1);
2454      throw new ParseException();
2455    }
2456    currentToken = jj_consume_token(VARNAME_QNAME);
2457                                var = (Variable)VarName(currentToken.image);
2458    currentToken = jj_consume_token(OPERATOR_IN);
2459    expression = ExprSingle();
2460                                var.setBindingType(Constants.QUANTIFIER_BINDINGTYPE);
2461                                var.setExpression(expression, true);
2462                                //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2463
//addVarDefinition(var);
2464
varlist.add(var);
2465    label_9:
2466    while (true) {
2467      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2468      case COMMA:
2469        ;
2470        break;
2471      default:
2472        jj_la1[75] = jj_gen;
2473        break label_9;
2474      }
2475      currentToken = jj_consume_token(COMMA);
2476      currentToken = jj_consume_token(DOLLAR);
2477      currentToken = jj_consume_token(VARNAME_QNAME);
2478                                var = (Variable)VarName(currentToken.image);
2479      currentToken = jj_consume_token(OPERATOR_IN);
2480      expression = ExprSingle();
2481                                        var.setBindingType(Constants.QUANTIFIER_BINDINGTYPE);
2482                                        var.setExpression(expression, true);
2483                                        //if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2484
//addVarDefinition(var);
2485
varlist.add(var);
2486    }
2487    currentToken = jj_consume_token(OPERATOR_SATISFIES);
2488    satisfies = ExprSingle();
2489                        for (int i=0;i<varlist.size();i++)
2490                        {
2491                                removeVarDefinition(((Variable)varlist.get(i)).getStringValue());
2492                        }
2493                        try
2494                        {
2495                                {if (true) return factory.createQuantifiedExpression(kind, varlist, satisfies, parentModule);}
2496                        }
2497                        catch (TypeException te)
2498                        {
2499                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2500                        }
2501    throw new Error("Missing return statement in function");
2502  }
2503
2504/***************************************************************************************
2505[52] TypeswitchExpr ::= <"typeswitch" "("> Expr ")" CaseClause+ "default" ("$" VarName)? "return" ExprSingle
2506LARS --> [52] TypeswitchExpr ::= <"typeswitch" "("> ExprSingle ")" CaseClause+ "default" ("$" VarName)? "return" ExprSingle
2507***************************************************************************************/

2508  final public XQueryExpression TypeswitchExpr() throws ParseException, TypeException, XQueryException {
2509        XQueryExpression switchExpression = null;
2510        CaseClauseExpression caseClause = null;
2511        XQueryExpression returnClause = null;
2512        HashMap cases = new HashMap();
2513        XQueryExpression var = null;
2514    currentToken = jj_consume_token(TYPESWITCH_L_PAREN);
2515    switchExpression = ExprSingle();
2516    currentToken = jj_consume_token(R_PAREN);
2517    label_10:
2518    while (true) {
2519      caseClause = CaseClause();
2520                                cases.put(caseClause.getSequenceType(), caseClause);
2521      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2522      case OPERATOR_CASE:
2523        ;
2524        break;
2525      default:
2526        jj_la1[76] = jj_gen;
2527        break label_10;
2528      }
2529    }
2530    currentToken = jj_consume_token(OPERATOR_DEFAULT);
2531                        var = null;
2532    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2533    case DOLLAR:
2534      currentToken = jj_consume_token(DOLLAR);
2535      currentToken = jj_consume_token(VARNAME_QNAME);
2536                                var = (Variable)VarName(currentToken.image,false);
2537      break;
2538    default:
2539      jj_la1[77] = jj_gen;
2540      ;
2541    }
2542    currentToken = jj_consume_token(OPERATOR_RETURN);
2543    returnClause = ExprSingle();
2544                        try
2545                        {
2546                                if (var != null)
2547                                {
2548                                        {if (true) return factory.createTypeSwitchExpression(switchExpression, cases, (Variable)var, returnClause, parentModule);}
2549                                }
2550                                else
2551                                {
2552                                        {if (true) return factory.createTypeSwitchExpression(switchExpression, cases, null, returnClause, parentModule);}
2553                                }
2554                        }
2555                        catch (TypeException te)
2556                        {
2557                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2558                        }
2559    throw new Error("Missing return statement in function");
2560  }
2561
2562/***************************************************************************************
2563[53] CaseClause ::= "case" ("$" VarName "as")? SequenceType "return" ExprSingle
2564***************************************************************************************/

2565  final public CaseClauseExpression CaseClause() throws ParseException, TypeException, XQueryException {
2566        XQueryExpression var = null;
2567        SequenceType sequenceType = null;
2568        XQueryExpression returnExpression = null;
2569    currentToken = jj_consume_token(OPERATOR_CASE);
2570    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2571    case DOLLAR:
2572      currentToken = jj_consume_token(DOLLAR);
2573      currentToken = jj_consume_token(VARNAME_QNAME);
2574                                var = (Variable)VarName(currentToken.image);
2575                                var.setTypeDeclaration(sequenceType);
2576                                if (staticcontext.getTypeVisitor() != null) var.accept(staticcontext.getTypeVisitor());
2577      currentToken = jj_consume_token(OPERATOR_AS);
2578      break;
2579    default:
2580      jj_la1[78] = jj_gen;
2581      ;
2582    }
2583    sequenceType = SequenceType();
2584    currentToken = jj_consume_token(OPERATOR_RETURN);
2585    returnExpression = ExprSingle();
2586                try
2587                {
2588                        if (var == null)
2589                        {
2590                                {if (true) return factory.createCaseClauseExpression(sequenceType, null, returnExpression, parentModule);}
2591                        }
2592                        else
2593                        {
2594                                removeVarDefinition(var.getStringValue());
2595                                {if (true) return factory.createCaseClauseExpression(null, (Variable)var, returnExpression, parentModule);}
2596                        }
2597                }
2598                catch (TypeException te)
2599                {
2600                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2601                }
2602    throw new Error("Missing return statement in function");
2603  }
2604
2605/***************************************************************************************
2606[54] IfExpr ::= <"if" "("> Expr ")" "then" ExprSingle "else" ExprSingle
2607***************************************************************************************/

2608  final public XQueryExpression IfExpr() throws ParseException, TypeException, XQueryException {
2609        XQueryExpression ifClause = null;
2610        XQueryExpression thenClause = null;
2611        XQueryExpression elseClause = null;
2612    currentToken = jj_consume_token(IF_L_PAREN);
2613    ifClause = ExprSingle();
2614    currentToken = jj_consume_token(R_PAREN);
2615    currentToken = jj_consume_token(OPERATOR_THEN);
2616    thenClause = ExprSingle();
2617    currentToken = jj_consume_token(OPERATOR_ELSE);
2618    elseClause = ExprSingle();
2619                        try
2620                        {
2621                                {if (true) return factory.createITEExpression(ifClause, thenClause, elseClause, parentModule);}
2622                        }
2623                        catch (TypeException te)
2624                        {
2625                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2626                        }
2627    throw new Error("Missing return statement in function");
2628  }
2629
2630/***************************************************************************************
2631[55] OrExpr ::= AndExpr ( "or" AndExpr )*
2632***************************************************************************************/

2633  final public XQueryExpression OrExpr() throws ParseException, TypeException, XQueryException {
2634        XQueryExpression mainExpression = null;
2635        XQueryExpression expression = null;
2636        BinOpORExpression binOpORExpression = null;
2637    mainExpression = AndExpr();
2638    label_11:
2639    while (true) {
2640      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2641      case OPERATOR_OR:
2642        ;
2643        break;
2644      default:
2645        jj_la1[79] = jj_gen;
2646        break label_11;
2647      }
2648      currentToken = jj_consume_token(OPERATOR_OR);
2649      expression = AndExpr();
2650                                try
2651                                {
2652                                        binOpORExpression = factory.createBinOpORExpression(mainExpression, expression, parentModule);
2653                                }
2654                                catch (TypeException te)
2655                                {
2656                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2657                                }
2658                                mainExpression = binOpORExpression;
2659    }
2660                {if (true) return mainExpression;}
2661    throw new Error("Missing return statement in function");
2662  }
2663
2664/***************************************************************************************
2665[56] AndExpr ::= InstanceofExpr ( "and" InstanceofExpr )*
2666***************************************************************************************/

2667  final public XQueryExpression AndExpr() throws ParseException, TypeException, XQueryException {
2668        XQueryExpression mainExpression = null;
2669        XQueryExpression expression = null;
2670        BinOpANDExpression binOpANDExpression = null;
2671    mainExpression = InstanceofExpr();
2672    label_12:
2673    while (true) {
2674      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2675      case OPERATOR_AND:
2676        ;
2677        break;
2678      default:
2679        jj_la1[80] = jj_gen;
2680        break label_12;
2681      }
2682      currentToken = jj_consume_token(OPERATOR_AND);
2683      expression = InstanceofExpr();
2684                                try
2685                                {
2686                                        binOpANDExpression = factory.createBinOpANDExpression(mainExpression, expression, parentModule);
2687                                }
2688                                catch (TypeException te)
2689                                {
2690                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2691                                }
2692                                mainExpression = binOpANDExpression;
2693    }
2694                {if (true) return mainExpression;}
2695    throw new Error("Missing return statement in function");
2696  }
2697
2698/***************************************************************************************
2699[57] InstanceofExpr ::= TreatExpr ( <"instance" "of"> SequenceType )?
2700***************************************************************************************/

2701  final public XQueryExpression InstanceofExpr() throws ParseException, TypeException, XQueryException {
2702        XQueryExpression expression = null;
2703        SequenceType sequenceType = null;
2704    expression = TreatExpr();
2705    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2706    case OPERATOR_INSTANCE_OF:
2707      currentToken = jj_consume_token(OPERATOR_INSTANCE_OF);
2708                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". InstanceOfExpr is not supported yet.");}
2709      sequenceType = SequenceType();
2710                                try
2711                                {
2712                                        expression = factory.createInstanceOfExpression(expression, sequenceType, parentModule);
2713                                }
2714                                catch (TypeException te)
2715                                {
2716                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2717                                }
2718      break;
2719    default:
2720      jj_la1[81] = jj_gen;
2721      ;
2722    }
2723                {if (true) return expression;}
2724    throw new Error("Missing return statement in function");
2725  }
2726
2727/***************************************************************************************
2728[58] TreatExpr ::= CastableExpr ( <"treat" "as"> SequenceType )?
2729***************************************************************************************/

2730  final public XQueryExpression TreatExpr() throws ParseException, TypeException, XQueryException {
2731        SequenceType sequenceType = null;
2732        XQueryExpression expression = null;
2733    expression = CastableExpr();
2734    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2735    case OPERATOR_TREAT_AS:
2736      currentToken = jj_consume_token(OPERATOR_TREAT_AS);
2737                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". TreatExpr is not supported yet.");}
2738      sequenceType = SequenceType();
2739                                try
2740                                {
2741                                        {if (true) return factory.createCastTreatExpression(Constants.TREAT_TYPING, sequenceType, expression, parentModule);}
2742                                }
2743                                catch (TypeException te)
2744                                {
2745                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2746                                }
2747      break;
2748    default:
2749      jj_la1[82] = jj_gen;
2750      ;
2751    }
2752                {if (true) return expression;}
2753    throw new Error("Missing return statement in function");
2754  }
2755
2756/***************************************************************************************
2757[59] CastableExpr ::= CastExpr ( <"castable" "as"> SingleType )?
2758[124] SingleType ::= AtomicType "?"?
2759[126] AtomicType ::= QName
2760***************************************************************************************/

2761  final public XQueryExpression CastableExpr() throws ParseException, TypeException, XQueryException {
2762        XQueryExpression expression = null;
2763        XQueryExpression qname = null;
2764    expression = CastExpr();
2765    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2766    case OPERATOR_CASTABLE_AS:
2767      currentToken = jj_consume_token(OPERATOR_CASTABLE_AS);
2768                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". CastableExpr is not supported yet.");}
2769      currentToken = jj_consume_token(QNAME);
2770                                qname = QName(currentToken.image);
2771      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2772      case OPERATOR_QUESTION_MARK:
2773        currentToken = jj_consume_token(OPERATOR_QUESTION_MARK);
2774        break;
2775      default:
2776        jj_la1[83] = jj_gen;
2777        ;
2778      }
2779                                try
2780                                {
2781                                        {if (true) return factory.createCastTreatExpression(Constants.CAST_TYPING, null, expression, parentModule);}
2782                                }
2783                                catch (TypeException te)
2784                                {
2785                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2786                                }
2787      break;
2788    default:
2789      jj_la1[84] = jj_gen;
2790      ;
2791    }
2792                {if (true) return expression;}
2793    throw new Error("Missing return statement in function");
2794  }
2795
2796/***************************************************************************************
2797[60] CastExpr ::= ComparisonExpr ( <"cast" "as"> SingleType )?
2798[124] SingleType ::= AtomicType "?"?
2799[126] AtomicType ::= QName
2800***************************************************************************************/

2801  final public XQueryExpression CastExpr() throws ParseException, TypeException, XQueryException {
2802        XQueryExpression expression = null;
2803        XQueryExpression qname = null;
2804    expression = ComparisonExpr();
2805    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2806    case OPERATOR_CAST_AS:
2807      currentToken = jj_consume_token(OPERATOR_CAST_AS);
2808                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". CastExpr is not supported yet.");}
2809      currentToken = jj_consume_token(ITEMTYPE_QNAME);
2810                                qname = QName(currentToken.image);
2811      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2812      case OPERATOR_QUESTION_MARK:
2813        currentToken = jj_consume_token(OPERATOR_QUESTION_MARK);
2814        break;
2815      default:
2816        jj_la1[85] = jj_gen;
2817        ;
2818      }
2819                                try
2820                                {
2821                                        {if (true) return factory.createCastTreatExpression(Constants.CAST_TYPING, null, expression, parentModule);}
2822                                }
2823                                catch (TypeException te)
2824                                {
2825                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2826                                }
2827      break;
2828    default:
2829      jj_la1[86] = jj_gen;
2830      ;
2831    }
2832                {if (true) return expression;}
2833    throw new Error("Missing return statement in function");
2834  }
2835
2836/**************************************************************************************
2837[61] ComparisonExpr ::= RangeExpr ( (ValueComp | GeneralComp | NodeComp) RangeExpr )?
2838**************************************************************************************/

2839  final public XQueryExpression ComparisonExpr() throws ParseException, TypeException, XQueryException {
2840        XQueryExpression mainExpression = null;
2841        XQueryExpression expression = null;
2842        int kind = Constants.NOTHING;
2843    mainExpression = RangeExpr();
2844    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2845    case OPERATOR_EQUAL:
2846    case OPERATOR_EQ:
2847    case OPERATOR_GE:
2848    case OPERATOR_GT:
2849    case OPERATOR_LE:
2850    case OPERATOR_LT:
2851    case OPERATOR_NE:
2852    case OPERATOR_GREATER_EQUAL:
2853    case OPERATOR_GREATER_GREATER:
2854    case OPERATOR_GREATER:
2855    case OPERATOR_IS:
2856    case OPERATOR_LESS_EQUAL:
2857    case OPERATOR_LESS_LESS:
2858    case OPERATOR_LESS:
2859    case OPERATOR_NOT_EQUAL:
2860      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2861      case OPERATOR_EQ:
2862      case OPERATOR_GE:
2863      case OPERATOR_GT:
2864      case OPERATOR_LE:
2865      case OPERATOR_LT:
2866      case OPERATOR_NE:
2867        kind = ValueComp();
2868        break;
2869      case OPERATOR_EQUAL:
2870      case OPERATOR_GREATER_EQUAL:
2871      case OPERATOR_GREATER:
2872      case OPERATOR_LESS_EQUAL:
2873      case OPERATOR_LESS:
2874      case OPERATOR_NOT_EQUAL:
2875        kind = GeneralComp();
2876        break;
2877      case OPERATOR_GREATER_GREATER:
2878      case OPERATOR_IS:
2879      case OPERATOR_LESS_LESS:
2880        kind = NodeComp();
2881                                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Node comparison is not supported yet.");}
2882        break;
2883      default:
2884        jj_la1[87] = jj_gen;
2885        jj_consume_token(-1);
2886        throw new ParseException();
2887      }
2888      expression = RangeExpr();
2889      break;
2890    default:
2891      jj_la1[88] = jj_gen;
2892      ;
2893    }
2894                if (kind != Constants.NOTHING)
2895                {
2896                        try
2897                        {
2898                                {if (true) return factory.createListOpCompExpression(mainExpression, expression, kind, parentModule);}
2899                        }
2900                        catch (TypeException te)
2901                        {
2902                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
2903                        }
2904                }
2905                {if (true) return mainExpression;}
2906    throw new Error("Missing return statement in function");
2907  }
2908
2909/**************************************************************************************
2910[82] GeneralComp ::= "=" | "!=" | "<" | "<=" | ">" | ">=" // gn: lt
2911**************************************************************************************/

2912  final public int GeneralComp() throws ParseException, TypeException, XQueryException {
2913        int kind = Constants.NOTHING;
2914    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2915    case OPERATOR_EQUAL:
2916      currentToken = jj_consume_token(OPERATOR_EQUAL);
2917                        kind = Constants.EQ_COMPOP;
2918      break;
2919    case OPERATOR_NOT_EQUAL:
2920      currentToken = jj_consume_token(OPERATOR_NOT_EQUAL);
2921                        kind = Constants.NEQ_COMPOP;
2922      break;
2923    case OPERATOR_LESS:
2924      currentToken = jj_consume_token(OPERATOR_LESS);
2925                        kind = Constants.LT_COMPOP;
2926      break;
2927    case OPERATOR_LESS_EQUAL:
2928      currentToken = jj_consume_token(OPERATOR_LESS_EQUAL);
2929                        kind = Constants.LEQ_COMPOP;
2930      break;
2931    case OPERATOR_GREATER:
2932      currentToken = jj_consume_token(OPERATOR_GREATER);
2933                        kind = Constants.GT_COMPOP;
2934      break;
2935    case OPERATOR_GREATER_EQUAL:
2936      currentToken = jj_consume_token(OPERATOR_GREATER_EQUAL);
2937                        kind = Constants.GEQ_COMPOP;
2938      break;
2939    default:
2940      jj_la1[89] = jj_gen;
2941      jj_consume_token(-1);
2942      throw new ParseException();
2943    }
2944                {if (true) return kind;}
2945    throw new Error("Missing return statement in function");
2946  }
2947
2948/**************************************************************************************
2949[83] ValueComp ::= "eq" | "ne" | "lt" | "le" | "gt" | "ge"
2950**************************************************************************************/

2951  final public int ValueComp() throws ParseException, TypeException, XQueryException {
2952        int kind = Constants.NOTHING;
2953    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2954    case OPERATOR_EQ:
2955      currentToken = jj_consume_token(OPERATOR_EQ);
2956                        kind = Constants.EQ_VALUECOMP;
2957      break;
2958    case OPERATOR_NE:
2959      currentToken = jj_consume_token(OPERATOR_NE);
2960                        kind = Constants.NE_VALUECOMP;
2961      break;
2962    case OPERATOR_LT:
2963      currentToken = jj_consume_token(OPERATOR_LT);
2964                        kind = Constants.LT_VALUECOMP;
2965      break;
2966    case OPERATOR_LE:
2967      currentToken = jj_consume_token(OPERATOR_LE);
2968                        kind = Constants.LE_VALUECOMP;
2969      break;
2970    case OPERATOR_GT:
2971      currentToken = jj_consume_token(OPERATOR_GT);
2972                        kind = Constants.GT_VALUECOMP;
2973      break;
2974    case OPERATOR_GE:
2975      currentToken = jj_consume_token(OPERATOR_GE);
2976                        kind = Constants.GE_VALUECOMP;
2977      break;
2978    default:
2979      jj_la1[90] = jj_gen;
2980      jj_consume_token(-1);
2981      throw new ParseException();
2982    }
2983                {if (true) return kind;}
2984    throw new Error("Missing return statement in function");
2985  }
2986
2987/**************************************************************************************
2988[84] NodeComp ::= "is" | "<<" | ">>"
2989**************************************************************************************/

2990  final public int NodeComp() throws ParseException, TypeException, XQueryException {
2991        int kind = Constants.NOTHING;
2992    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
2993    case OPERATOR_IS:
2994      currentToken = jj_consume_token(OPERATOR_IS);
2995                        kind = Constants.IS_NODECOMP;
2996      break;
2997    case OPERATOR_LESS_LESS:
2998      currentToken = jj_consume_token(OPERATOR_LESS_LESS);
2999                        kind = Constants.LEAST_NODECOMP;
3000      break;
3001    case OPERATOR_GREATER_GREATER:
3002      currentToken = jj_consume_token(OPERATOR_GREATER_GREATER);
3003                        kind = Constants.GREATEST_NODECOMP;
3004      break;
3005    default:
3006      jj_la1[91] = jj_gen;
3007      jj_consume_token(-1);
3008      throw new ParseException();
3009    }
3010                {if (true) return kind;}
3011    throw new Error("Missing return statement in function");
3012  }
3013
3014/**************************************************************************************
3015[62] RangeExpr ::= AdditiveExpr ( "to" AdditiveExpr )?
3016**************************************************************************************/

3017  final public XQueryExpression RangeExpr() throws ParseException, TypeException, XQueryException {
3018        XQueryExpression mainExpression = null;
3019        XQueryExpression expression = null;
3020        XQueryExpression rangeExpr = null;
3021    mainExpression = AdditiveExpr();
3022    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3023    case OPERATOR_TO:
3024      currentToken = jj_consume_token(OPERATOR_TO);
3025                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". RangeExpr is not supported yet.");}
3026      expression = AdditiveExpr();
3027                                try
3028                                {
3029                                        rangeExpr = factory.createRangeExpression(mainExpression, expression, parentModule);
3030                                }
3031                                catch (TypeException te)
3032                                {
3033                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3034                                }
3035                                mainExpression = rangeExpr;
3036      break;
3037    default:
3038      jj_la1[92] = jj_gen;
3039      ;
3040    }
3041                {if (true) return mainExpression;}
3042    throw new Error("Missing return statement in function");
3043  }
3044
3045/**************************************************************************************
3046[63] AdditiveExpr ::= MultiplicativeExpr ( ("+" | "-") MultiplicativeExpr )*
3047**************************************************************************************/

3048  final public XQueryExpression AdditiveExpr() throws ParseException, TypeException, XQueryException {
3049        int kind = Constants.NOTHING;
3050        XQueryExpression mainExpression = null;
3051        XQueryExpression expression = null;
3052        ListOpArithExpression listOpArithExpression = null;
3053    mainExpression = MultiplicativeExpr();
3054    label_13:
3055    while (true) {
3056      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3057      case MINUS:
3058      case PLUS:
3059        ;
3060        break;
3061      default:
3062        jj_la1[93] = jj_gen;
3063        break label_13;
3064      }
3065      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3066      case PLUS:
3067        currentToken = jj_consume_token(PLUS);
3068                                        kind = Constants.PLUS_ARITHMETICS;
3069        break;
3070      case MINUS:
3071        currentToken = jj_consume_token(MINUS);
3072                                        kind = Constants.MINUS_ARITHMETICS;
3073        break;
3074      default:
3075        jj_la1[94] = jj_gen;
3076        jj_consume_token(-1);
3077        throw new ParseException();
3078      }
3079      expression = MultiplicativeExpr();
3080                                try
3081                                {
3082                                        listOpArithExpression = factory.createListOpArithExpression(mainExpression, expression, kind, parentModule);
3083                                }
3084                                catch (TypeException te)
3085                                {
3086                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3087                                }
3088                                mainExpression = listOpArithExpression;
3089    }
3090                {if (true) return mainExpression;}
3091    throw new Error("Missing return statement in function");
3092  }
3093
3094/**************************************************************************************
3095[64] MultiplicativeExpr ::= UnaryExpr ( ("*" | "div" | "idiv" | "mod") UnaryExpr )*
3096**************************************************************************************/

3097  final public XQueryExpression MultiplicativeExpr() throws ParseException, TypeException, XQueryException {
3098        int kind = Constants.NOTHING;
3099        XQueryExpression mainExpression = null;
3100        XQueryExpression expression = null;
3101        ListOpArithExpression listOpArithExpression = null;
3102    mainExpression = UnaryExpr();
3103    label_14:
3104    while (true) {
3105      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3106      case OPERATOR_DIV:
3107      case OPERATOR_IDIV:
3108      case OPERATOR_MOD:
3109      case OPERATOR_STAR:
3110        ;
3111        break;
3112      default:
3113        jj_la1[95] = jj_gen;
3114        break label_14;
3115      }
3116      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3117      case OPERATOR_STAR:
3118        currentToken = jj_consume_token(OPERATOR_STAR);
3119                                        kind = Constants.MULTIPLY_ARITHMETICS;
3120        break;
3121      case OPERATOR_DIV:
3122        currentToken = jj_consume_token(OPERATOR_DIV);
3123                                        kind = Constants.DIVIDE_ARITHMETICS;
3124        break;
3125      case OPERATOR_IDIV:
3126        currentToken = jj_consume_token(OPERATOR_IDIV);
3127                                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". Integer division is not supported yet.");}
3128                                        kind = Constants.INTEGER_DIVIDE_ARITHMETICS;
3129        break;
3130      case OPERATOR_MOD:
3131        currentToken = jj_consume_token(OPERATOR_MOD);
3132                                        kind = Constants.MODULO_ARITHMETICS;
3133        break;
3134      default:
3135        jj_la1[96] = jj_gen;
3136        jj_consume_token(-1);
3137        throw new ParseException();
3138      }
3139      expression = UnaryExpr();
3140                                try
3141                                {
3142                                        listOpArithExpression = factory.createListOpArithExpression(mainExpression, expression, kind, parentModule);
3143                                }
3144                                catch (TypeException te)
3145                                {
3146                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3147                                }
3148                                mainExpression = listOpArithExpression;
3149    }
3150                {if (true) return mainExpression;}
3151    throw new Error("Missing return statement in function");
3152  }
3153
3154/**************************************************************************************
3155[65] UnaryExpr ::= ("-" | "+")* UnionExpr
3156**************************************************************************************/

3157  final public XQueryExpression UnaryExpr() throws ParseException, TypeException, XQueryException {
3158        XQueryExpression expression = null;
3159        boolean minus = false;
3160        boolean hasSign = false;
3161    label_15:
3162    while (true) {
3163      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3164      case MINUS:
3165      case PLUS:
3166        ;
3167        break;
3168      default:
3169        jj_la1[97] = jj_gen;
3170        break label_15;
3171      }
3172      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3173      case MINUS:
3174        currentToken = jj_consume_token(MINUS);
3175                                hasSign = true;
3176                                minus = true;
3177        break;
3178      case PLUS:
3179        currentToken = jj_consume_token(PLUS);
3180                                hasSign = true;
3181        break;
3182      default:
3183        jj_la1[98] = jj_gen;
3184        jj_consume_token(-1);
3185        throw new ParseException();
3186      }
3187    }
3188    expression = UnionExpr();
3189                if (hasSign)
3190                {
3191                        try
3192                        {
3193                                {if (true) return factory.createUnOpMinusExpression(expression, minus, parentModule);}
3194                        }
3195                        catch (TypeException te)
3196                        {
3197                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3198                        }
3199                }
3200                {if (true) return expression;}
3201    throw new Error("Missing return statement in function");
3202  }
3203
3204/**************************************************************************************
3205[66] UnionExpr ::= IntersectExceptExpr ( ("union" | "|") IntersectExceptExpr )*
3206**************************************************************************************/

3207  final public XQueryExpression UnionExpr() throws ParseException, TypeException, XQueryException {
3208        XQueryExpression mainExpression = null;
3209        XQueryExpression expression = null;
3210        ListOpUNIONExpression listOpUNIONExpression = null;
3211    mainExpression = IntersectExceptExpr();
3212    label_16:
3213    while (true) {
3214      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3215      case OPERATOR_UNION:
3216      case OPERATOR_BAR:
3217        ;
3218        break;
3219      default:
3220        jj_la1[99] = jj_gen;
3221        break label_16;
3222      }
3223      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3224      case OPERATOR_UNION:
3225        currentToken = jj_consume_token(OPERATOR_UNION);
3226        break;
3227      case OPERATOR_BAR:
3228        currentToken = jj_consume_token(OPERATOR_BAR);
3229        break;
3230      default:
3231        jj_la1[100] = jj_gen;
3232        jj_consume_token(-1);
3233        throw new ParseException();
3234      }
3235                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". UnionExpr is not supported yet.");}
3236      expression = IntersectExceptExpr();
3237                                try
3238                                {
3239                                        listOpUNIONExpression = factory.createListOpUNIONExpression(mainExpression, expression, parentModule);
3240                                }
3241                                catch (TypeException te)
3242                                {
3243                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3244                                }
3245                                mainExpression = listOpUNIONExpression;
3246    }
3247                {if (true) return mainExpression;}
3248    throw new Error("Missing return statement in function");
3249  }
3250
3251/**************************************************************************************
3252[67] IntersectExceptExpr ::= ValueExpr ( ("intersect" | "except") ValueExpr )*
3253**************************************************************************************/

3254  final public XQueryExpression IntersectExceptExpr() throws ParseException, TypeException, XQueryException {
3255        XQueryExpression mainExpression = null;
3256        XQueryExpression expression = null;
3257        XQueryExpression resultExpression = null;
3258        boolean kind = false;
3259    mainExpression = ValueExpr();
3260    label_17:
3261    while (true) {
3262      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3263      case OPERATOR_EXCEPT:
3264      case OPERATOR_INTERSECT:
3265        ;
3266        break;
3267      default:
3268        jj_la1[101] = jj_gen;
3269        break label_17;
3270      }
3271      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3272      case OPERATOR_INTERSECT:
3273        currentToken = jj_consume_token(OPERATOR_INTERSECT);
3274                                        kind = true;
3275        break;
3276      case OPERATOR_EXCEPT:
3277        currentToken = jj_consume_token(OPERATOR_EXCEPT);
3278        break;
3279      default:
3280        jj_la1[102] = jj_gen;
3281        jj_consume_token(-1);
3282        throw new ParseException();
3283      }
3284                                if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". IntersectExceptExpr is not supported yet.");}
3285      expression = ValueExpr();
3286                                try
3287                                {
3288                                        if (kind)
3289                                        {
3290                                                resultExpression = factory.createListOpINTERSECTExpression(mainExpression, expression, parentModule);
3291                                        }
3292                                        else
3293                                        {
3294                                                resultExpression = factory.createListOpEXCEPTExpression(mainExpression, expression, parentModule);
3295                                        }
3296                                }
3297                                catch (TypeException te)
3298                                {
3299                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3300                                }
3301                                mainExpression = resultExpression;
3302    }
3303                {if (true) return mainExpression;}
3304    throw new Error("Missing return statement in function");
3305  }
3306
3307/**************************************************************************************
3308[68] ValueExpr ::= ValidateExpr | PathExpr
3309**************************************************************************************/

3310  final public XQueryExpression ValueExpr() throws ParseException, TypeException, XQueryException {
3311        XQueryExpression expression = null;
3312    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3313    case VALIDATE_GLOBAL:
3314    case VALIDATE_CONTEXT:
3315    case VALIDATE_LAX:
3316    case VALIDATE_STRICT:
3317    case VALIDATE_SKIP:
3318    case VALIDATE_L_BRACE:
3319      expression = ValidateExpr();
3320                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". ValidateExpr is not supported yet.");}
3321      break;
3322    case ELEMENT_L_PAREN:
3323    case ATTRIBUTE_L_PAREN:
3324    case COMMENT_L_PAREN:
3325    case TEXT_L_PAREN:
3326    case NODE_L_PAREN:
3327    case DOCUMENT_NODE_L_PAREN:
3328    case PROCESSING_INSTRUCTION_L_PAREN:
3329    case STAR:
3330    case XMLCOMMENT_START:
3331    case XMLPROCESSING_START:
3332    case CDATA_START:
3333    case TAG_START:
3334    case ELEMENT_QNAME_L_BRACE:
3335    case ELEMENT_L_BRACE:
3336    case ATTRIBUTE_L_BRACE:
3337    case ATTRIBUTE_QNAME_L_BRACE:
3338    case NAMESPACE_NCNAME_L_BRACE:
3339    case DOCUMENT_L_BRACE:
3340    case TEXT_L_BRACE:
3341    case PROCESSING_INSTRUCTION_L_BRACE:
3342    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
3343    case COMMENT_L_BRACE:
3344    case AROBASE:
3345    case ANCESTOR_OR_SELF_DCOLON:
3346    case ANCESTOR_DCOLON:
3347    case ATTRIBUTE_DCOLON:
3348    case CHILD_DCOLON:
3349    case DESCENDANT_SELF_DCOLON:
3350    case DESCENDANT_DCOLON:
3351    case FOLLOWING_SIBLING_DCOLON:
3352    case FOLLOWING_DCOLON:
3353    case PARENT_DCOLON:
3354    case PRECEDING_SIBLING_DCOLON:
3355    case PRECEDING_DCOLON:
3356    case SELF_DCOLON:
3357    case QNAME_L_PAREN:
3358    case DOLLAR:
3359    case L_PAREN:
3360    case SLASH_SLASH:
3361    case SLASH:
3362    case DecimalLiteral:
3363    case DOTDOT:
3364    case DOT:
3365    case DoubleLiteral:
3366    case IntegerLiteral:
3367    case NCNAME_STAR:
3368    case STAR_NCNAME:
3369    case StringLiteral:
3370    case QNAME:
3371    case KINDTEST_ELEMENT_L_PAREN:
3372    case ELEMENT_CONTENT_ELT_LESS:
3373    case ELEMENT_CONTENT_XMLCOMMENT_START:
3374    case ELEMENT_CONTENT_XMLPROCESSING_START:
3375    case ELEMENT_CONTENT_CDATA_START:
3376      expression = PathExpr();
3377      break;
3378    default:
3379      jj_la1[103] = jj_gen;
3380      jj_consume_token(-1);
3381      throw new ParseException();
3382    }
3383                {if (true) return expression;}
3384    throw new Error("Missing return statement in function");
3385  }
3386
3387/**************************************************************************************
3388[78] ValidateExpr ::= (<"validate" "{"> | (<"validate" "global"> "{") | (<"validate" "context"> SchemaContextLoc "{") | (<"validate" SchemaMode> SchemaContext? "{")) Expr "}"
3389[79] SchemaContext ::= ("context" SchemaContextLoc) | "global"
3390**************************************************************************************/

3391  final public XQueryExpression ValidateExpr() throws ParseException, TypeException, XQueryException {
3392        XQueryExpression schemaContext = null;
3393        XQueryExpression validateExpression = null;
3394        SchemaContextPath scp = null;
3395        int validation_type = Constants.NOTHING;
3396        int scope_type = Constants.NOTHING;
3397    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3398    case VALIDATE_L_BRACE:
3399      currentToken = jj_consume_token(VALIDATE_L_BRACE);
3400      break;
3401    case VALIDATE_GLOBAL:
3402    case VALIDATE_CONTEXT:
3403    case VALIDATE_LAX:
3404    case VALIDATE_STRICT:
3405    case VALIDATE_SKIP:
3406      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3407      case VALIDATE_GLOBAL:
3408        currentToken = jj_consume_token(VALIDATE_GLOBAL);
3409                                                scope_type = Constants.SCOPE_GLOBAL;
3410        break;
3411      case VALIDATE_CONTEXT:
3412        currentToken = jj_consume_token(VALIDATE_CONTEXT);
3413                                                        scope_type = Constants.SCOPE_CONTEXT;
3414        scp = SchemaContextLoc();
3415        break;
3416      case VALIDATE_LAX:
3417      case VALIDATE_STRICT:
3418      case VALIDATE_SKIP:
3419        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3420        case VALIDATE_LAX:
3421          currentToken = jj_consume_token(VALIDATE_LAX);
3422                                                                validation_type = Constants.VALIDATION_LAX;
3423          break;
3424        case VALIDATE_STRICT:
3425          currentToken = jj_consume_token(VALIDATE_STRICT);
3426                                                                validation_type = Constants.VALIDATION_STRICT;
3427          break;
3428        case VALIDATE_SKIP:
3429          currentToken = jj_consume_token(VALIDATE_SKIP);
3430                                                                validation_type = Constants.VALIDATION_SKIP;
3431          break;
3432        default:
3433          jj_la1[104] = jj_gen;
3434          jj_consume_token(-1);
3435          throw new ParseException();
3436        }
3437        SchemaMode();
3438        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3439        case KINDTEST_CONTEXT:
3440        case KINDTEST_GLOBAL:
3441          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3442          case KINDTEST_CONTEXT:
3443            jj_consume_token(KINDTEST_CONTEXT);
3444                                                                        scope_type = Constants.SCOPE_CONTEXT;
3445            scp = SchemaContextLoc();
3446            break;
3447          case KINDTEST_GLOBAL:
3448            jj_consume_token(KINDTEST_GLOBAL);
3449                                                                scope_type = Constants.SCOPE_GLOBAL;
3450            break;
3451          default:
3452            jj_la1[105] = jj_gen;
3453            jj_consume_token(-1);
3454            throw new ParseException();
3455          }
3456          break;
3457        default:
3458          jj_la1[106] = jj_gen;
3459          ;
3460        }
3461        break;
3462      default:
3463        jj_la1[107] = jj_gen;
3464        jj_consume_token(-1);
3465        throw new ParseException();
3466      }
3467      currentToken = jj_consume_token(L_BRACE);
3468      break;
3469    default:
3470      jj_la1[108] = jj_gen;
3471      jj_consume_token(-1);
3472      throw new ParseException();
3473    }
3474    validateExpression = Expr(false);
3475    currentToken = jj_consume_token(R_BRACE);
3476                try
3477                {
3478                        {if (true) return factory.createValidateExpression(scope_type, validation_type, scp, validateExpression, parentModule);}
3479                }
3480                catch (TypeException te)
3481                {
3482                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3483                }
3484    throw new Error("Missing return statement in function");
3485  }
3486
3487/**************************************************************************************
3488[69] PathExpr ::= ("/" RelativePathExpr?) | ("//" RelativePathExpr) | RelativePathExpr
3489**************************************************************************************/

3490  final public XQueryExpression PathExpr() throws ParseException, TypeException, XQueryException {
3491        boolean separator = false;
3492        Step step = null;
3493        NodeTest nodeType = null;
3494        ArrayList tmpSteps = null;
3495        ArrayList resSteps = new ArrayList();
3496    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3497    case SLASH:
3498      currentToken = jj_consume_token(SLASH);
3499                                separator = true;
3500      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3501      case ELEMENT_L_PAREN:
3502      case ATTRIBUTE_L_PAREN:
3503      case COMMENT_L_PAREN:
3504      case TEXT_L_PAREN:
3505      case NODE_L_PAREN:
3506      case DOCUMENT_NODE_L_PAREN:
3507      case PROCESSING_INSTRUCTION_L_PAREN:
3508      case STAR:
3509      case XMLCOMMENT_START:
3510      case XMLPROCESSING_START:
3511      case CDATA_START:
3512      case TAG_START:
3513      case ELEMENT_QNAME_L_BRACE:
3514      case ELEMENT_L_BRACE:
3515      case ATTRIBUTE_L_BRACE:
3516      case ATTRIBUTE_QNAME_L_BRACE:
3517      case NAMESPACE_NCNAME_L_BRACE:
3518      case DOCUMENT_L_BRACE:
3519      case TEXT_L_BRACE:
3520      case PROCESSING_INSTRUCTION_L_BRACE:
3521      case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
3522      case COMMENT_L_BRACE:
3523      case AROBASE:
3524      case ANCESTOR_OR_SELF_DCOLON:
3525      case ANCESTOR_DCOLON:
3526      case ATTRIBUTE_DCOLON:
3527      case CHILD_DCOLON:
3528      case DESCENDANT_SELF_DCOLON:
3529      case DESCENDANT_DCOLON:
3530      case FOLLOWING_SIBLING_DCOLON:
3531      case FOLLOWING_DCOLON:
3532      case PARENT_DCOLON:
3533      case PRECEDING_SIBLING_DCOLON:
3534      case PRECEDING_DCOLON:
3535      case SELF_DCOLON:
3536      case QNAME_L_PAREN:
3537      case DOLLAR:
3538      case L_PAREN:
3539      case DecimalLiteral:
3540      case DOTDOT:
3541      case DOT:
3542      case DoubleLiteral:
3543      case IntegerLiteral:
3544      case NCNAME_STAR:
3545      case STAR_NCNAME:
3546      case StringLiteral:
3547      case QNAME:
3548      case KINDTEST_ELEMENT_L_PAREN:
3549      case ELEMENT_CONTENT_ELT_LESS:
3550      case ELEMENT_CONTENT_XMLCOMMENT_START:
3551      case ELEMENT_CONTENT_XMLPROCESSING_START:
3552      case ELEMENT_CONTENT_CDATA_START:
3553        tmpSteps = RelativePathExpr(separator);
3554                                        if (tmpSteps != null) resSteps.addAll(tmpSteps);
3555        break;
3556      default:
3557        jj_la1[109] = jj_gen;
3558        ;
3559      }
3560                                if (tmpSteps == null)
3561                                {
3562                                        try
3563                                        {
3564                                                nodeType = factory.createNodeTest(NodeKind.NODE, null, parentModule);
3565                                                step = factory.createStep(separator, Axis.CHILD, nodeType, null, parentModule);
3566                                                resSteps.add(step);
3567                                        }
3568                                        catch (TypeException te)
3569                                        {
3570                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3571                                        }
3572                                }
3573      break;
3574    case SLASH_SLASH:
3575      currentToken = jj_consume_token(SLASH_SLASH);
3576                                separator = true;
3577                                try
3578                                {
3579                                        nodeType = factory.createNodeTest(NodeKind.NODE, null, parentModule);
3580                                        step = factory.createStep(separator, Axis.DESCENDANT_OR_SELF, nodeType, null, parentModule);
3581                                        resSteps.add(step);
3582                                }
3583                                catch (TypeException te)
3584                                {
3585                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3586                                }
3587      tmpSteps = RelativePathExpr(separator);
3588                                resSteps.addAll(tmpSteps);
3589      break;
3590    case ELEMENT_L_PAREN:
3591    case ATTRIBUTE_L_PAREN:
3592    case COMMENT_L_PAREN:
3593    case TEXT_L_PAREN:
3594    case NODE_L_PAREN:
3595    case DOCUMENT_NODE_L_PAREN:
3596    case PROCESSING_INSTRUCTION_L_PAREN:
3597    case STAR:
3598    case XMLCOMMENT_START:
3599    case XMLPROCESSING_START:
3600    case CDATA_START:
3601    case TAG_START:
3602    case ELEMENT_QNAME_L_BRACE:
3603    case ELEMENT_L_BRACE:
3604    case ATTRIBUTE_L_BRACE:
3605    case ATTRIBUTE_QNAME_L_BRACE:
3606    case NAMESPACE_NCNAME_L_BRACE:
3607    case DOCUMENT_L_BRACE:
3608    case TEXT_L_BRACE:
3609    case PROCESSING_INSTRUCTION_L_BRACE:
3610    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
3611    case COMMENT_L_BRACE:
3612    case AROBASE:
3613    case ANCESTOR_OR_SELF_DCOLON:
3614    case ANCESTOR_DCOLON:
3615    case ATTRIBUTE_DCOLON:
3616    case CHILD_DCOLON:
3617    case DESCENDANT_SELF_DCOLON:
3618    case DESCENDANT_DCOLON:
3619    case FOLLOWING_SIBLING_DCOLON:
3620    case FOLLOWING_DCOLON:
3621    case PARENT_DCOLON:
3622    case PRECEDING_SIBLING_DCOLON:
3623    case PRECEDING_DCOLON:
3624    case SELF_DCOLON:
3625    case QNAME_L_PAREN:
3626    case DOLLAR:
3627    case L_PAREN:
3628    case DecimalLiteral:
3629    case DOTDOT:
3630    case DOT:
3631    case DoubleLiteral:
3632    case IntegerLiteral:
3633    case NCNAME_STAR:
3634    case STAR_NCNAME:
3635    case StringLiteral:
3636    case QNAME:
3637    case KINDTEST_ELEMENT_L_PAREN:
3638    case ELEMENT_CONTENT_ELT_LESS:
3639    case ELEMENT_CONTENT_XMLCOMMENT_START:
3640    case ELEMENT_CONTENT_XMLPROCESSING_START:
3641    case ELEMENT_CONTENT_CDATA_START:
3642      tmpSteps = RelativePathExpr(false);
3643                                separator = false;
3644                                resSteps.addAll(tmpSteps);
3645      break;
3646    default:
3647      jj_la1[110] = jj_gen;
3648      jj_consume_token(-1);
3649      throw new ParseException();
3650    }
3651                XQueryExpression expr = (XQueryExpression) resSteps.get(0);
3652                if (resSteps.size() == 1 && !(expr instanceof Step))
3653                        {if (true) return expr;}
3654                if (resSteps.size() != 1 && !(expr instanceof Step)) {
3655                        resSteps.set(0,factory.createStep(separator, Axis.NONE, expr, null, parentModule));
3656                }
3657                /*
3658        if (!step.hasSeparator() && step.getAxis() == Axis.NONE && step.getPredicates() == null)
3659            {
3660                // remove step from parent !!!
3661                step.getExpression().getParentExpression().remove(step);
3662                return step.getExpression();
3663            }
3664        }
3665        */

3666                try {
3667                        if (LocatedExpressionReducer.simplifySteps(resSteps, inPredicate, parentModule) == 0)
3668                                {if (true) throw new TypeException("steps of LocatedExpression are not valid", currentToken.beginLine, currentToken.beginColumn);}
3669                }
3670                catch (NormalizeException ne) {
3671                        {if (true) throw new TypeException(ne.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3672                }
3673                try
3674                {
3675                        {if (true) return factory.createLocatedExpression(resSteps, inPredicate, parentModule);}
3676                }
3677                catch (TypeException te)
3678                {
3679                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3680                }
3681    throw new Error("Missing return statement in function");
3682  }
3683
3684/**************************************************************************************
3685[70] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)*
3686**************************************************************************************/

3687  final public ArrayList RelativePathExpr(boolean separator) throws ParseException, TypeException, XQueryException {
3688        XQueryExpression step = null;
3689        ArrayList steps = new ArrayList();
3690        NodeTest nodeType = null;
3691    step = StepExpr(separator, true);
3692                                steps.add(step);
3693    label_18:
3694    while (true) {
3695      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3696      case SLASH_SLASH:
3697      case SLASH:
3698        ;
3699        break;
3700      default:
3701        jj_la1[111] = jj_gen;
3702        break label_18;
3703      }
3704      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3705      case SLASH:
3706        currentToken = jj_consume_token(SLASH);
3707                                        separator = true;
3708        break;
3709      case SLASH_SLASH:
3710        currentToken = jj_consume_token(SLASH_SLASH);
3711                                        separator = true;
3712                                        try
3713                                        {
3714                                                nodeType = factory.createNodeTest(NodeKind.NODE, null, parentModule);
3715                                                step = factory.createStep(separator, Axis.DESCENDANT_OR_SELF, nodeType, null, parentModule);
3716                                                steps.add(step);
3717                                        }
3718                                        catch (TypeException te)
3719                                        {
3720                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3721                                        }
3722        break;
3723      default:
3724        jj_la1[112] = jj_gen;
3725        jj_consume_token(-1);
3726        throw new ParseException();
3727      }
3728      step = StepExpr(separator, false);
3729                                steps.add(step);
3730    }
3731                {if (true) return steps;}
3732    throw new Error("Missing return statement in function");
3733  }
3734
3735/**************************************************************************************
3736[71] StepExpr ::= AxisStep | FilterStep
3737[72] AxisStep ::= (ForwardStep | ReverseStep) Predicates
3738[73] FilterStep ::= PrimaryExpr Predicates
3739
3740**************************************************************************************/

3741  final public XQueryExpression StepExpr(boolean separator, boolean isFirst) throws ParseException, TypeException, XQueryException {
3742        XQueryExpression step = null;
3743        ArrayList predicates = new ArrayList();
3744    if (jj_2_6(4)) {
3745      step = PrimaryExpr(isFirst);
3746    } else {
3747      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3748      case ELEMENT_L_PAREN:
3749      case ATTRIBUTE_L_PAREN:
3750      case COMMENT_L_PAREN:
3751      case TEXT_L_PAREN:
3752      case NODE_L_PAREN:
3753      case DOCUMENT_NODE_L_PAREN:
3754      case PROCESSING_INSTRUCTION_L_PAREN:
3755      case STAR:
3756      case AROBASE:
3757      case ATTRIBUTE_DCOLON:
3758      case CHILD_DCOLON:
3759      case DESCENDANT_SELF_DCOLON:
3760      case DESCENDANT_DCOLON:
3761      case FOLLOWING_SIBLING_DCOLON:
3762      case FOLLOWING_DCOLON:
3763      case SELF_DCOLON:
3764      case NCNAME_STAR:
3765      case STAR_NCNAME:
3766      case QNAME:
3767      case KINDTEST_ELEMENT_L_PAREN:
3768        step = ForwardStep(separator);
3769        break;
3770      case ANCESTOR_OR_SELF_DCOLON:
3771      case ANCESTOR_DCOLON:
3772      case PARENT_DCOLON:
3773      case PRECEDING_SIBLING_DCOLON:
3774      case PRECEDING_DCOLON:
3775      case DOTDOT:
3776        step = ReverseStep(separator);
3777        break;
3778      default:
3779        jj_la1[113] = jj_gen;
3780        jj_consume_token(-1);
3781        throw new ParseException();
3782      }
3783    }
3784    predicates = Predicates();
3785                if (predicates != null)
3786                {
3787                        if (!(step instanceof Step))
3788                                step = factory.createStep(separator, Axis.NONE, step, predicates, parentModule);
3789                        else
3790                                ((Step)step).setPredicates(predicates);
3791                        if (staticcontext.getTypeVisitor() != null) step.accept(staticcontext.getTypeVisitor());
3792                }
3793                {if (true) return step;}
3794    throw new Error("Missing return statement in function");
3795  }
3796
3797/**************************************************************************************
3798[75] PrimaryExpr ::= Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall | Constructor
3799[74] ContextItemExpr ::= "."
3800[76] VarRef ::= "$" VarName
3801**************************************************************************************/

3802  final public XQueryExpression PrimaryExpr(boolean isFirst) throws ParseException, TypeException, XQueryException {
3803        byte axis = Axis.NONE;
3804        XQueryExpression expression = null;
3805        boolean separator = true;
3806    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3807    case DecimalLiteral:
3808    case DoubleLiteral:
3809    case IntegerLiteral:
3810    case StringLiteral:
3811      expression = Literal();
3812      break;
3813    case DOLLAR:
3814      currentToken = jj_consume_token(DOLLAR);
3815      currentToken = jj_consume_token(VARNAME_QNAME);
3816                                expression = VarName(currentToken.image,false);
3817      break;
3818    case L_PAREN:
3819      expression = ParenthesizedExpr();
3820      break;
3821    case DOT:
3822      currentToken = jj_consume_token(DOT);
3823                        try
3824                        {
3825                                expression = factory.createNodeTest(NodeKind.NODE, null, parentModule);
3826                        }
3827                        catch (TypeException te)
3828                        {
3829                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3830                        }
3831                        if (isFirst) {
3832                                isFirst = false;
3833                                separator = false;
3834                        }
3835                        axis = Axis.SELF;
3836      break;
3837    case QNAME_L_PAREN:
3838      expression = FunctionCall();
3839      break;
3840    case XMLCOMMENT_START:
3841    case XMLPROCESSING_START:
3842    case CDATA_START:
3843    case TAG_START:
3844    case ELEMENT_QNAME_L_BRACE:
3845    case ELEMENT_L_BRACE:
3846    case ATTRIBUTE_L_BRACE:
3847    case ATTRIBUTE_QNAME_L_BRACE:
3848    case NAMESPACE_NCNAME_L_BRACE:
3849    case DOCUMENT_L_BRACE:
3850    case TEXT_L_BRACE:
3851    case PROCESSING_INSTRUCTION_L_BRACE:
3852    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
3853    case COMMENT_L_BRACE:
3854    case ELEMENT_CONTENT_ELT_LESS:
3855    case ELEMENT_CONTENT_XMLCOMMENT_START:
3856    case ELEMENT_CONTENT_XMLPROCESSING_START:
3857    case ELEMENT_CONTENT_CDATA_START:
3858      expression = Constructor();
3859      break;
3860    default:
3861      jj_la1[114] = jj_gen;
3862      jj_consume_token(-1);
3863      throw new ParseException();
3864    }
3865                if (!isFirst) {
3866                        if (separator && axis == Axis.NONE)
3867                        {
3868                                axis = Axis.CHILD;
3869                        }
3870                        try
3871                        {
3872                                Step step = factory.createStep(separator, axis, expression, null, parentModule);
3873                                if (expression.getParenthesis()) step.setParenthesis(true);
3874                                {if (true) return step;}
3875                        }
3876                        catch (TypeException te)
3877                        {
3878                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3879                        }
3880                }
3881                {if (true) return expression;}
3882    throw new Error("Missing return statement in function");
3883  }
3884
3885/**************************************************************************************
3886[85] ForwardStep ::= (ForwardAxis NodeTest) | AbbrevForwardStep
3887**************************************************************************************/

3888  final public Step ForwardStep(boolean separator) throws ParseException, TypeException, XQueryException {
3889        byte axis = Axis.NONE;
3890        XQueryExpression expression = null;
3891        Step step = null;
3892    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3893    case ELEMENT_L_PAREN:
3894    case ATTRIBUTE_L_PAREN:
3895    case COMMENT_L_PAREN:
3896    case TEXT_L_PAREN:
3897    case NODE_L_PAREN:
3898    case DOCUMENT_NODE_L_PAREN:
3899    case PROCESSING_INSTRUCTION_L_PAREN:
3900    case STAR:
3901    case AROBASE:
3902    case NCNAME_STAR:
3903    case STAR_NCNAME:
3904    case QNAME:
3905    case KINDTEST_ELEMENT_L_PAREN:
3906      step = AbbrevForwardStep(separator);
3907      break;
3908    case ATTRIBUTE_DCOLON:
3909    case CHILD_DCOLON:
3910    case DESCENDANT_SELF_DCOLON:
3911    case DESCENDANT_DCOLON:
3912    case FOLLOWING_SIBLING_DCOLON:
3913    case FOLLOWING_DCOLON:
3914    case SELF_DCOLON:
3915      axis = ForwardAxis();
3916      expression = NodeTest();
3917                                try
3918                                {
3919                                        if (axis == Axis.ATTRIBUTE && defaultElementNameSpace != null && expression instanceof QName) ((QName) expression).setNameSpace(null);
3920                                        step = factory.createStep(separator, axis, expression, null, parentModule);
3921                                }
3922                                catch (TypeException te)
3923                                {
3924                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3925                                }
3926      break;
3927    default:
3928      jj_la1[115] = jj_gen;
3929      jj_consume_token(-1);
3930      throw new ParseException();
3931    }
3932                {if (true) return step;}
3933    throw new Error("Missing return statement in function");
3934  }
3935
3936/***************************************************************************************
3937[87] AbbrevForwardStep ::= "@"? NodeTest
3938***************************************************************************************/

3939  final public Step AbbrevForwardStep(boolean separator) throws ParseException, TypeException, XQueryException {
3940        XQueryExpression expression = null;
3941        byte axis = Axis.NONE;
3942        if (separator)
3943        {
3944                axis = Axis.CHILD;
3945        }
3946    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3947    case AROBASE:
3948      currentToken = jj_consume_token(AROBASE);
3949                                axis = Axis.ATTRIBUTE;
3950      break;
3951    default:
3952      jj_la1[116] = jj_gen;
3953      ;
3954    }
3955    expression = NodeTest();
3956                try
3957                {
3958                        if (axis == Axis.ATTRIBUTE && defaultElementNameSpace != null && expression instanceof QName) ((QName) expression).setNameSpace(null);
3959                        {if (true) return factory.createStep(separator, axis, expression, null, parentModule);}
3960                }
3961                catch (TypeException te)
3962                {
3963                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
3964                }
3965    throw new Error("Missing return statement in function");
3966  }
3967
3968/***************************************************************************************
3969[89] ForwardAxis ::= <"child" "::"> | <"descendant" "::"> | <"attribute" "::"> | <"self" "::"> | <"descendant-or-self" "::"> | <"following-sibling" "::"> | <"following" "::">
3970***************************************************************************************/

3971  final public byte ForwardAxis() throws ParseException, TypeException, XQueryException {
3972        byte axis = Axis.NONE;
3973    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
3974    case CHILD_DCOLON:
3975      currentToken = jj_consume_token(CHILD_DCOLON);
3976                        axis = Axis.CHILD;
3977      break;
3978    case DESCENDANT_DCOLON:
3979      currentToken = jj_consume_token(DESCENDANT_DCOLON);
3980                        axis = Axis.DESCENDANT;
3981      break;
3982    case ATTRIBUTE_DCOLON:
3983      currentToken = jj_consume_token(ATTRIBUTE_DCOLON);
3984                        axis = Axis.ATTRIBUTE;
3985      break;
3986    case SELF_DCOLON:
3987      currentToken = jj_consume_token(SELF_DCOLON);
3988                        axis = Axis.SELF;
3989      break;
3990    case DESCENDANT_SELF_DCOLON:
3991      currentToken = jj_consume_token(DESCENDANT_SELF_DCOLON);
3992                        axis = Axis.DESCENDANT_OR_SELF;
3993      break;
3994    case FOLLOWING_SIBLING_DCOLON:
3995      currentToken = jj_consume_token(FOLLOWING_SIBLING_DCOLON);
3996                        axis = Axis.FOLLOWING_SIBLING;
3997                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'following-sibling' axis is not supported yet.");}
3998      break;
3999    case FOLLOWING_DCOLON:
4000      currentToken = jj_consume_token(FOLLOWING_DCOLON);
4001                        axis = Axis.FOLLOWING;
4002                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'following' axis is not supported yet.");}
4003      break;
4004    default:
4005      jj_la1[117] = jj_gen;
4006      jj_consume_token(-1);
4007      throw new ParseException();
4008    }
4009                {if (true) return axis;}
4010    throw new Error("Missing return statement in function");
4011  }
4012
4013/**************************************************************************************
4014[86] ReverseStep ::= (ReverseAxis NodeTest) | AbbrevReverseStep
4015**************************************************************************************/

4016  final public Step ReverseStep(boolean separator) throws ParseException, TypeException, XQueryException {
4017        byte axis = Axis.NONE;
4018        XQueryExpression expression = null;
4019        Step step = null;
4020    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4021    case DOTDOT:
4022      step = AbbrevReverseStep(separator);
4023      break;
4024    case ANCESTOR_OR_SELF_DCOLON:
4025    case ANCESTOR_DCOLON:
4026    case PARENT_DCOLON:
4027    case PRECEDING_SIBLING_DCOLON:
4028    case PRECEDING_DCOLON:
4029      axis = ReverseAxis();
4030      expression = NodeTest();
4031                                try
4032                                {
4033                                        step = factory.createStep(separator, axis, expression, null, parentModule);
4034                                }
4035                                catch (TypeException te)
4036                                {
4037                                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4038                                }
4039      break;
4040    default:
4041      jj_la1[118] = jj_gen;
4042      jj_consume_token(-1);
4043      throw new ParseException();
4044    }
4045                {if (true) return step;}
4046    throw new Error("Missing return statement in function");
4047  }
4048
4049/***************************************************************************************
4050[88] AbbrevReverseStep ::= ".."
4051***************************************************************************************/

4052  final public Step AbbrevReverseStep(boolean separator) throws ParseException, TypeException, XQueryException {
4053        XQueryExpression expression = null;
4054        byte axis = Axis.NONE;
4055    currentToken = jj_consume_token(DOTDOT);
4056                        try
4057                        {
4058                                expression = factory.createNodeTest(NodeKind.NODE, null, parentModule);
4059                        }
4060                        catch (TypeException te)
4061                        {
4062                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4063                        }
4064                        axis = Axis.PARENT;
4065                try
4066                {
4067                        {if (true) return factory.createStep(separator, axis, expression, null, parentModule);}
4068                }
4069                catch (TypeException te)
4070                {
4071                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4072                }
4073    throw new Error("Missing return statement in function");
4074  }
4075
4076/***************************************************************************************
4077[90] ReverseAxis ::= <"parent" "::"> | <"ancestor" "::"> | <"preceding-sibling" "::"> | <"preceding" "::"> | <"ancestor-or-self" "::">
4078***************************************************************************************/

4079  final public byte ReverseAxis() throws ParseException, TypeException, XQueryException {
4080        byte axis = Axis.NONE;
4081    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4082    case PARENT_DCOLON:
4083      currentToken = jj_consume_token(PARENT_DCOLON);
4084                        axis = Axis.PARENT;
4085      break;
4086    case ANCESTOR_DCOLON:
4087      currentToken = jj_consume_token(ANCESTOR_DCOLON);
4088                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'ancestor' axis is not supported yet.");}
4089                        axis = Axis.ANCESTOR;
4090      break;
4091    case PRECEDING_SIBLING_DCOLON:
4092      currentToken = jj_consume_token(PRECEDING_SIBLING_DCOLON);
4093                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'preceding-sibling' axis is not supported yet.");}
4094                        axis = Axis.PRECEDING_SIBLING;
4095      break;
4096    case PRECEDING_DCOLON:
4097      currentToken = jj_consume_token(PRECEDING_DCOLON);
4098                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'preceding' axis is not supported yet.");}
4099                        axis = Axis.PRECEDING;
4100      break;
4101    case ANCESTOR_OR_SELF_DCOLON:
4102      currentToken = jj_consume_token(ANCESTOR_OR_SELF_DCOLON);
4103                        if (restriction) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". 'ancestor-or-self' axis is not supported yet.");}
4104                        axis = Axis.ANCESTOR_OR_SELF;
4105      break;
4106    default:
4107      jj_la1[119] = jj_gen;
4108      jj_consume_token(-1);
4109      throw new ParseException();
4110    }
4111                {if (true) return axis;}
4112    throw new Error("Missing return statement in function");
4113  }
4114
4115/***************************************************************************************
4116[91] NodeTest ::= KindTest | NameTest
4117***************************************************************************************/

4118  final public XQueryExpression NodeTest() throws ParseException, TypeException, XQueryException {
4119        XQueryExpression expression = null;
4120    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4121    case ELEMENT_L_PAREN:
4122    case ATTRIBUTE_L_PAREN:
4123    case COMMENT_L_PAREN:
4124    case TEXT_L_PAREN:
4125    case NODE_L_PAREN:
4126    case DOCUMENT_NODE_L_PAREN:
4127    case PROCESSING_INSTRUCTION_L_PAREN:
4128    case KINDTEST_ELEMENT_L_PAREN:
4129      expression = KindTest();
4130      break;
4131    case STAR:
4132    case NCNAME_STAR:
4133    case STAR_NCNAME:
4134    case QNAME:
4135      expression = NameTest();
4136      break;
4137    default:
4138      jj_la1[120] = jj_gen;
4139      jj_consume_token(-1);
4140      throw new ParseException();
4141    }
4142                {if (true) return expression;}
4143    throw new Error("Missing return statement in function");
4144  }
4145
4146/***************************************************************************************
4147[92] NameTest ::= QName | Wildcard
4148***************************************************************************************/

4149  final public QName NameTest() throws ParseException, TypeException, XQueryException {
4150        QName nameTest = null;
4151    if (jj_2_7(3)) {
4152      currentToken = jj_consume_token(QNAME);
4153                        nameTest = QName(currentToken.image);
4154    } else {
4155      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4156      case STAR:
4157      case NCNAME_STAR:
4158      case STAR_NCNAME:
4159        nameTest = Wildcard();
4160        break;
4161      default:
4162        jj_la1[121] = jj_gen;
4163        jj_consume_token(-1);
4164        throw new ParseException();
4165      }
4166    }
4167                {if (true) return nameTest;}
4168    throw new Error("Missing return statement in function");
4169  }
4170
4171/***************************************************************************************
4172[93] Wildcard ::= "*" | <NCName ":" "*"> | <"*" ":" NCName>
4173***************************************************************************************/

4174  final public QName Wildcard() throws ParseException, TypeException, XQueryException {
4175        String namespace = null;
4176        String prefixname = null;
4177        String localname = null;
4178    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4179    case STAR:
4180      currentToken = jj_consume_token(STAR);
4181                        localname = currentToken.image;
4182                        prefixname = currentToken.image;
4183      break;
4184    case NCNAME_STAR:
4185      currentToken = jj_consume_token(NCNAME_STAR);
4186                        localname = "*";
4187                        prefixname = currentToken.image.substring(0,currentToken.image.length()-2);
4188      break;
4189    case STAR_NCNAME:
4190      currentToken = jj_consume_token(STAR_NCNAME);
4191                        prefixname = "*";
4192                        localname = currentToken.image.substring(2);
4193      break;
4194    default:
4195      jj_la1[122] = jj_gen;
4196      jj_consume_token(-1);
4197      throw new ParseException();
4198    }
4199                try
4200                {
4201                        String tmpStr = null;
4202                        if (prefixname == null)
4203                        {
4204                                namespace = defaultElementNameSpace;
4205                        }
4206                        else if (prefixname.equals("*"))
4207                        {
4208                                namespace = prefixname;
4209                        }
4210                        else
4211                        {
4212                                tmpStr = getNameSpace(prefixname);
4213                                if (tmpStr == null)
4214                                {
4215                                        {if (true) throw new TypeException("Could not match prefix [ " + prefixname + " ]" , currentToken.beginLine, currentToken.beginColumn);}
4216                                }
4217                                namespace = tmpStr;
4218                        }
4219                        {if (true) return factory.createQName(namespace, prefixname, localname, parentModule, namespaceContextStack.getNamespaceContext());}
4220                }
4221                catch (TypeException te)
4222                {
4223                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4224                }
4225    throw new Error("Missing return statement in function");
4226  }
4227
4228/**************************************************************************************
4229[77] Predicates ::= ("[" Expr "]")*
4230LARS --> [77] Predicates ::= ("[" ExprSingle "]")*
4231**************************************************************************************/

4232  final public ArrayList Predicates() throws ParseException, TypeException, XQueryException {
4233        XQueryExpression expression = null;
4234        ArrayList predicates = null;
4235        boolean oldInPredicate = false;
4236    label_19:
4237    while (true) {
4238      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4239      case L_BRACKET:
4240        ;
4241        break;
4242      default:
4243        jj_la1[123] = jj_gen;
4244        break label_19;
4245      }
4246      currentToken = jj_consume_token(L_BRACKET);
4247                                oldInPredicate = inPredicate;
4248                                inPredicate = true;
4249      expression = ExprSingle();
4250                                if (restriction && expression instanceof Value) {if (true) throw new ParseException("Encountered \"" + currentToken.image + "\" at line " + currentToken.beginLine + ", column " + currentToken.beginColumn + ". RangeExpr is not supported yet.");}
4251      currentToken = jj_consume_token(R_BRACKET);
4252                                inPredicate = oldInPredicate;
4253                        if (predicates == null)
4254                        {
4255                                predicates = new ArrayList(1);
4256                        }
4257                        //expression.setBracket(true);
4258
predicates.add(expression);
4259    }
4260                {if (true) return predicates;}
4261    throw new Error("Missing return statement in function");
4262  }
4263
4264/**************************************************************************************
4265[94] Literal ::= NumericLiteral | StringLiteral
4266**************************************************************************************/

4267  final public Value Literal() throws ParseException, TypeException, XQueryException {
4268        Value value = null;
4269        String stringLiteral;
4270    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4271    case DecimalLiteral:
4272    case DoubleLiteral:
4273    case IntegerLiteral:
4274      value = NumericLiteral();
4275      break;
4276    case StringLiteral:
4277      currentToken = jj_consume_token(StringLiteral);
4278                        stringLiteral = currentToken.image;
4279                        try
4280                        {
4281                                value = factory.createValueString(unquote(stringLiteral), parentModule);
4282                        }
4283                        catch (TypeException te)
4284                        {
4285                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4286                        }
4287      break;
4288    default:
4289      jj_la1[124] = jj_gen;
4290      jj_consume_token(-1);
4291      throw new ParseException();
4292    }
4293                {if (true) return value;}
4294    throw new Error("Missing return statement in function");
4295  }
4296
4297/***************************************************************************************
4298[95] NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral
4299***************************************************************************************/

4300  final public Value NumericLiteral() throws ParseException, TypeException, XQueryException {
4301    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4302    case IntegerLiteral:
4303      currentToken = jj_consume_token(IntegerLiteral);
4304                try
4305                {
4306                        {if (true) return factory.createValueInteger(currentToken.image, parentModule);}
4307                }
4308                catch (TypeException te)
4309                {
4310                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4311                }
4312      break;
4313    case DecimalLiteral:
4314      currentToken = jj_consume_token(DecimalLiteral);
4315                try
4316                {
4317                        {if (true) return factory.createValueDecimal(currentToken.image, parentModule);}
4318                }
4319                catch (TypeException te)
4320                {
4321                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4322                }
4323      break;
4324    case DoubleLiteral:
4325      currentToken = jj_consume_token(DoubleLiteral);
4326                try
4327                {
4328                        {if (true) return factory.createValueDouble(currentToken.image, parentModule);}
4329                }
4330                catch (TypeException te)
4331                {
4332                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4333                }
4334      break;
4335    default:
4336      jj_la1[125] = jj_gen;
4337      jj_consume_token(-1);
4338      throw new ParseException();
4339    }
4340    throw new Error("Missing return statement in function");
4341  }
4342
4343/***************************************************************************************
4344[96] ParenthesizedExpr ::= "(" Expr? ")"
4345***************************************************************************************/

4346  final public XQueryExpression ParenthesizedExpr() throws ParseException, TypeException, XQueryException {
4347        XQueryExpression expression = null;
4348    currentToken = jj_consume_token(L_PAREN);
4349    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4350    case ELEMENT_L_PAREN:
4351    case ATTRIBUTE_L_PAREN:
4352    case COMMENT_L_PAREN:
4353    case TEXT_L_PAREN:
4354    case NODE_L_PAREN:
4355    case DOCUMENT_NODE_L_PAREN:
4356    case PROCESSING_INSTRUCTION_L_PAREN:
4357    case STAR:
4358    case XMLCOMMENT_START:
4359    case XMLPROCESSING_START:
4360    case CDATA_START:
4361    case TAG_START:
4362    case VALIDATE_GLOBAL:
4363    case VALIDATE_CONTEXT:
4364    case VALIDATE_LAX:
4365    case VALIDATE_STRICT:
4366    case VALIDATE_SKIP:
4367    case ELEMENT_QNAME_L_BRACE:
4368    case ELEMENT_L_BRACE:
4369    case ATTRIBUTE_L_BRACE:
4370    case ATTRIBUTE_QNAME_L_BRACE:
4371    case NAMESPACE_NCNAME_L_BRACE:
4372    case DOCUMENT_L_BRACE:
4373    case TEXT_L_BRACE:
4374    case PROCESSING_INSTRUCTION_L_BRACE:
4375    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
4376    case COMMENT_L_BRACE:
4377    case AROBASE:
4378    case ANCESTOR_OR_SELF_DCOLON:
4379    case ANCESTOR_DCOLON:
4380    case ATTRIBUTE_DCOLON:
4381    case CHILD_DCOLON:
4382    case DESCENDANT_SELF_DCOLON:
4383    case DESCENDANT_DCOLON:
4384    case FOLLOWING_SIBLING_DCOLON:
4385    case FOLLOWING_DCOLON:
4386    case PARENT_DCOLON:
4387    case PRECEDING_SIBLING_DCOLON:
4388    case PRECEDING_DCOLON:
4389    case SELF_DCOLON:
4390    case IF_L_PAREN:
4391    case QNAME_L_PAREN:
4392    case DOLLAR:
4393    case FOR_$:
4394    case LET_$:
4395    case SOME_$:
4396    case EVERY_$:
4397    case VALIDATE_L_BRACE:
4398    case TYPESWITCH_L_PAREN:
4399    case L_PAREN:
4400    case MINUS:
4401    case PLUS:
4402    case SLASH_SLASH:
4403    case SLASH:
4404    case DecimalLiteral:
4405    case DOTDOT:
4406    case DOT:
4407    case DoubleLiteral:
4408    case IntegerLiteral:
4409    case NCNAME_STAR:
4410    case STAR_NCNAME:
4411    case StringLiteral:
4412    case QNAME:
4413    case KINDTEST_ELEMENT_L_PAREN:
4414    case ELEMENT_CONTENT_ELT_LESS:
4415    case ELEMENT_CONTENT_XMLCOMMENT_START:
4416    case ELEMENT_CONTENT_XMLPROCESSING_START:
4417    case ELEMENT_CONTENT_CDATA_START:
4418      expression = Expr(false);
4419      break;
4420    default:
4421      jj_la1[126] = jj_gen;
4422      ;
4423    }
4424    currentToken = jj_consume_token(R_PAREN);
4425                        if (expression == null)
4426                                expression = factory.createXQueryVoid(parentModule);
4427                        else
4428                                expression.setParenthesis(true);
4429                {if (true) return expression;}
4430    throw new Error("Missing return statement in function");
4431  }
4432
4433/***************************************************************************************
4434[97] FunctionCall ::= <QName "("> (ExprSingle ("," ExprSingle)*)? ")"
4435***************************************************************************************/

4436  final public XQueryExpression FunctionCall() throws ParseException, TypeException, XQueryException {
4437        QName funcName = null;
4438        XQueryExpression expression = null;
4439        XQueryExpressionSequence tmpExpr = null;
4440        ArrayList arguments = null;
4441    currentToken = jj_consume_token(QNAME_L_PAREN);
4442                        String tmpstr = extractName(currentToken.image,null,"(");
4443                        funcName = QName(tmpstr,true,true);
4444    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4445    case ELEMENT_L_PAREN:
4446    case ATTRIBUTE_L_PAREN:
4447    case COMMENT_L_PAREN:
4448    case TEXT_L_PAREN:
4449    case NODE_L_PAREN:
4450    case DOCUMENT_NODE_L_PAREN:
4451    case PROCESSING_INSTRUCTION_L_PAREN:
4452    case STAR:
4453    case XMLCOMMENT_START:
4454    case XMLPROCESSING_START:
4455    case CDATA_START:
4456    case TAG_START:
4457    case VALIDATE_GLOBAL:
4458    case VALIDATE_CONTEXT:
4459    case VALIDATE_LAX:
4460    case VALIDATE_STRICT:
4461    case VALIDATE_SKIP:
4462    case ELEMENT_QNAME_L_BRACE:
4463    case ELEMENT_L_BRACE:
4464    case ATTRIBUTE_L_BRACE:
4465    case ATTRIBUTE_QNAME_L_BRACE:
4466    case NAMESPACE_NCNAME_L_BRACE:
4467    case DOCUMENT_L_BRACE:
4468    case TEXT_L_BRACE:
4469    case PROCESSING_INSTRUCTION_L_BRACE:
4470    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
4471    case COMMENT_L_BRACE:
4472    case AROBASE:
4473    case ANCESTOR_OR_SELF_DCOLON:
4474    case ANCESTOR_DCOLON:
4475    case ATTRIBUTE_DCOLON:
4476    case CHILD_DCOLON:
4477    case DESCENDANT_SELF_DCOLON:
4478    case DESCENDANT_DCOLON:
4479    case FOLLOWING_SIBLING_DCOLON:
4480    case FOLLOWING_DCOLON:
4481    case PARENT_DCOLON:
4482    case PRECEDING_SIBLING_DCOLON:
4483    case PRECEDING_DCOLON:
4484    case SELF_DCOLON:
4485    case IF_L_PAREN:
4486    case QNAME_L_PAREN:
4487    case DOLLAR:
4488    case FOR_$:
4489    case LET_$:
4490    case SOME_$:
4491    case EVERY_$:
4492    case VALIDATE_L_BRACE:
4493    case TYPESWITCH_L_PAREN:
4494    case L_PAREN:
4495    case MINUS:
4496    case PLUS:
4497    case SLASH_SLASH:
4498    case SLASH:
4499    case DecimalLiteral:
4500    case DOTDOT:
4501    case DOT:
4502    case DoubleLiteral:
4503    case IntegerLiteral:
4504    case NCNAME_STAR:
4505    case STAR_NCNAME:
4506    case StringLiteral:
4507    case QNAME:
4508    case KINDTEST_ELEMENT_L_PAREN:
4509    case ELEMENT_CONTENT_ELT_LESS:
4510    case ELEMENT_CONTENT_XMLCOMMENT_START:
4511    case ELEMENT_CONTENT_XMLPROCESSING_START:
4512    case ELEMENT_CONTENT_CDATA_START:
4513      expression = ExprSingle();
4514                                if (arguments == null) arguments = new ArrayList(1);
4515                                arguments.add(expression);
4516      label_20:
4517      while (true) {
4518        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4519        case COMMA:
4520          ;
4521          break;
4522        default:
4523          jj_la1[127] = jj_gen;
4524          break label_20;
4525        }
4526        currentToken = jj_consume_token(COMMA);
4527        expression = ExprSingle();
4528                                        arguments.add(expression);
4529      }
4530      break;
4531    default:
4532      jj_la1[128] = jj_gen;
4533      ;
4534    }
4535    currentToken = jj_consume_token(R_PAREN);
4536                HashMap map = (HashMap)hashDeclFuncList.get(funcName.getNameSpace());
4537                if (map != null && map.containsKey(funcName.getLocalName()))
4538                {
4539                        try
4540                        {
4541                                {if (true) return factory.createLibraryFunctionCall(funcName, arguments, (FunctionDeclaration)map.get(funcName.getLocalName()), parentModule);}
4542                        }
4543                        catch (TypeException te)
4544                        {
4545                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4546                        }
4547                }
4548                try
4549                {
4550
4551                        String functionName = funcName.getLocalName();
4552                        if (functionName.equals("collection"))
4553                        {
4554                                /* looks up view definition */
4555                                ValueString viewName = (ValueString)arguments.get(0);
4556                                String viewNameString = viewName.getValue();
4557                                if (null != viewDefinitions) {
4558                                        XQueryModule resFile = (XQueryModule)viewDefinitions.get(viewNameString);
4559                                        XQueryExpression resExpr = null;
4560                                        resExpr = (XQueryExpression)resFile.getExpressions().get(0);
4561                                        if (resExpr != null) {if (true) return resExpr;}
4562                                }
4563                        }
4564                        functionName = funcName.getLocalName().toUpperCase();
4565                        functionName = functionName.replace('-', '_');
4566                        boolean found = true;
4567                        java.lang.Class cl = null;
4568                        try {
4569                                found = true;
4570                                cl = Class.forName("org.xquark.xquery.parser.primitivefunctions.fnfunctions.Function" + functionName );
4571                        } catch (ClassNotFoundException cnfe) { found = false; }
4572                        if (!found)
4573                                try {
4574                                        found = true;
4575                                        cl = Class.forName("org.xquark.xquery.parser.primitivefunctions.myfunctions.Function" + functionName );
4576                                } catch (ClassNotFoundException cnfe) {found = false;}
4577                        if (!found)
4578                                try {
4579                                        found = true;
4580                                        cl = Class.forName("org.xquark.xquery.parser.primitivefunctions.xsfunctions.Function" + functionName );
4581                                } catch (ClassNotFoundException cnfe) {found = false;}
4582                        if (!found)
4583                                {if (true) throw new TypeException("Could not find primitive function " + funcName, currentToken.beginLine, currentToken.beginColumn);}
4584                        java.lang.Class[] paramTypes = { Class.forName("java.util.ArrayList"), Class.forName("org.xquark.xquery.parser.XQueryModule")};
4585                        java.lang.reflect.Constructor constructor = cl.getConstructor(paramTypes);
4586                        Object[] params = { arguments, parentModule };
4587                        FunctionCall fc = null;
4588                        fc = (FunctionCall) constructor.newInstance(params);
4589                        String localName = funcName.getLocalName();
4590                        if (!fc.getFuncName().getLocalName().equals(localName)) {if (true) throw new ParseException("XQuery is a case-sensitive language. Primitive function " + localName + " is not a valid name.");}
4591                        // change lars 18/06/2003
4592
if (fc instanceof FunctionINTEGER || fc instanceof FunctionDOUBLE || fc instanceof FunctionDECIMAL || fc instanceof FunctionFLOAT)
4593                        {
4594                                if (fc.getArgument(0) instanceof Value)
4595                                        {if (true) return (XQueryExpression)fc.getArguments().get(0);}
4596                        }
4597                        {if (true) return fc;}
4598                }
4599                catch (ClassNotFoundException cnfe) {
4600                        {if (true) throw new TypeException("Could not find primitive function " + funcName, currentToken.beginLine, currentToken.beginColumn);}
4601                }
4602                catch (java.lang.reflect.InvocationTargetException ite) {
4603                        {if (true) throw new TypeException(ite.getTargetException().getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4604                }
4605                catch (TypeException e) {
4606                        {if (true) throw e;}
4607                }
4608                catch (Exception e) // { /* this is done on purpose you fool! */ }
4609
{
4610                        {if (true) throw new TypeException(e.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4611                }
4612    throw new Error("Missing return statement in function");
4613  }
4614
4615/***************************************************************************************
4616[80] Constructor ::= DirElemConstructor | ComputedConstructor | XmlComment | XmlPI | CdataSection
4617[81] ComputedConstructor ::= CompElemConstructor | CompAttrConstructor | CompDocConstructor | CompTextConstructor | CompXmlPI | CompXmlComment | CompNSConstructor
4618***************************************************************************************/

4619  final public XQueryExpression Constructor() throws ParseException, TypeException, XQueryException {
4620        XQueryExpression expression = null;
4621    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4622    case TAG_START:
4623    case ELEMENT_CONTENT_ELT_LESS:
4624      expression = DirElemConstructor();
4625      break;
4626    case XMLCOMMENT_START:
4627    case ELEMENT_CONTENT_XMLCOMMENT_START:
4628      expression = XmlComment();
4629      break;
4630    case XMLPROCESSING_START:
4631    case ELEMENT_CONTENT_XMLPROCESSING_START:
4632      expression = XmlPI();
4633      break;
4634    case CDATA_START:
4635    case ELEMENT_CONTENT_CDATA_START:
4636      expression = CdataSection();
4637      break;
4638    case DOCUMENT_L_BRACE:
4639      expression = CompDocConstructor();
4640      break;
4641    case ELEMENT_QNAME_L_BRACE:
4642    case ELEMENT_L_BRACE:
4643      expression = CompElemConstructor();
4644      break;
4645    case ATTRIBUTE_L_BRACE:
4646    case ATTRIBUTE_QNAME_L_BRACE:
4647      expression = CompAttrConstructor();
4648      break;
4649    case COMMENT_L_BRACE:
4650      expression = CompXmlComment();
4651      break;
4652    case NAMESPACE_NCNAME_L_BRACE:
4653      expression = CompNSConstructor();
4654      break;
4655    case TEXT_L_BRACE:
4656      expression = CompTextConstructor();
4657      break;
4658    case PROCESSING_INSTRUCTION_L_BRACE:
4659    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
4660      expression = CompXmlPI();
4661      break;
4662    default:
4663      jj_la1[129] = jj_gen;
4664      jj_consume_token(-1);
4665      throw new ParseException();
4666    }
4667                {if (true) return expression;}
4668    throw new Error("Missing return statement in function");
4669  }
4670
4671/***************************************************************************************
4672[98] DirElemConstructor ::= "<" QName AttributeList S? ("/>" | (">" ElementContent* "</" QName S? ">"))
4673***************************************************************************************/

4674  final public Element DirElemConstructor() throws ParseException, TypeException, XQueryException {
4675        String startTagString = null;
4676        QName startTag = null;
4677        ArrayList attributeList = null;
4678        ArrayList vectExpressions = null;
4679        XQueryExpression expression = null;
4680        QName endTag = null;
4681    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4682    case TAG_START:
4683      currentToken = jj_consume_token(TAG_START);
4684
4685      break;
4686    case ELEMENT_CONTENT_ELT_LESS:
4687      currentToken = jj_consume_token(ELEMENT_CONTENT_ELT_LESS);
4688
4689      break;
4690    default:
4691      jj_la1[130] = jj_gen;
4692      jj_consume_token(-1);
4693      throw new ParseException();
4694    }
4695                        namespaceContextStack.pushContext();
4696    currentToken = jj_consume_token(START_TAG_QNAME);
4697                        startTagString = currentToken.image;
4698                        //startTag = QName(currentToken.image,false,false);
4699

4700    attributeList = AttributeList();
4701                        startTag = QName(startTagString);
4702                        if (startTag.getPrefixName() == null)
4703                        {
4704                                startTag.setNameSpace(defaultElementNameSpace);
4705                        }
4706                        else
4707                        {
4708                                String tmpStr = getNameSpace(startTag.getPrefixName());
4709                                if (tmpStr == null)
4710                                        {if (true) throw new TypeException("Could not match prefix [ " + startTag.getPrefixName() + " ]" , currentToken.beginLine, currentToken.beginColumn);}
4711                                startTag.setNameSpace(tmpStr);
4712                        }
4713    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4714    case START_TAG_SLASH_GREATER:
4715      currentToken = jj_consume_token(START_TAG_SLASH_GREATER);
4716      break;
4717    case START_TAG_GREATER:
4718      currentToken = jj_consume_token(START_TAG_GREATER);
4719      label_21:
4720      while (true) {
4721        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4722        case XMLCOMMENT_START:
4723        case XMLPROCESSING_START:
4724        case CDATA_START:
4725        case TAG_START:
4726        case L_BRACE:
4727        case ELEMENT_CONTENT_ELT_LESS:
4728        case ELEMENT_CONTENT_L_BRACE:
4729        case ELEMENT_CONTENT_XMLCOMMENT_START:
4730        case ELEMENT_CONTENT_XMLPROCESSING_START:
4731        case ELEMENT_CONTENT_CDATA_START:
4732        case ELEMENT_CONTENT_ESCAPE_L_BRACE:
4733        case ELEMENT_CONTENT_ESCAPE_R_BRACE:
4734        case ELEMENT_CONTENT_PredefinedEntityRef:
4735        case ELEMENT_CONTENT_CharRef:
4736        case ELEMENT_CONTENT_WhiteChar:
4737        case ELEMENT_CONTENT_Char:
4738          ;
4739          break;
4740        default:
4741          jj_la1[131] = jj_gen;
4742          break label_21;
4743        }
4744        expression = ElementContent();
4745                                                if (expression != null)
4746                                                {
4747                                                        if (vectExpressions == null)
4748                                                        {
4749                                                                vectExpressions = new ArrayList();
4750                                                        }
4751                                                        if (expression instanceof XQueryExpressionSequence && ((XQueryExpressionSequence)expression).getSubExpressions().size() > 1)
4752                                                        {
4753                                                                ArrayList subExpressions = ((XQueryExpressionSequence)expression).getSubExpressions();
4754                                                                XQueryExpression expri = null;
4755                                                                ArrayList sequence = null;
4756                                                                for (int i = 0; i < subExpressions.size(); i++)
4757                                                                {
4758                                                                        expri = (XQueryExpression)subExpressions.get(i);
4759                                                                        sequence = new ArrayList(1);
4760                                                                        sequence.add(expri);
4761                                                                        try
4762                                                                        {
4763                                                                                expri = factory.createXQueryExpressionSequence(sequence, parentModule);
4764                                                                        }
4765                                                                        catch (TypeException te)
4766                                                                        {
4767                                                                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4768                                                                        }
4769                                                                        //expri.setBrace(true);
4770
vectExpressions.add(expri);
4771                                                                }
4772                                                                if (subExpressions.isEmpty()) vectExpressions = null;
4773                                                        }
4774                                                        else
4775                                                        {
4776                                                                vectExpressions.add(expression);
4777                                                        }
4778                                                }
4779      }
4780      currentToken = jj_consume_token(ELEMENT_CONTENT_ELT_LESS_SLASH);
4781      currentToken = jj_consume_token(END_TAG_QNAME);
4782                                        endTag = QName(currentToken.image);
4783                                        if (!endTag.getName().equals(startTag.getName()))
4784                                        {
4785                                                {if (true) throw new ParseException("Error : tag '" + startTag.getName() + "' is ended with '" + endTag.getName() + "'!");}
4786                                        }
4787      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4788      case END_TAG_S:
4789        currentToken = jj_consume_token(END_TAG_S);
4790        break;
4791      default:
4792        jj_la1[132] = jj_gen;
4793        ;
4794      }
4795      currentToken = jj_consume_token(END_TAG_GREATER_THAN);
4796      break;
4797    default:
4798      jj_la1[133] = jj_gen;
4799      jj_consume_token(-1);
4800      throw new ParseException();
4801    }
4802                try
4803                {
4804                        List list = namespaceContextStack.getDeclaredPrefixes();
4805                        HashMap localPrefixes = null;
4806                        for (int i = 0; i < list.size(); i++)
4807                        {
4808                                if (i == 0) localPrefixes = new HashMap();
4809                                String prefix = (String)list.get(i);
4810                                localPrefixes.put(prefix, namespaceContextStack.getNamespaceURI(prefix));
4811                        }
4812                        namespaceContextStack.popContext();
4813                        {if (true) return factory.createElement(startTag, localPrefixes, attributeList, vectExpressions, parentModule);}
4814                }
4815                catch (TypeException te)
4816                {
4817                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4818                }
4819    throw new Error("Missing return statement in function");
4820  }
4821
4822/***************************************************************************************
4823[99] CompDocConstructor ::= <"document" "{"> Expr "}"
4824***************************************************************************************/

4825  final public Document CompDocConstructor() throws ParseException, TypeException, XQueryException {
4826        XQueryExpression expression = null;
4827    currentToken = jj_consume_token(DOCUMENT_L_BRACE);
4828    expression = Expr(false);
4829    currentToken = jj_consume_token(R_BRACE);
4830                try
4831                {
4832                        {if (true) return factory.createDocument(expression, parentModule);}
4833                }
4834                catch (TypeException te)
4835                {
4836                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4837                }
4838    throw new Error("Missing return statement in function");
4839  }
4840
4841/***************************************************************************************
4842[100] CompElemConstructor ::= (<"element" QName "{"> | (<"element" "{"> Expr "}" "{")) Expr? "}"
4843***************************************************************************************/

4844  final public Element CompElemConstructor() throws ParseException, TypeException, XQueryException {
4845        XQueryExpression expression = null;
4846        XQueryExpression sequence = null;
4847        ArrayList attributeList = null;
4848        ArrayList vectExpressions = null;
4849    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4850    case ELEMENT_QNAME_L_BRACE:
4851      currentToken = jj_consume_token(ELEMENT_QNAME_L_BRACE);
4852                                        expression = QName(extractName(currentToken.image,"element","{"),false,false);
4853      break;
4854    case ELEMENT_L_BRACE:
4855      currentToken = jj_consume_token(ELEMENT_L_BRACE);
4856      expression = Expr(false);
4857      currentToken = jj_consume_token(R_BRACE);
4858      currentToken = jj_consume_token(L_BRACE);
4859      break;
4860    default:
4861      jj_la1[134] = jj_gen;
4862      jj_consume_token(-1);
4863      throw new ParseException();
4864    }
4865                        namespaceContextStack.pushContext();
4866    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
4867    case ELEMENT_L_PAREN:
4868    case ATTRIBUTE_L_PAREN:
4869    case COMMENT_L_PAREN:
4870    case TEXT_L_PAREN:
4871    case NODE_L_PAREN:
4872    case DOCUMENT_NODE_L_PAREN:
4873    case PROCESSING_INSTRUCTION_L_PAREN:
4874    case STAR:
4875    case XMLCOMMENT_START:
4876    case XMLPROCESSING_START:
4877    case CDATA_START:
4878    case TAG_START:
4879    case VALIDATE_GLOBAL:
4880    case VALIDATE_CONTEXT:
4881    case VALIDATE_LAX:
4882    case VALIDATE_STRICT:
4883    case VALIDATE_SKIP:
4884    case ELEMENT_QNAME_L_BRACE:
4885    case ELEMENT_L_BRACE:
4886    case ATTRIBUTE_L_BRACE:
4887    case ATTRIBUTE_QNAME_L_BRACE:
4888    case NAMESPACE_NCNAME_L_BRACE:
4889    case DOCUMENT_L_BRACE:
4890    case TEXT_L_BRACE:
4891    case PROCESSING_INSTRUCTION_L_BRACE:
4892    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
4893    case COMMENT_L_BRACE:
4894    case AROBASE:
4895    case ANCESTOR_OR_SELF_DCOLON:
4896    case ANCESTOR_DCOLON:
4897    case ATTRIBUTE_DCOLON:
4898    case CHILD_DCOLON:
4899    case DESCENDANT_SELF_DCOLON:
4900    case DESCENDANT_DCOLON:
4901    case FOLLOWING_SIBLING_DCOLON:
4902    case FOLLOWING_DCOLON:
4903    case PARENT_DCOLON:
4904    case PRECEDING_SIBLING_DCOLON:
4905    case PRECEDING_DCOLON:
4906    case SELF_DCOLON:
4907    case IF_L_PAREN:
4908    case QNAME_L_PAREN:
4909    case DOLLAR:
4910    case FOR_$:
4911    case LET_$:
4912    case SOME_$:
4913    case EVERY_$:
4914    case VALIDATE_L_BRACE:
4915    case TYPESWITCH_L_PAREN:
4916    case L_PAREN:
4917    case MINUS:
4918    case PLUS:
4919    case SLASH_SLASH:
4920    case SLASH:
4921    case DecimalLiteral:
4922    case DOTDOT:
4923    case DOT:
4924    case DoubleLiteral:
4925    case IntegerLiteral:
4926    case NCNAME_STAR:
4927    case STAR_NCNAME:
4928    case StringLiteral:
4929    case QNAME:
4930    case KINDTEST_ELEMENT_L_PAREN:
4931    case ELEMENT_CONTENT_ELT_LESS:
4932    case ELEMENT_CONTENT_XMLCOMMENT_START:
4933    case ELEMENT_CONTENT_XMLPROCESSING_START:
4934    case ELEMENT_CONTENT_CDATA_START:
4935      sequence = Expr(false);
4936      break;
4937    default:
4938      jj_la1[135] = jj_gen;
4939      ;
4940    }
4941    currentToken = jj_consume_token(R_BRACE);
4942                if (sequence != null)
4943                {
4944                        if (sequence instanceof AttributeValuePair)
4945                        {
4946                                attributeList = new ArrayList(1);
4947                                attributeList.add(sequence);
4948                        }
4949                        else if (sequence instanceof XQueryExpressionSequence)
4950                        {
4951                                vectExpressions = ((XQueryExpressionSequence)sequence).getSubExpressions();
4952                                XQueryExpression expri = null;
4953                                for (int i = 0; i < vectExpressions.size(); i++)
4954                                {
4955                                        expri = (XQueryExpression)vectExpressions.get(i);
4956                                        if (expri instanceof AttributeValuePair)
4957                                        {
4958                                                if (attributeList == null) attributeList = new ArrayList(1);
4959                                                attributeList.add(expri);
4960                                                vectExpressions.remove(i);
4961                                                i--;
4962                                        }
4963                                }
4964                                if (vectExpressions.isEmpty()) vectExpressions = null;
4965                        }
4966                        else
4967                        {
4968                                vectExpressions = new ArrayList(1);
4969                                vectExpressions.add(sequence);
4970                        }
4971                }
4972                try
4973                {
4974                        List list = namespaceContextStack.getDeclaredPrefixes();
4975                        HashMap localPrefixes = null;
4976                        for (int i = 0; i < list.size(); i++)
4977                        {
4978                                if (i == 0) localPrefixes = new HashMap();
4979                                String prefix = (String)list.get(i);
4980                                localPrefixes.put(prefix, namespaceContextStack.getNamespaceURI(prefix));
4981                        }
4982                        namespaceContextStack.popContext();
4983                        Element element = factory.createElement(expression, localPrefixes, attributeList, vectExpressions, parentModule);
4984                        element.setIsComputed(true);
4985                        {if (true) return element;}
4986                }
4987                catch (TypeException te)
4988                {
4989                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
4990                }
4991    throw new Error("Missing return statement in function");
4992  }
4993
4994/***************************************************************************************
4995[102] CompAttrConstructor ::= (<"attribute" QName "{"> | (<"attribute" "{"> Expr "}" "{")) Expr? "}"
4996***************************************************************************************/

4997  final public AttributeValuePair CompAttrConstructor() throws ParseException, TypeException, XQueryException {
4998        XQueryExpression attributeName = null;
4999        XQueryExpression attributeValue = null;
5000    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5001    case ATTRIBUTE_QNAME_L_BRACE:
5002      currentToken = jj_consume_token(ATTRIBUTE_QNAME_L_BRACE);
5003                                attributeName = QName(extractName(currentToken.image,"attribute","{"));
5004      break;
5005    case ATTRIBUTE_L_BRACE:
5006      currentToken = jj_consume_token(ATTRIBUTE_L_BRACE);
5007      attributeName = Expr(false);
5008      currentToken = jj_consume_token(R_BRACE);
5009      currentToken = jj_consume_token(L_BRACE);
5010      break;
5011    default:
5012      jj_la1[136] = jj_gen;
5013      jj_consume_token(-1);
5014      throw new ParseException();
5015    }
5016    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5017    case ELEMENT_L_PAREN:
5018    case ATTRIBUTE_L_PAREN:
5019    case COMMENT_L_PAREN:
5020    case TEXT_L_PAREN:
5021    case NODE_L_PAREN:
5022    case DOCUMENT_NODE_L_PAREN:
5023    case PROCESSING_INSTRUCTION_L_PAREN:
5024    case STAR:
5025    case XMLCOMMENT_START:
5026    case XMLPROCESSING_START:
5027    case CDATA_START:
5028    case TAG_START:
5029    case VALIDATE_GLOBAL:
5030    case VALIDATE_CONTEXT:
5031    case VALIDATE_LAX:
5032    case VALIDATE_STRICT:
5033    case VALIDATE_SKIP:
5034    case ELEMENT_QNAME_L_BRACE:
5035    case ELEMENT_L_BRACE:
5036    case ATTRIBUTE_L_BRACE:
5037    case ATTRIBUTE_QNAME_L_BRACE:
5038    case NAMESPACE_NCNAME_L_BRACE:
5039    case DOCUMENT_L_BRACE:
5040    case TEXT_L_BRACE:
5041    case PROCESSING_INSTRUCTION_L_BRACE:
5042    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
5043    case COMMENT_L_BRACE:
5044    case AROBASE:
5045    case ANCESTOR_OR_SELF_DCOLON:
5046    case ANCESTOR_DCOLON:
5047    case ATTRIBUTE_DCOLON:
5048    case CHILD_DCOLON:
5049    case DESCENDANT_SELF_DCOLON:
5050    case DESCENDANT_DCOLON:
5051    case FOLLOWING_SIBLING_DCOLON:
5052    case FOLLOWING_DCOLON:
5053    case PARENT_DCOLON:
5054    case PRECEDING_SIBLING_DCOLON:
5055    case PRECEDING_DCOLON:
5056    case SELF_DCOLON:
5057    case IF_L_PAREN:
5058    case QNAME_L_PAREN:
5059    case DOLLAR:
5060    case FOR_$:
5061    case LET_$:
5062    case SOME_$:
5063    case EVERY_$:
5064    case VALIDATE_L_BRACE:
5065    case TYPESWITCH_L_PAREN:
5066    case L_PAREN:
5067    case MINUS:
5068    case PLUS:
5069    case SLASH_SLASH:
5070    case SLASH:
5071    case DecimalLiteral:
5072    case DOTDOT:
5073    case DOT:
5074    case DoubleLiteral:
5075    case IntegerLiteral:
5076    case NCNAME_STAR:
5077    case STAR_NCNAME:
5078    case StringLiteral:
5079    case QNAME:
5080    case KINDTEST_ELEMENT_L_PAREN:
5081    case ELEMENT_CONTENT_ELT_LESS:
5082    case ELEMENT_CONTENT_XMLCOMMENT_START:
5083    case ELEMENT_CONTENT_XMLPROCESSING_START:
5084    case ELEMENT_CONTENT_CDATA_START:
5085      attributeValue = Expr(false);
5086      break;
5087    default:
5088      jj_la1[137] = jj_gen;
5089      ;
5090    }
5091    currentToken = jj_consume_token(R_BRACE);
5092                if (attributeValue == null)
5093                {
5094                        try
5095                        {
5096                                attributeValue = factory.createValueString("", parentModule);
5097                        }
5098                        catch (TypeException te)
5099                        {
5100                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5101                        }
5102                }
5103                try
5104                {
5105                        AttributeValuePair attributeValuePair = factory.createAttributeValuePair(attributeName, attributeValue, false, parentModule);
5106                        attributeValuePair.setIsComputed(true);
5107                        {if (true) return attributeValuePair;}
5108                }
5109                catch (TypeException te)
5110                {
5111                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5112                }
5113    throw new Error("Missing return statement in function");
5114  }
5115
5116/***************************************************************************************
5117[103] CompXmlPI ::= (("processing-instruction" NCName "{") | ("processing-instruction" "{" Expr "}" "{")) Expr? "}"
5118***************************************************************************************/

5119  final public XMLProcessingInstruction CompXmlPI() throws ParseException, TypeException, XQueryException {
5120        XQueryExpression name = null;
5121        XQueryExpression value = null;
5122        String nameStr = null;
5123    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5124    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
5125      currentToken = jj_consume_token(PROCESSING_INSTRUCTION_NCNAME_L_BRACE);
5126                                name = QName(extractName(currentToken.image,"processing-instruction","{"));
5127      break;
5128    case PROCESSING_INSTRUCTION_L_BRACE:
5129      currentToken = jj_consume_token(PROCESSING_INSTRUCTION_L_BRACE);
5130      name = ExprSingle();
5131      currentToken = jj_consume_token(R_BRACE);
5132      currentToken = jj_consume_token(L_BRACE);
5133      break;
5134    default:
5135      jj_la1[138] = jj_gen;
5136      jj_consume_token(-1);
5137      throw new ParseException();
5138    }
5139    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5140    case ELEMENT_L_PAREN:
5141    case ATTRIBUTE_L_PAREN:
5142    case COMMENT_L_PAREN:
5143    case TEXT_L_PAREN:
5144    case NODE_L_PAREN:
5145    case DOCUMENT_NODE_L_PAREN:
5146    case PROCESSING_INSTRUCTION_L_PAREN:
5147    case STAR:
5148    case XMLCOMMENT_START:
5149    case XMLPROCESSING_START:
5150    case CDATA_START:
5151    case TAG_START:
5152    case VALIDATE_GLOBAL:
5153    case VALIDATE_CONTEXT:
5154    case VALIDATE_LAX:
5155    case VALIDATE_STRICT:
5156    case VALIDATE_SKIP:
5157    case ELEMENT_QNAME_L_BRACE:
5158    case ELEMENT_L_BRACE:
5159    case ATTRIBUTE_L_BRACE:
5160    case ATTRIBUTE_QNAME_L_BRACE:
5161    case NAMESPACE_NCNAME_L_BRACE:
5162    case DOCUMENT_L_BRACE:
5163    case TEXT_L_BRACE:
5164    case PROCESSING_INSTRUCTION_L_BRACE:
5165    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
5166    case COMMENT_L_BRACE:
5167    case AROBASE:
5168    case ANCESTOR_OR_SELF_DCOLON:
5169    case ANCESTOR_DCOLON:
5170    case ATTRIBUTE_DCOLON:
5171    case CHILD_DCOLON:
5172    case DESCENDANT_SELF_DCOLON:
5173    case DESCENDANT_DCOLON:
5174    case FOLLOWING_SIBLING_DCOLON:
5175    case FOLLOWING_DCOLON:
5176    case PARENT_DCOLON:
5177    case PRECEDING_SIBLING_DCOLON:
5178    case PRECEDING_DCOLON:
5179    case SELF_DCOLON:
5180    case IF_L_PAREN:
5181    case QNAME_L_PAREN:
5182    case DOLLAR:
5183    case FOR_$:
5184    case LET_$:
5185    case SOME_$:
5186    case EVERY_$:
5187    case VALIDATE_L_BRACE:
5188    case TYPESWITCH_L_PAREN:
5189    case L_PAREN:
5190    case MINUS:
5191    case PLUS:
5192    case SLASH_SLASH:
5193    case SLASH:
5194    case DecimalLiteral:
5195    case DOTDOT:
5196    case DOT:
5197    case DoubleLiteral:
5198    case IntegerLiteral:
5199    case NCNAME_STAR:
5200    case STAR_NCNAME:
5201    case StringLiteral:
5202    case QNAME:
5203    case KINDTEST_ELEMENT_L_PAREN:
5204    case ELEMENT_CONTENT_ELT_LESS:
5205    case ELEMENT_CONTENT_XMLCOMMENT_START:
5206    case ELEMENT_CONTENT_XMLPROCESSING_START:
5207    case ELEMENT_CONTENT_CDATA_START:
5208      value = Expr(false);
5209      break;
5210    default:
5211      jj_la1[139] = jj_gen;
5212      ;
5213    }
5214    currentToken = jj_consume_token(R_BRACE);
5215                if (value == null)
5216                {
5217                        try
5218                        {
5219                                value = factory.createValueString("", parentModule);
5220                        }
5221                        catch (TypeException te)
5222                        {
5223                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5224                        }
5225                }
5226                try
5227                {
5228                        XMLProcessingInstruction xmlpi = factory.createXMLProcessingInstruction(name, value, parentModule);
5229                        xmlpi.setIsComputed(true);
5230                        {if (true) return xmlpi;}
5231                }
5232                catch (TypeException te)
5233                {
5234                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5235                }
5236    throw new Error("Missing return statement in function");
5237  }
5238
5239/***************************************************************************************
5240[104] CompXmlComment ::= <"comment" "{"> Expr "}"
5241***************************************************************************************/

5242  final public XQueryExpression CompXmlComment() throws ParseException, TypeException, XQueryException {
5243        XQueryExpression commentValue = null;
5244    currentToken = jj_consume_token(COMMENT_L_BRACE);
5245    commentValue = Expr(false);
5246    currentToken = jj_consume_token(R_BRACE);
5247                try
5248                {
5249                        {if (true) return factory.createXMLComment(commentValue, parentModule);}
5250                }
5251                catch (TypeException te)
5252                {
5253                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5254                }
5255    throw new Error("Missing return statement in function");
5256  }
5257
5258/***************************************************************************************
5259[101] CompNSConstructor ::= <"namespace" NCName "{"> Expr "}"
5260***************************************************************************************/

5261  final public XQueryExpression CompNSConstructor() throws ParseException, TypeException, XQueryException {
5262        String ncname = null;
5263        XQueryExpression namespaceValue = null;
5264    currentToken = jj_consume_token(NAMESPACE_NCNAME_L_BRACE);
5265                        ncname = extractName(currentToken.image,"namespace","{");
5266    namespaceValue = ExprSingle();
5267    currentToken = jj_consume_token(R_BRACE);
5268                try
5269                {
5270                        {if (true) return factory.createComputedNamespace(ncname,namespaceValue, parentModule);}
5271                }
5272                catch (TypeException te)
5273                {
5274                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5275                }
5276    throw new Error("Missing return statement in function");
5277  }
5278
5279/***************************************************************************************
5280[105] CompTextConstructor ::= <"text" "{"> Expr? "}"
5281***************************************************************************************/

5282  final public XQueryExpression CompTextConstructor() throws ParseException, TypeException, XQueryException {
5283        XQueryExpression textValue = null;
5284    currentToken = jj_consume_token(TEXT_L_BRACE);
5285    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5286    case ELEMENT_L_PAREN:
5287    case ATTRIBUTE_L_PAREN:
5288    case COMMENT_L_PAREN:
5289    case TEXT_L_PAREN:
5290    case NODE_L_PAREN:
5291    case DOCUMENT_NODE_L_PAREN:
5292    case PROCESSING_INSTRUCTION_L_PAREN:
5293    case STAR:
5294    case XMLCOMMENT_START:
5295    case XMLPROCESSING_START:
5296    case CDATA_START:
5297    case TAG_START:
5298    case VALIDATE_GLOBAL:
5299    case VALIDATE_CONTEXT:
5300    case VALIDATE_LAX:
5301    case VALIDATE_STRICT:
5302    case VALIDATE_SKIP:
5303    case ELEMENT_QNAME_L_BRACE:
5304    case ELEMENT_L_BRACE:
5305    case ATTRIBUTE_L_BRACE:
5306    case ATTRIBUTE_QNAME_L_BRACE:
5307    case NAMESPACE_NCNAME_L_BRACE:
5308    case DOCUMENT_L_BRACE:
5309    case TEXT_L_BRACE:
5310    case PROCESSING_INSTRUCTION_L_BRACE:
5311    case PROCESSING_INSTRUCTION_NCNAME_L_BRACE:
5312    case COMMENT_L_BRACE:
5313    case AROBASE:
5314    case ANCESTOR_OR_SELF_DCOLON:
5315    case ANCESTOR_DCOLON:
5316    case ATTRIBUTE_DCOLON:
5317    case CHILD_DCOLON:
5318    case DESCENDANT_SELF_DCOLON:
5319    case DESCENDANT_DCOLON:
5320    case FOLLOWING_SIBLING_DCOLON:
5321    case FOLLOWING_DCOLON:
5322    case PARENT_DCOLON:
5323    case PRECEDING_SIBLING_DCOLON:
5324    case PRECEDING_DCOLON:
5325    case SELF_DCOLON:
5326    case IF_L_PAREN:
5327    case QNAME_L_PAREN:
5328    case DOLLAR:
5329    case FOR_$:
5330    case LET_$:
5331    case SOME_$:
5332    case EVERY_$:
5333    case VALIDATE_L_BRACE:
5334    case TYPESWITCH_L_PAREN:
5335    case L_PAREN:
5336    case MINUS:
5337    case PLUS:
5338    case SLASH_SLASH:
5339    case SLASH:
5340    case DecimalLiteral:
5341    case DOTDOT:
5342    case DOT:
5343    case DoubleLiteral:
5344    case IntegerLiteral:
5345    case NCNAME_STAR:
5346    case STAR_NCNAME:
5347    case StringLiteral:
5348    case QNAME:
5349    case KINDTEST_ELEMENT_L_PAREN:
5350    case ELEMENT_CONTENT_ELT_LESS:
5351    case ELEMENT_CONTENT_XMLCOMMENT_START:
5352    case ELEMENT_CONTENT_XMLPROCESSING_START:
5353    case ELEMENT_CONTENT_CDATA_START:
5354      textValue = Expr(false);
5355      break;
5356    default:
5357      jj_la1[140] = jj_gen;
5358      ;
5359    }
5360    currentToken = jj_consume_token(R_BRACE);
5361                try
5362                {
5363                        if (textValue == null) {
5364                                textValue = factory.createValueString("",parentModule);
5365                        }
5366                        {if (true) return factory.createComputedText(textValue, parentModule);}
5367                }
5368                catch (TypeException te)
5369                {
5370                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5371                }
5372    throw new Error("Missing return statement in function");
5373  }
5374
5375/***************************************************************************************
5376[106] CdataSection ::= "<![CDATA[" Char* "]]>"
5377***************************************************************************************/

5378  final public CData CdataSection() throws ParseException, TypeException, XQueryException {
5379        StringBuffer buf = new StringBuffer();
5380    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5381    case CDATA_START:
5382      currentToken = jj_consume_token(CDATA_START);
5383      break;
5384    case ELEMENT_CONTENT_CDATA_START:
5385      currentToken = jj_consume_token(ELEMENT_CONTENT_CDATA_START);
5386      break;
5387    default:
5388      jj_la1[141] = jj_gen;
5389      jj_consume_token(-1);
5390      throw new ParseException();
5391    }
5392    label_22:
5393    while (true) {
5394      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5395      case CDATA_SECTION_CHAR:
5396        ;
5397        break;
5398      default:
5399        jj_la1[142] = jj_gen;
5400        break label_22;
5401      }
5402      currentToken = jj_consume_token(CDATA_SECTION_CHAR);
5403                                buf.append(currentToken.image);
5404    }
5405    currentToken = jj_consume_token(CDATA_SECTION_END);
5406                try
5407                {
5408                        {if (true) return factory.createCData(buf.toString(), parentModule);}
5409                }
5410                catch (TypeException te)
5411                {
5412                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5413                }
5414    throw new Error("Missing return statement in function");
5415  }
5416
5417/***************************************************************************************
5418[107] XmlPI ::= "<?" PITarget Char* "?>"
5419***************************************************************************************/

5420  final public XMLProcessingInstruction XmlPI() throws ParseException, TypeException, XQueryException {
5421        StringBuffer buf = new StringBuffer();
5422        String PITarget = null;
5423    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5424    case XMLPROCESSING_START:
5425      currentToken = jj_consume_token(XMLPROCESSING_START);
5426      break;
5427    case ELEMENT_CONTENT_XMLPROCESSING_START:
5428      currentToken = jj_consume_token(ELEMENT_CONTENT_XMLPROCESSING_START);
5429      break;
5430    default:
5431      jj_la1[143] = jj_gen;
5432      jj_consume_token(-1);
5433      throw new ParseException();
5434    }
5435    currentToken = jj_consume_token(PROCESSING_INSTRUCTION_NCNAME);
5436                        PITarget = unquote(currentToken.image);
5437    label_23:
5438    while (true) {
5439      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5440      case PROCESSING_INSTRUCTION_CONTENT_CHAR:
5441        ;
5442        break;
5443      default:
5444        jj_la1[144] = jj_gen;
5445        break label_23;
5446      }
5447      currentToken = jj_consume_token(PROCESSING_INSTRUCTION_CONTENT_CHAR);
5448                                buf.append(currentToken.image);
5449    }
5450    currentToken = jj_consume_token(PROCESSING_INSTRUCTION_CONTENT_PROCESSING_INSTRUCTION_END);
5451                try
5452                {
5453                        {if (true) return factory.createXMLProcessingInstruction(factory.createValueString(PITarget,parentModule), factory.createValueString(buf.toString(),parentModule), parentModule);}
5454                }
5455                catch (TypeException te)
5456                {
5457                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5458                }
5459    throw new Error("Missing return statement in function");
5460  }
5461
5462/***************************************************************************************
5463[108] XmlComment ::= "<!--" Char* "-->"
5464***************************************************************************************/

5465  final public XMLComment XmlComment() throws ParseException, TypeException, XQueryException {
5466        StringBuffer buf = new StringBuffer();
5467    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5468    case XMLCOMMENT_START:
5469      currentToken = jj_consume_token(XMLCOMMENT_START);
5470      break;
5471    case ELEMENT_CONTENT_XMLCOMMENT_START:
5472      currentToken = jj_consume_token(ELEMENT_CONTENT_XMLCOMMENT_START);
5473      break;
5474    default:
5475      jj_la1[145] = jj_gen;
5476      jj_consume_token(-1);
5477      throw new ParseException();
5478    }
5479    label_24:
5480    while (true) {
5481      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5482      case XML_COMMENT_CHAR:
5483        ;
5484        break;
5485      default:
5486        jj_la1[146] = jj_gen;
5487        break label_24;
5488      }
5489      currentToken = jj_consume_token(XML_COMMENT_CHAR);
5490                                buf.append(currentToken.image);
5491    }
5492    currentToken = jj_consume_token(XML_COMMENT_END);
5493                try
5494                {
5495                        {if (true) return factory.createXMLComment(factory.createValueString(buf.toString(),parentModule), parentModule);}
5496                }
5497                catch (TypeException te)
5498                {
5499                        {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5500                }
5501    throw new Error("Missing return statement in function");
5502  }
5503
5504/***************************************************************************************
5505[109] ElementContent ::= ElementContentChar | "{{" | "}}" | DirElemConstructor | EnclosedExpr | CdataSection | CharRef | PredefinedEntityRef | XmlComment | XmlPI
5506***************************************************************************************/

5507  final public XQueryExpression ElementContent() throws ParseException, TypeException, XQueryException {
5508        StringBuffer buf = new StringBuffer();
5509        XQueryExpression expression = null;
5510        boolean hasCharRef = false;
5511        boolean isWhiteOnly = true;
5512        boolean prevIsR = false;
5513    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5514    case ELEMENT_CONTENT_ESCAPE_L_BRACE:
5515    case ELEMENT_CONTENT_ESCAPE_R_BRACE:
5516    case ELEMENT_CONTENT_PredefinedEntityRef:
5517    case ELEMENT_CONTENT_CharRef:
5518    case ELEMENT_CONTENT_WhiteChar:
5519    case ELEMENT_CONTENT_Char:
5520      label_25:
5521      while (true) {
5522        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5523        case ELEMENT_CONTENT_WhiteChar:
5524          currentToken = jj_consume_token(ELEMENT_CONTENT_WhiteChar);
5525                                        if (currentToken.image.charAt(0) == '\r')
5526                                                prevIsR = true;
5527                                        else {
5528                                                if (prevIsR) {
5529                                                        if (currentToken.image.charAt(0) == '\n')
5530                                                                buf.deleteCharAt(buf.length()-1);
5531                                                        else
5532                                                                buf.setCharAt(buf.length()-1,'\n');
5533                                                        prevIsR = false;
5534                                                }
5535                                        }
5536                                        buf.append(currentToken.image);
5537          break;
5538        case ELEMENT_CONTENT_Char:
5539          currentToken = jj_consume_token(ELEMENT_CONTENT_Char);
5540                                        buf.append(currentToken.image);
5541                                        if (isWhiteOnly) isWhiteOnly = false;
5542                                        if (prevIsR) {
5543                                                buf.setCharAt(buf.length()-1,'\n');
5544                                                prevIsR = false;
5545                                        }
5546          break;
5547        case ELEMENT_CONTENT_ESCAPE_L_BRACE:
5548          currentToken = jj_consume_token(ELEMENT_CONTENT_ESCAPE_L_BRACE);
5549                                        buf.append("{");
5550                                        if (isWhiteOnly) isWhiteOnly = false;
5551                                        if (prevIsR) {
5552                                                buf.setCharAt(buf.length()-1,'\n');
5553                                                prevIsR = false;
5554                                        }
5555          break;
5556        case ELEMENT_CONTENT_ESCAPE_R_BRACE:
5557          currentToken = jj_consume_token(ELEMENT_CONTENT_ESCAPE_R_BRACE);
5558                                        buf.append("}");
5559                                        if (isWhiteOnly) isWhiteOnly = false;
5560                                        if (prevIsR) {
5561                                                buf.setCharAt(buf.length()-1,'\n');
5562                                                prevIsR = false;
5563                                        }
5564          break;
5565        case ELEMENT_CONTENT_CharRef:
5566          currentToken = jj_consume_token(ELEMENT_CONTENT_CharRef);
5567                                        if (!hasCharRef) hasCharRef = true;
5568                                        char car = parseCharRef(currentToken.image);
5569                                        if (car == '\r' || car == '\n' || car == '\n' || car == '\n') {
5570                                                if (car == '\r')
5571                                                        prevIsR = true;
5572                                                else {
5573                                                        if (prevIsR) {
5574                                                                if (car == '\n')
5575                                                                        buf.deleteCharAt(buf.length()-1);
5576                                                                else
5577                                                                        buf.setCharAt(buf.length()-1,'\n');
5578                                                                prevIsR = false;
5579                                                        }
5580                                                }
5581                                        } else {
5582                                                if (isWhiteOnly) isWhiteOnly = false;
5583                                                if (prevIsR) {
5584                                                        buf.setCharAt(buf.length()-1,'\n');
5585                                                        prevIsR = false;
5586                                                }
5587                                        }
5588                                        buf.append(car);
5589          break;
5590        case ELEMENT_CONTENT_PredefinedEntityRef:
5591          currentToken = jj_consume_token(ELEMENT_CONTENT_PredefinedEntityRef);
5592                                        if (!hasCharRef) hasCharRef = true;
5593                                        if (isWhiteOnly) isWhiteOnly = false;
5594                                        if (prevIsR) {
5595                                                buf.setCharAt(buf.length()-1,'\n');
5596                                                prevIsR = false;
5597                                        }
5598                                        buf.append(parsePredefinedEntityRef(currentToken.image));
5599          break;
5600        default:
5601          jj_la1[147] = jj_gen;
5602          jj_consume_token(-1);
5603          throw new ParseException();
5604        }
5605        if (jj_2_8(2)) {
5606          ;
5607        } else {
5608          break label_25;
5609        }
5610      }
5611                        try
5612                        {
5613                                if (buf.length() == 0 || (isWhiteOnly && !hasCharRef && xmlspace != Constants.XMLSPACE_PRESERVE))
5614                                        expression = null;
5615                                else
5616                                        expression = factory.createValueText(buf.toString(), parentModule);
5617                        }
5618                        catch (TypeException te)
5619                        {
5620                                {if (true) throw new TypeException(te.getMessage(), currentToken.beginLine, currentToken.beginColumn);}
5621                        }
5622      break;
5623    case TAG_START:
5624    case ELEMENT_CONTENT_ELT_LESS:
5625      expression = DirElemConstructor();
5626      break;
5627    case L_BRACE:
5628    case ELEMENT_CONTENT_L_BRACE:
5629      expression = EnclosedExpr(false);
5630      break;
5631    case CDATA_START:
5632    case ELEMENT_CONTENT_CDATA_START:
5633      expression = CdataSection();
5634      break;
5635    case XMLCOMMENT_START:
5636    case ELEMENT_CONTENT_XMLCOMMENT_START:
5637      expression = XmlComment();
5638      break;
5639    case XMLPROCESSING_START:
5640    case ELEMENT_CONTENT_XMLPROCESSING_START:
5641      expression = XmlPI();
5642      break;
5643    default:
5644      jj_la1[148] = jj_gen;
5645      jj_consume_token(-1);
5646      throw new ParseException();
5647    }
5648                {if (true) return expression;}
5649    throw new Error("Missing return statement in function");
5650  }
5651
5652/***************************************************************************************
5653[110] AttributeList ::= (S (QName S? "=" S? AttributeValue)?)*
5654***************************************************************************************/

5655  final public ArrayList AttributeList() throws ParseException, TypeException, XQueryException {
5656        QName attributeName = null;
5657        AttributeValuePair attributeValuePair = null;
5658        XQueryExpression attributeValue = null;
5659        ArrayList attributeList = null;
5660    label_26:
5661    while (true) {
5662      if (jj_2_9(2)) {
5663        ;
5664      } else {
5665        break label_26;
5666      }
5667      currentToken = jj_consume_token(START_TAG_S);
5668      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5669      case START_TAG_QNAME:
5670        currentToken = jj_consume_token(START_TAG_QNAME);
5671                                attributeName = QName(currentToken.image);
5672        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5673        case START_TAG_S:
5674          currentToken = jj_consume_token(START_TAG_S);
5675          break;
5676        default:
5677          jj_la1[149] = jj_gen;
5678          ;
5679        }
5680        currentToken = jj_consume_token(START_TAG_EQUAL);
5681        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
5682        case START_TAG_S:
5683          currentToken = jj_consume_token(START_TAG_S);
5684          break;
5685        default:
5686          jj_la1[150] = jj_gen;
5687          ;
5688        }
5689        attributeValue = AttributeValue();
5690                                try
5691                                {
5692                                        if (attributeName.getNameSpace() == null && attributeName.getPrefixName() != null && attributeName.getPrefixName().equals(XMLNS))
5693                                        {
5694                                                namespaceContextStack.declarePrefix(attributeName.getLocalName(), ((ValueString)attributeValue).getStringValue());
5695                                                attributeValuePair = factory.createAttributeValuePair(factory.createValueString(attributeName.getLocalName(), parentModule), attributeValue ,true , parentModule);
5696                                        }
5697                                        else if (attributeName.getNameSpace() == null && attributeName.getPrefixName() == null && attributeName.getLocalName() != null && attributeName.getLocalName().equals(XMLNS))
5698                                        {
5699                                                namespaceContextStack.declarePrefix("", ((ValueString)attributeValue).getStringValue());
5700                                                attributeValuePair = factor