src/share/jaxws_classes/com/sun/xml/internal/rngom/parse/compact/CompactSyntax.java

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 0
373ffda63c9a
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

     1 /*
     2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    25 /*
    26  * Copyright (C) 2004-2011
    27  *
    28  * Permission is hereby granted, free of charge, to any person obtaining a copy
    29  * of this software and associated documentation files (the "Software"), to deal
    30  * in the Software without restriction, including without limitation the rights
    31  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    32  * copies of the Software, and to permit persons to whom the Software is
    33  * furnished to do so, subject to the following conditions:
    34  *
    35  * The above copyright notice and this permission notice shall be included in
    36  * all copies or substantial portions of the Software.
    37  *
    38  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    39  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    40  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    41  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    42  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    43  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    44  * THE SOFTWARE.
    45  */
    46 /* Generated By:JavaCC: Do not edit this line. CompactSyntax.java */
    47 package com.sun.xml.internal.rngom.parse.compact;
    49 import java.io.Reader;
    50 import java.net.MalformedURLException;
    51 import java.net.URL;
    52 import java.util.Arrays;
    53 import java.util.ArrayList;
    54 import java.util.Collections;
    55 import java.util.Enumeration;
    56 import java.util.Hashtable;
    57 import java.util.List;
    59 import com.sun.xml.internal.rngom.ast.builder.Annotations;
    60 import com.sun.xml.internal.rngom.ast.builder.BuildException;
    61 import com.sun.xml.internal.rngom.ast.builder.CommentList;
    62 import com.sun.xml.internal.rngom.ast.builder.DataPatternBuilder;
    63 import com.sun.xml.internal.rngom.ast.builder.Div;
    64 import com.sun.xml.internal.rngom.ast.builder.ElementAnnotationBuilder;
    65 import com.sun.xml.internal.rngom.ast.builder.Grammar;
    66 import com.sun.xml.internal.rngom.ast.builder.GrammarSection;
    67 import com.sun.xml.internal.rngom.ast.builder.Include;
    68 import com.sun.xml.internal.rngom.ast.builder.IncludedGrammar;
    69 import com.sun.xml.internal.rngom.ast.builder.NameClassBuilder;
    70 import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
    71 import com.sun.xml.internal.rngom.ast.builder.Scope;
    72 import com.sun.xml.internal.rngom.ast.om.Location;
    73 import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
    74 import com.sun.xml.internal.rngom.ast.om.ParsedNameClass;
    75 import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
    76 import com.sun.xml.internal.rngom.parse.Context;
    77 import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
    78 import com.sun.xml.internal.rngom.parse.Parseable;
    79 import org.xml.sax.ErrorHandler;
    80 import org.xml.sax.SAXException;
    81 import org.xml.sax.SAXParseException;
    82 import org.xml.sax.helpers.LocatorImpl;
    84 import com.sun.xml.internal.rngom.util.Localizer;
    85 import com.sun.xml.internal.rngom.xml.util.WellKnownNamespaces;
    88 public class CompactSyntax implements Context, CompactSyntaxConstants {
    89   private static final int IN_ELEMENT = 0;
    90   private static final int IN_ATTRIBUTE = 1;
    91   private static final int IN_ANY_NAME = 2;
    92   private static final int IN_NS_NAME = 4;
    94   private String defaultNamespace;
    95   private String compatibilityPrefix = null;
    96   private SchemaBuilder sb;
    97   private NameClassBuilder ncb;
    98   private String sourceUri;
    99   /**
   100    * This is what we are parsing right now.
   101    */
   102   private CompactParseable parseable;
   103   private ErrorHandler eh;
   104   private final Hashtable namespaceTable = new Hashtable();
   105   private final Hashtable datatypesTable = new Hashtable();
   106   private boolean hadError = false;
   107   private static final Localizer localizer = new Localizer(new Localizer(Parseable.class),CompactSyntax.class);
   108   private final Hashtable attributeNameTable = new Hashtable();
   109   private boolean annotationsIncludeElements = false;
   111   /**
   112    * String that represents the inherited namespace.
   113    *
   114    * <p>
   115    * HACK: we always allocate a new String instance so that
   116    * we can distinguish inherited value from the explicitly
   117    * given value.
   118    */
   119   private /*final*/ String inheritedNs; // essentially final but JavaCC don't let us declare it as so.
   121   final class LocatedString {
   122     private final String str;
   123     private final Token tok;
   125     LocatedString(String str, Token tok) {
   126       this.str = str;
   127       this.tok = tok;
   128     }
   130     String getString() {
   131       return str;
   132     }
   134     Location getLocation() {
   135       return makeLocation(tok);
   136     }
   138     Token getToken() {
   139       return tok;
   140     }
   142   }
   144   public CompactSyntax(CompactParseable parseable, Reader r, String sourceUri, SchemaBuilder sb, ErrorHandler eh, String inheritedNs) {
   145     this(r);
   146     this.sourceUri = sourceUri;
   147     this.parseable = parseable;
   148     this.sb = sb;
   149     this.ncb = sb.getNameClassBuilder();
   150     this.eh = eh;
   151     // this causes the root pattern to have non-null annotations
   152     // which is useful because it gives a context to trang
   153     this.topLevelComments = sb.makeCommentList();
   154     this.inheritedNs = defaultNamespace = new String(inheritedNs);
   155   }
   157   ParsedPattern parse(Scope scope) throws IllegalSchemaException {
   158     try {
   159       ParsedPattern p = Input(scope);
   160       if (!hadError)
   161         return p;
   162     }
   163     catch (ParseException e) {
   164       error("syntax_error", e.getMessage(), e.currentToken.next);
   165     }
   166     catch (EscapeSyntaxException e) {
   167       reportEscapeSyntaxException(e);
   168     }
   169     throw new IllegalSchemaException();
   170   }
   172   ParsedPattern parseInclude(IncludedGrammar g) throws IllegalSchemaException {
   173     try {
   174       ParsedPattern p = IncludedGrammar(g);
   175       if (!hadError)
   176         return p;
   177     }
   178     catch (ParseException e) {
   179       error("syntax_error", e.getMessage(), e.currentToken.next);
   180     }
   181     catch (EscapeSyntaxException e) {
   182       reportEscapeSyntaxException(e);
   183     }
   184     throw new IllegalSchemaException();
   185   }
   187   private void checkNsName(int context, LocatedString ns) {
   188     if ((context & IN_NS_NAME) != 0)
   189       error("ns_name_except_contains_ns_name", ns.getToken());
   190   }
   192   private void checkAnyName(int context, Token t) {
   193     if ((context & IN_NS_NAME) != 0)
   194       error("ns_name_except_contains_any_name", t);
   195     if ((context & IN_ANY_NAME) != 0)
   196       error("any_name_except_contains_any_name", t);
   197   }
   199   private void error(String key, Token tok) {
   200     doError(localizer.message(key), tok);
   201   }
   203   private void error(String key, String arg, Token tok) {
   204     doError(localizer.message(key, arg), tok);
   205   }
   207   private void error(String key, String arg1, String arg2, Token tok) {
   208     doError(localizer.message(key, arg1, arg2), tok);
   209   }
   211   private void doError(String message, Token tok) {
   212     hadError = true;
   213     if (eh != null) {
   214       LocatorImpl loc = new LocatorImpl();
   215       loc.setLineNumber(tok.beginLine);
   216       loc.setColumnNumber(tok.beginColumn);
   217       loc.setSystemId(sourceUri);
   218       try {
   219         eh.error(new SAXParseException(message, loc));
   220       }
   221       catch (SAXException se) {
   222         throw new BuildException(se);
   223       }
   224     }
   225   }
   227   private void reportEscapeSyntaxException(EscapeSyntaxException e) {
   228     if (eh != null) {
   229       LocatorImpl loc = new LocatorImpl();
   230       loc.setLineNumber(e.getLineNumber());
   231       loc.setColumnNumber(e.getColumnNumber());
   232       loc.setSystemId(sourceUri);
   233       try {
   234         eh.error(new SAXParseException(localizer.message(e.getKey()), loc));
   235       }
   236       catch (SAXException se) {
   237         throw new BuildException(se);
   238       }
   239     }
   240   }
   242   private static String unquote(String s) {
   243     if (s.length() >= 6 && s.charAt(0) == s.charAt(1)) {
   244       s = s.replace('\u0000', '\u005cn');
   245       return s.substring(3, s.length() - 3);
   246     }
   247     else
   248       return s.substring(1, s.length() - 1);
   249   }
   251   Location makeLocation(Token t) {
   252     return sb.makeLocation(sourceUri, t.beginLine, t.beginColumn);
   253   }
   255   private static ParsedPattern[] addPattern(ParsedPattern[] patterns, int i, ParsedPattern p) {
   256     if (i >= patterns.length) {
   257       ParsedPattern[] oldPatterns = patterns;
   258       patterns = new ParsedPattern[oldPatterns.length*2];
   259       System.arraycopy(oldPatterns, 0, patterns, 0, oldPatterns.length);
   260     }
   261     patterns[i] = p;
   262     return patterns;
   263   }
   265   String getCompatibilityPrefix() {
   266     if (compatibilityPrefix == null) {
   267       compatibilityPrefix = "a";
   268       while (namespaceTable.get(compatibilityPrefix) != null)
   269         compatibilityPrefix = compatibilityPrefix + "a";
   270     }
   271     return compatibilityPrefix;
   272   }
   274   public String resolveNamespacePrefix(String prefix) {
   275     String result = (String)namespaceTable.get(prefix);
   276     if (result.length() == 0)
   277       return null;
   278     return result;
   279   }
   281   public Enumeration prefixes() {
   282     return namespaceTable.keys();
   283   }
   285   public String getBaseUri() {
   286     return sourceUri;
   287   }
   289   public boolean isUnparsedEntity(String entityName) {
   290     return false;
   291   }
   293   public boolean isNotation(String notationName) {
   294     return false;
   295   }
   297   public Context copy() {
   298     return this;
   299   }
   301   private Context getContext() {
   302     return this;
   303   }
   305   private CommentList getComments() {
   306     return getComments(getTopLevelComments());
   307   }
   309   private CommentList topLevelComments;
   311   private CommentList getTopLevelComments() {
   312     CommentList tem = topLevelComments;
   313     topLevelComments = null;
   314     return tem;
   315   }
   317   private void noteTopLevelComments() {
   318     topLevelComments = getComments(topLevelComments);
   319   }
   321   private void topLevelComments(GrammarSection section) {
   322     section.topLevelComment(getComments(null));
   323   }
   325   private Token lastCommentSourceToken = null;
   327   private CommentList getComments(CommentList comments) {
   328     Token nextToken = getToken(1);
   329     if (lastCommentSourceToken != nextToken) {
   330       if (lastCommentSourceToken == null)
   331         lastCommentSourceToken = token;
   332       do {
   333         lastCommentSourceToken = lastCommentSourceToken.next;
   334         Token t = lastCommentSourceToken.specialToken;
   335         if (t != null) {
   336           while (t.specialToken != null)
   337             t = t.specialToken;
   338           if (comments == null)
   339             comments = sb.makeCommentList();
   340           for (; t != null; t = t.next) {
   341             String s = mungeComment(t.image);
   342             Location loc = makeLocation(t);
   343             if (t.next != null
   344                 && t.next.kind == CompactSyntaxConstants.SINGLE_LINE_COMMENT_CONTINUE) {
   345               StringBuffer buf = new StringBuffer(s);
   346               do {
   347                 t = t.next;
   348                 buf.append('\u005cn');
   349                 buf.append(mungeComment(t.image));
   350               } while (t.next != null
   351                        && t.next.kind == CompactSyntaxConstants.SINGLE_LINE_COMMENT_CONTINUE);
   352               s = buf.toString();
   353             }
   354             comments.addComment(s, loc);
   355           }
   356         }
   357       } while (lastCommentSourceToken != nextToken);
   358     }
   359     return comments;
   360   }
   362   private ParsedPattern afterComments(ParsedPattern p) {
   363     CommentList comments = getComments(null);
   364     if (comments == null)
   365       return p;
   366     return sb.commentAfter(p, comments);
   367   }
   369   private ParsedNameClass afterComments(ParsedNameClass nc) {
   370     CommentList comments = getComments(null);
   371     if (comments == null)
   372       return nc;
   373     return ncb.commentAfter(nc, comments);
   374   }
   376   private static String mungeComment(String image) {
   377     int i = image.indexOf('#') + 1;
   378     while (i < image.length() && image.charAt(i) == '#')
   379       i++;
   380     if (i < image.length() && image.charAt(i) == ' ')
   381       i++;
   382     return image.substring(i);
   383   }
   385   private Annotations getCommentsAsAnnotations() {
   386     CommentList comments = getComments();
   387     if (comments == null)
   388       return null;
   389     return sb.makeAnnotations(comments, getContext());
   390   }
   392   private Annotations addCommentsToChildAnnotations(Annotations a) {
   393     CommentList comments = getComments();
   394     if (comments == null)
   395       return a;
   396     if (a == null)
   397       a = sb.makeAnnotations(null, getContext());
   398     a.addComment(comments);
   399     return a;
   400   }
   402   private Annotations addCommentsToLeadingAnnotations(Annotations a) {
   403     CommentList comments = getComments();
   404     if (comments == null)
   405       return a;
   406     if (a == null)
   407       return sb.makeAnnotations(comments, getContext());
   408     a.addLeadingComment(comments);
   409     return a;
   410   }
   412   private Annotations getTopLevelCommentsAsAnnotations() {
   413     CommentList comments = getTopLevelComments();
   414     if (comments == null)
   415       return null;
   416     return sb.makeAnnotations(comments, getContext());
   417   }
   419   private void clearAttributeList() {
   420     attributeNameTable.clear();
   421   }
   423   private void addAttribute(Annotations a, String ns, String localName, String prefix, String value, Token tok) {
   424     String key = ns + "#" + localName;
   425     if (attributeNameTable.get(key) != null)
   426       error("duplicate_attribute", ns, localName, tok);
   427     else {
   428       attributeNameTable.put(key, key);
   429       a.addAttribute(ns, localName, prefix, value, makeLocation(tok));
   430     }
   431   }
   433   private void checkExcept(Token[] except) {
   434     if (except[0] != null)
   435       error("except_missing_parentheses", except[0]);
   436   }
   438   private String lookupPrefix(String prefix, Token t) {
   439     String ns = (String)namespaceTable.get(prefix);
   440     if (ns == null) {
   441       error("undeclared_prefix", prefix, t);
   442       return "#error";
   443     }
   444     return ns;
   445   }
   446   private String lookupDatatype(String prefix, Token t) {
   447     String ns = (String)datatypesTable.get(prefix);
   448     if (ns == null) {
   449       error("undeclared_prefix", prefix, t);
   450       return ""; // XXX
   451     }
   452     return ns;
   453   }
   454   private String resolve(String str) {
   455     try {
   456      return new URL(new URL(sourceUri), str).toString();
   457     }
   458     catch (MalformedURLException e) { }
   459     return str;
   460   }
   462   final public ParsedPattern Input(Scope scope) throws ParseException {
   463   ParsedPattern p;
   464     Preamble();
   465     if (jj_2_1(2147483647)) {
   466       p = TopLevelGrammar(scope);
   467     } else {
   468       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   469       case 1:
   470       case 10:
   471       case 17:
   472       case 18:
   473       case 19:
   474       case 26:
   475       case 27:
   476       case 28:
   477       case 31:
   478       case 32:
   479       case 33:
   480       case 34:
   481       case 35:
   482       case 36:
   483       case DOCUMENTATION:
   484       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
   485       case IDENTIFIER:
   486       case ESCAPED_IDENTIFIER:
   487       case PREFIXED_NAME:
   488       case LITERAL:
   489         p = Expr(true, scope, null, null);
   490                                          p = afterComments(p);
   491         jj_consume_token(0);
   492         break;
   493       default:
   494         jj_la1[0] = jj_gen;
   495         jj_consume_token(-1);
   496         throw new ParseException();
   497       }
   498     }
   499     {if (true) return p;}
   500     throw new Error("Missing return statement in function");
   501   }
   503   final public void TopLevelLookahead() throws ParseException {
   504     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   505     case PREFIXED_NAME:
   506       jj_consume_token(PREFIXED_NAME);
   507       jj_consume_token(1);
   508       break;
   509     case IDENTIFIER:
   510     case ESCAPED_IDENTIFIER:
   511       Identifier();
   512       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   513       case 1:
   514         jj_consume_token(1);
   515         break;
   516       case 2:
   517         jj_consume_token(2);
   518         break;
   519       case 3:
   520         jj_consume_token(3);
   521         break;
   522       case 4:
   523         jj_consume_token(4);
   524         break;
   525       default:
   526         jj_la1[1] = jj_gen;
   527         jj_consume_token(-1);
   528         throw new ParseException();
   529       }
   530       break;
   531     case 5:
   532     case 6:
   533     case 7:
   534       LookaheadGrammarKeyword();
   535       break;
   536     case 1:
   537       LookaheadBody();
   538       LookaheadAfterAnnotations();
   539       break;
   540     case DOCUMENTATION:
   541     case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
   542       LookaheadDocumentation();
   543       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   544       case 1:
   545         LookaheadBody();
   546         break;
   547       default:
   548         jj_la1[2] = jj_gen;
   549         ;
   550       }
   551       LookaheadAfterAnnotations();
   552       break;
   553     default:
   554       jj_la1[3] = jj_gen;
   555       jj_consume_token(-1);
   556       throw new ParseException();
   557     }
   558   }
   560   final public void LookaheadAfterAnnotations() throws ParseException {
   561     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   562     case IDENTIFIER:
   563     case ESCAPED_IDENTIFIER:
   564       Identifier();
   565       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   566       case 2:
   567         jj_consume_token(2);
   568         break;
   569       case 3:
   570         jj_consume_token(3);
   571         break;
   572       case 4:
   573         jj_consume_token(4);
   574         break;
   575       default:
   576         jj_la1[4] = jj_gen;
   577         jj_consume_token(-1);
   578         throw new ParseException();
   579       }
   580       break;
   581     case 5:
   582     case 6:
   583     case 7:
   584       LookaheadGrammarKeyword();
   585       break;
   586     default:
   587       jj_la1[5] = jj_gen;
   588       jj_consume_token(-1);
   589       throw new ParseException();
   590     }
   591   }
   593   final public void LookaheadGrammarKeyword() throws ParseException {
   594     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   595     case 5:
   596       jj_consume_token(5);
   597       break;
   598     case 6:
   599       jj_consume_token(6);
   600       break;
   601     case 7:
   602       jj_consume_token(7);
   603       break;
   604     default:
   605       jj_la1[6] = jj_gen;
   606       jj_consume_token(-1);
   607       throw new ParseException();
   608     }
   609   }
   611   final public void LookaheadDocumentation() throws ParseException {
   612     label_1:
   613     while (true) {
   614       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   615       case DOCUMENTATION:
   616         jj_consume_token(DOCUMENTATION);
   617         break;
   618       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
   619         jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT);
   620         break;
   621       default:
   622         jj_la1[7] = jj_gen;
   623         jj_consume_token(-1);
   624         throw new ParseException();
   625       }
   626       label_2:
   627       while (true) {
   628         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   629         case DOCUMENTATION_CONTINUE:
   630           ;
   631           break;
   632         default:
   633           jj_la1[8] = jj_gen;
   634           break label_2;
   635         }
   636         jj_consume_token(DOCUMENTATION_CONTINUE);
   637       }
   638       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   639       case DOCUMENTATION:
   640       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
   641         ;
   642         break;
   643       default:
   644         jj_la1[9] = jj_gen;
   645         break label_1;
   646       }
   647     }
   648   }
   650   final public void LookaheadBody() throws ParseException {
   651     jj_consume_token(1);
   652     label_3:
   653     while (true) {
   654       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   655       case 1:
   656       case 2:
   657       case 5:
   658       case 6:
   659       case 7:
   660       case 8:
   661       case 10:
   662       case 13:
   663       case 14:
   664       case 15:
   665       case 16:
   666       case 17:
   667       case 18:
   668       case 19:
   669       case 26:
   670       case 27:
   671       case 31:
   672       case 32:
   673       case 33:
   674       case 34:
   675       case 35:
   676       case 36:
   677       case IDENTIFIER:
   678       case ESCAPED_IDENTIFIER:
   679       case PREFIXED_NAME:
   680       case LITERAL:
   681         ;
   682         break;
   683       default:
   684         jj_la1[10] = jj_gen;
   685         break label_3;
   686       }
   687       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   688       case PREFIXED_NAME:
   689         jj_consume_token(PREFIXED_NAME);
   690         break;
   691       case 5:
   692       case 6:
   693       case 7:
   694       case 10:
   695       case 13:
   696       case 14:
   697       case 15:
   698       case 16:
   699       case 17:
   700       case 18:
   701       case 19:
   702       case 26:
   703       case 27:
   704       case 31:
   705       case 32:
   706       case 33:
   707       case 34:
   708       case 35:
   709       case 36:
   710       case IDENTIFIER:
   711       case ESCAPED_IDENTIFIER:
   712         UnprefixedName();
   713         break;
   714       case 2:
   715         jj_consume_token(2);
   716         break;
   717       case LITERAL:
   718         jj_consume_token(LITERAL);
   719         break;
   720       case 8:
   721         jj_consume_token(8);
   722         break;
   723       case 1:
   724         LookaheadBody();
   725         break;
   726       default:
   727         jj_la1[11] = jj_gen;
   728         jj_consume_token(-1);
   729         throw new ParseException();
   730       }
   731     }
   732     jj_consume_token(9);
   733   }
   735   final public ParsedPattern IncludedGrammar(IncludedGrammar g) throws ParseException {
   736   Annotations a;
   737   ParsedPattern p;
   738     Preamble();
   739     if (jj_2_2(2147483647)) {
   740       a = GrammarBody(g, g, getTopLevelCommentsAsAnnotations());
   741     } else {
   742       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   743       case 1:
   744       case 10:
   745       case DOCUMENTATION:
   746       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
   747         a = Annotations();
   748         jj_consume_token(10);
   749         jj_consume_token(11);
   750         a = GrammarBody(g, g, a);
   751                                                                 topLevelComments(g);
   752         jj_consume_token(12);
   753         break;
   754       default:
   755         jj_la1[12] = jj_gen;
   756         jj_consume_token(-1);
   757         throw new ParseException();
   758       }
   759     }
   760     p = afterComments(g.endIncludedGrammar(sb.makeLocation(sourceUri, 1, 1), a));
   761     jj_consume_token(0);
   762     {if (true) return p;}
   763     throw new Error("Missing return statement in function");
   764   }
   766   final public ParsedPattern TopLevelGrammar(Scope scope) throws ParseException {
   767   Annotations a = getTopLevelCommentsAsAnnotations();
   768   Grammar g;
   769   ParsedPattern p;
   770     g = sb.makeGrammar(scope);
   771     a = GrammarBody(g, g, a);
   772     p = afterComments(g.endGrammar(sb.makeLocation(sourceUri, 1, 1), a));
   773     jj_consume_token(0);
   774     {if (true) return p;}
   775     throw new Error("Missing return statement in function");
   776   }
   778   final public void Preamble() throws ParseException {
   779     label_4:
   780     while (true) {
   781       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   782       case 13:
   783       case 14:
   784       case 16:
   785         ;
   786         break;
   787       default:
   788         jj_la1[13] = jj_gen;
   789         break label_4;
   790       }
   791       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   792       case 13:
   793       case 14:
   794         NamespaceDecl();
   795         break;
   796       case 16:
   797         DatatypesDecl();
   798         break;
   799       default:
   800         jj_la1[14] = jj_gen;
   801         jj_consume_token(-1);
   802         throw new ParseException();
   803       }
   804     }
   805     namespaceTable.put("xml", WellKnownNamespaces.XML);
   806     if (datatypesTable.get("xsd") == null)
   807       datatypesTable.put("xsd", WellKnownNamespaces.XML_SCHEMA_DATATYPES);
   808   }
   810   final public void NamespaceDecl() throws ParseException {
   811   LocatedString prefix = null;
   812   boolean isDefault = false;
   813   String namespaceName;
   814     noteTopLevelComments();
   815     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   816     case 13:
   817       jj_consume_token(13);
   818       prefix = UnprefixedName();
   819       break;
   820     case 14:
   821       jj_consume_token(14);
   822                    isDefault = true;
   823       jj_consume_token(13);
   824       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   825       case 5:
   826       case 6:
   827       case 7:
   828       case 10:
   829       case 13:
   830       case 14:
   831       case 15:
   832       case 16:
   833       case 17:
   834       case 18:
   835       case 19:
   836       case 26:
   837       case 27:
   838       case 31:
   839       case 32:
   840       case 33:
   841       case 34:
   842       case 35:
   843       case 36:
   844       case IDENTIFIER:
   845       case ESCAPED_IDENTIFIER:
   846         prefix = UnprefixedName();
   847         break;
   848       default:
   849         jj_la1[15] = jj_gen;
   850         ;
   851       }
   852       break;
   853     default:
   854       jj_la1[16] = jj_gen;
   855       jj_consume_token(-1);
   856       throw new ParseException();
   857     }
   858     jj_consume_token(2);
   859     namespaceName = NamespaceName();
   860     if (isDefault)
   861       defaultNamespace = namespaceName;
   862     if (prefix != null) {
   863       if (prefix.getString().equals("xmlns"))
   864         error("xmlns_prefix", prefix.getToken());
   865       else if (prefix.getString().equals("xml")) {
   866         if (!namespaceName.equals(WellKnownNamespaces.XML))
   867           error("xml_prefix_bad_uri", prefix.getToken());
   868       }
   869       else if (namespaceName.equals(WellKnownNamespaces.XML))
   870         error("xml_uri_bad_prefix", prefix.getToken());
   871       else {
   872         if (namespaceName.equals(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS))
   873           compatibilityPrefix = prefix.getString();
   874         namespaceTable.put(prefix.getString(), namespaceName);
   875       }
   876     }
   877   }
   879   final public String NamespaceName() throws ParseException {
   880   String r;
   881     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   882     case LITERAL:
   883       r = Literal();
   884       break;
   885     case 15:
   886       jj_consume_token(15);
   887                                r = this.inheritedNs;
   888       break;
   889     default:
   890       jj_la1[17] = jj_gen;
   891       jj_consume_token(-1);
   892       throw new ParseException();
   893     }
   894     {if (true) return r;}
   895     throw new Error("Missing return statement in function");
   896   }
   898   final public void DatatypesDecl() throws ParseException {
   899   LocatedString prefix;
   900   String uri;
   901     noteTopLevelComments();
   902     jj_consume_token(16);
   903     prefix = UnprefixedName();
   904     jj_consume_token(2);
   905     uri = Literal();
   906     datatypesTable.put(prefix.getString(), uri);
   907   }
   909   final public ParsedPattern AnnotatedPrimaryExpr(boolean topLevel, Scope scope, Token[] except) throws ParseException {
   910   Annotations a;
   911   ParsedPattern p;
   912   ParsedElementAnnotation e;
   913   Token t;
   914     a = Annotations();
   915     p = PrimaryExpr(topLevel, scope, a, except);
   916     label_5:
   917     while (true) {
   918       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   919       case FANNOTATE:
   920         ;
   921         break;
   922       default:
   923         jj_la1[18] = jj_gen;
   924         break label_5;
   925       }
   926       t = jj_consume_token(FANNOTATE);
   927       e = AnnotationElement(false);
   928        if (topLevel)
   929          error("top_level_follow_annotation", t);
   930        else
   931          p = sb.annotateAfter(p, e);
   932     }
   933     {if (true) return p;}
   934     throw new Error("Missing return statement in function");
   935   }
   937   final public ParsedPattern PrimaryExpr(boolean topLevel, Scope scope, Annotations a, Token[] except) throws ParseException {
   938   ParsedPattern p;
   939     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
   940     case 26:
   941       p = ElementExpr(scope, a);
   942       break;
   943     case 27:
   944       p = AttributeExpr(scope, a);
   945       break;
   946     case 10:
   947       p = GrammarExpr(scope, a);
   948       break;
   949     case 33:
   950       p = ExternalRefExpr(scope, a);
   951       break;
   952     case 31:
   953       p = ListExpr(scope, a);
   954       break;
   955     case 32:
   956       p = MixedExpr(scope, a);
   957       break;
   958     case 28:
   959       p = ParenExpr(topLevel, scope, a);
   960       break;
   961     case IDENTIFIER:
   962     case ESCAPED_IDENTIFIER:
   963       p = IdentifierExpr(scope, a);
   964       break;
   965     case 34:
   966       p = ParentExpr(scope, a);
   967       break;
   968     case 35:
   969     case 36:
   970     case PREFIXED_NAME:
   971       p = DataExpr(topLevel, scope, a, except);
   972       break;
   973     case LITERAL:
   974       p = ValueExpr(topLevel, a);
   975       break;
   976     case 18:
   977       p = TextExpr(a);
   978       break;
   979     case 17:
   980       p = EmptyExpr(a);
   981       break;
   982     case 19:
   983       p = NotAllowedExpr(a);
   984       break;
   985     default:
   986       jj_la1[19] = jj_gen;
   987       jj_consume_token(-1);
   988       throw new ParseException();
   989     }
   990     {if (true) return p;}
   991     throw new Error("Missing return statement in function");
   992   }
   994   final public ParsedPattern EmptyExpr(Annotations a) throws ParseException {
   995   Token t;
   996     t = jj_consume_token(17);
   997     {if (true) return sb.makeEmpty(makeLocation(t), a);}
   998     throw new Error("Missing return statement in function");
   999   }
  1001   final public ParsedPattern TextExpr(Annotations a) throws ParseException {
  1002   Token t;
  1003     t = jj_consume_token(18);
  1004     {if (true) return sb.makeText(makeLocation(t), a);}
  1005     throw new Error("Missing return statement in function");
  1008   final public ParsedPattern NotAllowedExpr(Annotations a) throws ParseException {
  1009   Token t;
  1010     t = jj_consume_token(19);
  1011     {if (true) return sb.makeNotAllowed(makeLocation(t), a);}
  1012     throw new Error("Missing return statement in function");
  1015   final public ParsedPattern Expr(boolean topLevel, Scope scope, Token t, Annotations a) throws ParseException {
  1016   List patterns = new ArrayList();
  1017   ParsedPattern p;
  1018   boolean[] hadOccur = new boolean[1];
  1019   Token[] except = new Token[1];
  1020     p = UnaryExpr(topLevel, scope, hadOccur, except);
  1021     patterns.add(p);
  1022     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1023     case 20:
  1024     case 21:
  1025     case 22:
  1026       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1027       case 20:
  1028      checkExcept(except);
  1029         label_6:
  1030         while (true) {
  1031           t = jj_consume_token(20);
  1032           p = UnaryExpr(topLevel, scope, null, except);
  1033        patterns.add(p); checkExcept(except);
  1034           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1035           case 20:
  1037             break;
  1038           default:
  1039             jj_la1[20] = jj_gen;
  1040             break label_6;
  1043       p = sb.makeChoice(patterns, makeLocation(t), a);
  1044         break;
  1045       case 21:
  1046         label_7:
  1047         while (true) {
  1048           t = jj_consume_token(21);
  1049           p = UnaryExpr(topLevel, scope, null, except);
  1050        patterns.add(p); checkExcept(except);
  1051           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1052           case 21:
  1054             break;
  1055           default:
  1056             jj_la1[21] = jj_gen;
  1057             break label_7;
  1060       p = sb.makeInterleave(patterns, makeLocation(t), a);
  1061         break;
  1062       case 22:
  1063         label_8:
  1064         while (true) {
  1065           t = jj_consume_token(22);
  1066           p = UnaryExpr(topLevel, scope, null, except);
  1067        patterns.add(p); checkExcept(except);
  1068           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1069           case 22:
  1071             break;
  1072           default:
  1073             jj_la1[22] = jj_gen;
  1074             break label_8;
  1077       p = sb.makeGroup(patterns, makeLocation(t), a);
  1078         break;
  1079       default:
  1080         jj_la1[23] = jj_gen;
  1081         jj_consume_token(-1);
  1082         throw new ParseException();
  1084       break;
  1085     default:
  1086       jj_la1[24] = jj_gen;
  1089     if (patterns.size() == 1 && a != null) {
  1090       if (hadOccur[0])
  1091         p = sb.annotate(p, a);
  1092       else
  1093         p = sb.makeGroup(patterns, makeLocation(t), a);
  1095     {if (true) return p;}
  1096     throw new Error("Missing return statement in function");
  1099   final public ParsedPattern UnaryExpr(boolean topLevel, Scope scope, boolean[] hadOccur, Token[] except) throws ParseException {
  1100   ParsedPattern p;
  1101   Token t;
  1102   ParsedElementAnnotation e;
  1103     p = AnnotatedPrimaryExpr(topLevel, scope, except);
  1104     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1105     case 23:
  1106     case 24:
  1107     case 25:
  1108      if (hadOccur != null) hadOccur[0] = true;
  1109      p = afterComments(p);
  1110       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1111       case 23:
  1112         t = jj_consume_token(23);
  1113               checkExcept(except); p = sb.makeOneOrMore(p, makeLocation(t), null);
  1114         break;
  1115       case 24:
  1116         t = jj_consume_token(24);
  1117                 checkExcept(except); p = sb.makeOptional(p, makeLocation(t), null);
  1118         break;
  1119       case 25:
  1120         t = jj_consume_token(25);
  1121                 checkExcept(except); p = sb.makeZeroOrMore(p, makeLocation(t), null);
  1122         break;
  1123       default:
  1124         jj_la1[25] = jj_gen;
  1125         jj_consume_token(-1);
  1126         throw new ParseException();
  1128       label_9:
  1129       while (true) {
  1130         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1131         case FANNOTATE:
  1133           break;
  1134         default:
  1135           jj_la1[26] = jj_gen;
  1136           break label_9;
  1138         t = jj_consume_token(FANNOTATE);
  1139         e = AnnotationElement(false);
  1140         if (topLevel)
  1141           error("top_level_follow_annotation", t);
  1142         else
  1143           p = sb.annotateAfter(p, e);
  1145       break;
  1146     default:
  1147       jj_la1[27] = jj_gen;
  1150     {if (true) return p;}
  1151     throw new Error("Missing return statement in function");
  1154   final public ParsedPattern ElementExpr(Scope scope, Annotations a) throws ParseException {
  1155   Token t;
  1156   ParsedNameClass nc;
  1157   ParsedPattern p;
  1158     t = jj_consume_token(26);
  1159     nc = NameClass(IN_ELEMENT, null);
  1160     jj_consume_token(11);
  1161     p = Expr(false, scope, null, null);
  1162     p = afterComments(p);
  1163     jj_consume_token(12);
  1164     {if (true) return sb.makeElement(nc, p, makeLocation(t), a);}
  1165     throw new Error("Missing return statement in function");
  1168   final public ParsedPattern AttributeExpr(Scope scope, Annotations a) throws ParseException {
  1169   Token t;
  1170   ParsedNameClass nc;
  1171   ParsedPattern p;
  1172     t = jj_consume_token(27);
  1173     nc = NameClass(IN_ATTRIBUTE, null);
  1174     jj_consume_token(11);
  1175     p = Expr(false, scope, null, null);
  1176     p = afterComments(p);
  1177     jj_consume_token(12);
  1178     {if (true) return sb.makeAttribute(nc, p, makeLocation(t), a);}
  1179     throw new Error("Missing return statement in function");
  1182   final public ParsedNameClass NameClass(int context, Annotations[] pa) throws ParseException {
  1183   Annotations a;
  1184   ParsedNameClass nc;
  1185     a = Annotations();
  1186     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1187     case 5:
  1188     case 6:
  1189     case 7:
  1190     case 10:
  1191     case 13:
  1192     case 14:
  1193     case 15:
  1194     case 16:
  1195     case 17:
  1196     case 18:
  1197     case 19:
  1198     case 26:
  1199     case 27:
  1200     case 28:
  1201     case 31:
  1202     case 32:
  1203     case 33:
  1204     case 34:
  1205     case 35:
  1206     case 36:
  1207     case IDENTIFIER:
  1208     case ESCAPED_IDENTIFIER:
  1209     case PREFIXED_NAME:
  1210       nc = PrimaryNameClass(context, a);
  1211       nc = AnnotateAfter(nc);
  1212       nc = NameClassAlternatives(context, nc, pa);
  1213       break;
  1214     case 25:
  1215       nc = AnyNameExceptClass(context, a, pa);
  1216       break;
  1217     case PREFIX_STAR:
  1218       nc = NsNameExceptClass(context, a, pa);
  1219       break;
  1220     default:
  1221       jj_la1[28] = jj_gen;
  1222       jj_consume_token(-1);
  1223       throw new ParseException();
  1225     {if (true) return nc;}
  1226     throw new Error("Missing return statement in function");
  1229   final public ParsedNameClass AnnotateAfter(ParsedNameClass nc) throws ParseException {
  1230   ParsedElementAnnotation e;
  1231     label_10:
  1232     while (true) {
  1233       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1234       case FANNOTATE:
  1236         break;
  1237       default:
  1238         jj_la1[29] = jj_gen;
  1239         break label_10;
  1241       jj_consume_token(FANNOTATE);
  1242       e = AnnotationElement(false);
  1243                                                nc = ncb.annotateAfter(nc, e);
  1245     {if (true) return nc;}
  1246     throw new Error("Missing return statement in function");
  1249   final public ParsedNameClass NameClassAlternatives(int context, ParsedNameClass nc, Annotations[] pa) throws ParseException {
  1250   Token t;
  1251   ParsedNameClass[] nameClasses;
  1252   int nNameClasses;
  1253     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1254     case 20:
  1255       nameClasses = new ParsedNameClass[2];
  1256       nameClasses[0] = nc;
  1257       nNameClasses = 1;
  1258       label_11:
  1259       while (true) {
  1260         t = jj_consume_token(20);
  1261         nc = BasicNameClass(context);
  1262         nc = AnnotateAfter(nc);
  1263       if (nNameClasses >= nameClasses.length) {
  1264         ParsedNameClass[] oldNameClasses = nameClasses;
  1265         nameClasses = new ParsedNameClass[oldNameClasses.length*2];
  1266         System.arraycopy(oldNameClasses, 0, nameClasses, 0, oldNameClasses.length);
  1268       nameClasses[nNameClasses++] = nc;
  1269         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1270         case 20:
  1272           break;
  1273         default:
  1274           jj_la1[30] = jj_gen;
  1275           break label_11;
  1278       Annotations a;
  1279       if (pa == null)
  1280         a = null;
  1281       else {
  1282         a = pa[0];
  1283         pa[0] = null;
  1285       nc = ncb.makeChoice(Arrays.asList(nameClasses).subList(0,nNameClasses), makeLocation(t), a);
  1286       break;
  1287     default:
  1288       jj_la1[31] = jj_gen;
  1291     {if (true) return nc;}
  1292     throw new Error("Missing return statement in function");
  1295   final public ParsedNameClass BasicNameClass(int context) throws ParseException {
  1296   Annotations a;
  1297   ParsedNameClass nc;
  1298     a = Annotations();
  1299     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1300     case 5:
  1301     case 6:
  1302     case 7:
  1303     case 10:
  1304     case 13:
  1305     case 14:
  1306     case 15:
  1307     case 16:
  1308     case 17:
  1309     case 18:
  1310     case 19:
  1311     case 26:
  1312     case 27:
  1313     case 28:
  1314     case 31:
  1315     case 32:
  1316     case 33:
  1317     case 34:
  1318     case 35:
  1319     case 36:
  1320     case IDENTIFIER:
  1321     case ESCAPED_IDENTIFIER:
  1322     case PREFIXED_NAME:
  1323       nc = PrimaryNameClass(context, a);
  1324       break;
  1325     case 25:
  1326     case PREFIX_STAR:
  1327       nc = OpenNameClass(context, a);
  1328       break;
  1329     default:
  1330       jj_la1[32] = jj_gen;
  1331       jj_consume_token(-1);
  1332       throw new ParseException();
  1334     {if (true) return nc;}
  1335     throw new Error("Missing return statement in function");
  1338   final public ParsedNameClass PrimaryNameClass(int context, Annotations a) throws ParseException {
  1339   ParsedNameClass nc;
  1340     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1341     case 5:
  1342     case 6:
  1343     case 7:
  1344     case 10:
  1345     case 13:
  1346     case 14:
  1347     case 15:
  1348     case 16:
  1349     case 17:
  1350     case 18:
  1351     case 19:
  1352     case 26:
  1353     case 27:
  1354     case 31:
  1355     case 32:
  1356     case 33:
  1357     case 34:
  1358     case 35:
  1359     case 36:
  1360     case IDENTIFIER:
  1361     case ESCAPED_IDENTIFIER:
  1362       nc = UnprefixedNameClass(context, a);
  1363       break;
  1364     case PREFIXED_NAME:
  1365       nc = PrefixedNameClass(a);
  1366       break;
  1367     case 28:
  1368       nc = ParenNameClass(context, a);
  1369       break;
  1370     default:
  1371       jj_la1[33] = jj_gen;
  1372       jj_consume_token(-1);
  1373       throw new ParseException();
  1375     {if (true) return nc;}
  1376     throw new Error("Missing return statement in function");
  1379   final public ParsedNameClass OpenNameClass(int context, Annotations a) throws ParseException {
  1380   Token t;
  1381   LocatedString ns;
  1382     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1383     case PREFIX_STAR:
  1384       ns = NsName();
  1385                   checkNsName(context, ns); {if (true) return ncb.makeNsName(ns.getString(), ns.getLocation(), a);}
  1386       break;
  1387     case 25:
  1388       t = jj_consume_token(25);
  1389               checkAnyName(context, t); {if (true) return ncb.makeAnyName(makeLocation(t), a);}
  1390       break;
  1391     default:
  1392       jj_la1[34] = jj_gen;
  1393       jj_consume_token(-1);
  1394       throw new ParseException();
  1396     throw new Error("Missing return statement in function");
  1399   final public ParsedNameClass UnprefixedNameClass(int context, Annotations a) throws ParseException {
  1400   LocatedString name;
  1401     name = UnprefixedName();
  1402     String ns;
  1403     if ((context & (IN_ATTRIBUTE|IN_ELEMENT)) == IN_ATTRIBUTE)
  1404       ns = "";
  1405     else
  1406       ns = defaultNamespace;
  1407     {if (true) return ncb.makeName(ns, name.getString(), null, name.getLocation(), a);}
  1408     throw new Error("Missing return statement in function");
  1411   final public ParsedNameClass PrefixedNameClass(Annotations a) throws ParseException {
  1412   Token t;
  1413     t = jj_consume_token(PREFIXED_NAME);
  1414     String qn = t.image;
  1415     int colon = qn.indexOf(':');
  1416     String prefix = qn.substring(0, colon);
  1417     {if (true) return ncb.makeName(lookupPrefix(prefix, t), qn.substring(colon + 1), prefix, makeLocation(t), a);}
  1418     throw new Error("Missing return statement in function");
  1421   final public ParsedNameClass NsNameExceptClass(int context, Annotations a, Annotations[] pa) throws ParseException {
  1422   LocatedString ns;
  1423   ParsedNameClass nc;
  1424     ns = NsName();
  1425     checkNsName(context, ns);
  1426     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1427     case 30:
  1428       nc = ExceptNameClass(context | IN_NS_NAME);
  1429      nc = ncb.makeNsName(ns.getString(), nc, ns.getLocation(), a);
  1430       nc = AnnotateAfter(nc);
  1431       break;
  1432     default:
  1433       jj_la1[35] = jj_gen;
  1434       nc = ncb.makeNsName(ns.getString(), ns.getLocation(), a);
  1435       nc = AnnotateAfter(nc);
  1436       nc = NameClassAlternatives(context, nc, pa);
  1438     {if (true) return nc;}
  1439     throw new Error("Missing return statement in function");
  1442   final public LocatedString NsName() throws ParseException {
  1443   Token t;
  1444     t = jj_consume_token(PREFIX_STAR);
  1445     String qn = t.image;
  1446     String prefix = qn.substring(0, qn.length() - 2);
  1447     {if (true) return new LocatedString(lookupPrefix(prefix, t), t);}
  1448     throw new Error("Missing return statement in function");
  1451   final public ParsedNameClass AnyNameExceptClass(int context, Annotations a, Annotations[] pa) throws ParseException {
  1452   Token t;
  1453   ParsedNameClass nc;
  1454     t = jj_consume_token(25);
  1455     checkAnyName(context, t);
  1456     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1457     case 30:
  1458       nc = ExceptNameClass(context | IN_ANY_NAME);
  1459      nc = ncb.makeAnyName(nc, makeLocation(t), a);
  1460       nc = AnnotateAfter(nc);
  1461       break;
  1462     default:
  1463       jj_la1[36] = jj_gen;
  1464       nc = ncb.makeAnyName(makeLocation(t), a);
  1465       nc = AnnotateAfter(nc);
  1466       nc = NameClassAlternatives(context, nc, pa);
  1468     {if (true) return nc;}
  1469     throw new Error("Missing return statement in function");
  1472   final public ParsedNameClass ParenNameClass(int context, Annotations a) throws ParseException {
  1473   Token t;
  1474   ParsedNameClass nc;
  1475   Annotations[] pa = new Annotations[]{ a };
  1476     t = jj_consume_token(28);
  1477     nc = NameClass(context, pa);
  1478                                         nc = afterComments(nc);
  1479     jj_consume_token(29);
  1480     if (pa[0] != null)
  1481       nc = ncb.makeChoice(Collections.singletonList(nc), makeLocation(t), pa[0]);
  1482     {if (true) return nc;}
  1483     throw new Error("Missing return statement in function");
  1486   final public ParsedNameClass ExceptNameClass(int context) throws ParseException {
  1487   ParsedNameClass nc;
  1488     jj_consume_token(30);
  1489     nc = BasicNameClass(context);
  1490     {if (true) return nc;}
  1491     throw new Error("Missing return statement in function");
  1494   final public ParsedPattern ListExpr(Scope scope, Annotations a) throws ParseException {
  1495   Token t;
  1496   ParsedPattern p;
  1497     t = jj_consume_token(31);
  1498     jj_consume_token(11);
  1499     p = Expr(false, scope, null, null);
  1500     p = afterComments(p);
  1501     jj_consume_token(12);
  1502     {if (true) return sb.makeList(p, makeLocation(t), a);}
  1503     throw new Error("Missing return statement in function");
  1506   final public ParsedPattern MixedExpr(Scope scope, Annotations a) throws ParseException {
  1507   Token t;
  1508   ParsedPattern p;
  1509     t = jj_consume_token(32);
  1510     jj_consume_token(11);
  1511     p = Expr(false, scope, null, null);
  1512     p = afterComments(p);
  1513     jj_consume_token(12);
  1514     {if (true) return sb.makeMixed(p, makeLocation(t), a);}
  1515     throw new Error("Missing return statement in function");
  1518   final public ParsedPattern GrammarExpr(Scope scope, Annotations a) throws ParseException {
  1519   Token t;
  1520   Grammar g;
  1521     t = jj_consume_token(10);
  1522                   g = sb.makeGrammar(scope);
  1523     jj_consume_token(11);
  1524     a = GrammarBody(g, g, a);
  1525                                  topLevelComments(g);
  1526     jj_consume_token(12);
  1527     {if (true) return g.endGrammar(makeLocation(t), a);}
  1528     throw new Error("Missing return statement in function");
  1531   final public ParsedPattern ParenExpr(boolean topLevel, Scope scope, Annotations a) throws ParseException {
  1532   Token t;
  1533   ParsedPattern p;
  1534     t = jj_consume_token(28);
  1535     p = Expr(topLevel, scope, t, a);
  1536                                             p = afterComments(p);
  1537     jj_consume_token(29);
  1538     {if (true) return p;}
  1539     throw new Error("Missing return statement in function");
  1542   final public Annotations GrammarBody(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1543   ParsedElementAnnotation e;
  1544     label_12:
  1545     while (true) {
  1546       if (jj_2_3(2)) {
  1548       } else {
  1549         break label_12;
  1551       e = AnnotationElementNotKeyword();
  1552      if (a == null) a = sb.makeAnnotations(null, getContext()); a.addElement(e);
  1554     label_13:
  1555     while (true) {
  1556       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1557       case 1:
  1558       case 5:
  1559       case 6:
  1560       case 7:
  1561       case DOCUMENTATION:
  1562       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  1563       case IDENTIFIER:
  1564       case ESCAPED_IDENTIFIER:
  1566         break;
  1567       default:
  1568         jj_la1[37] = jj_gen;
  1569         break label_13;
  1571       GrammarComponent(section, scope);
  1573     {if (true) return a;}
  1574     throw new Error("Missing return statement in function");
  1577   final public void GrammarComponent(GrammarSection section, Scope scope) throws ParseException {
  1578   ParsedElementAnnotation e;
  1579   Annotations a;
  1580     a = Annotations();
  1581     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1582     case 5:
  1583     case IDENTIFIER:
  1584     case ESCAPED_IDENTIFIER:
  1585       Definition(section, scope, a);
  1586       break;
  1587     case 7:
  1588       Include(section, scope, a);
  1589       break;
  1590     case 6:
  1591       Div(section, scope, a);
  1592       break;
  1593     default:
  1594       jj_la1[38] = jj_gen;
  1595       jj_consume_token(-1);
  1596       throw new ParseException();
  1598     label_14:
  1599     while (true) {
  1600       if (jj_2_4(2)) {
  1602       } else {
  1603         break label_14;
  1605       e = AnnotationElementNotKeyword();
  1606                                                     section.topLevelAnnotation(e);
  1610   final public void Definition(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1611     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1612     case IDENTIFIER:
  1613     case ESCAPED_IDENTIFIER:
  1614       Define(section, scope, a);
  1615       break;
  1616     case 5:
  1617       Start(section, scope, a);
  1618       break;
  1619     default:
  1620       jj_la1[39] = jj_gen;
  1621       jj_consume_token(-1);
  1622       throw new ParseException();
  1626   final public void Start(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1627   Token t;
  1628   GrammarSection.Combine combine;
  1629   ParsedPattern p;
  1630     t = jj_consume_token(5);
  1631     combine = AssignOp();
  1632     p = Expr(false, scope, null, null);
  1633     section.define(GrammarSection.START, combine, p, makeLocation(t), a);
  1636   final public void Define(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1637   LocatedString name;
  1638   GrammarSection.Combine combine;
  1639   ParsedPattern p;
  1640     name = Identifier();
  1641     combine = AssignOp();
  1642     p = Expr(false, scope, null, null);
  1643     section.define(name.getString(), combine, p, name.getLocation(), a);
  1646   final public GrammarSection.Combine AssignOp() throws ParseException {
  1647     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1648     case 2:
  1649       jj_consume_token(2);
  1650         {if (true) return null;}
  1651       break;
  1652     case 4:
  1653       jj_consume_token(4);
  1654            {if (true) return GrammarSection.COMBINE_CHOICE;}
  1655       break;
  1656     case 3:
  1657       jj_consume_token(3);
  1658            {if (true) return GrammarSection.COMBINE_INTERLEAVE;}
  1659       break;
  1660     default:
  1661       jj_la1[40] = jj_gen;
  1662       jj_consume_token(-1);
  1663       throw new ParseException();
  1665     throw new Error("Missing return statement in function");
  1668   final public void Include(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1669   Token t;
  1670   String href;
  1671   String ns;
  1672   Include include = section.makeInclude();
  1673     t = jj_consume_token(7);
  1674     href = Literal();
  1675     ns = Inherit();
  1676     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1677     case 11:
  1678       jj_consume_token(11);
  1679       a = IncludeBody(include, scope, a);
  1680                                             topLevelComments(include);
  1681       jj_consume_token(12);
  1682       break;
  1683     default:
  1684       jj_la1[41] = jj_gen;
  1687     try {
  1688       include.endInclude(parseable, resolve(href), ns, makeLocation(t), a);
  1690     catch (IllegalSchemaException e) { }
  1693   final public Annotations IncludeBody(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1694   ParsedElementAnnotation e;
  1695     label_15:
  1696     while (true) {
  1697       if (jj_2_5(2)) {
  1699       } else {
  1700         break label_15;
  1702       e = AnnotationElementNotKeyword();
  1703      if (a == null) a = sb.makeAnnotations(null, getContext()); a.addElement(e);
  1705     label_16:
  1706     while (true) {
  1707       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1708       case 1:
  1709       case 5:
  1710       case 6:
  1711       case DOCUMENTATION:
  1712       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  1713       case IDENTIFIER:
  1714       case ESCAPED_IDENTIFIER:
  1716         break;
  1717       default:
  1718         jj_la1[42] = jj_gen;
  1719         break label_16;
  1721       IncludeComponent(section, scope);
  1723     {if (true) return a;}
  1724     throw new Error("Missing return statement in function");
  1727   final public void IncludeComponent(GrammarSection section, Scope scope) throws ParseException {
  1728   ParsedElementAnnotation e;
  1729   Annotations a;
  1730     a = Annotations();
  1731     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1732     case 5:
  1733     case IDENTIFIER:
  1734     case ESCAPED_IDENTIFIER:
  1735       Definition(section, scope, a);
  1736       break;
  1737     case 6:
  1738       IncludeDiv(section, scope, a);
  1739       break;
  1740     default:
  1741       jj_la1[43] = jj_gen;
  1742       jj_consume_token(-1);
  1743       throw new ParseException();
  1745     label_17:
  1746     while (true) {
  1747       if (jj_2_6(2)) {
  1749       } else {
  1750         break label_17;
  1752       e = AnnotationElementNotKeyword();
  1753                                                     section.topLevelAnnotation(e);
  1757   final public void Div(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1758   Token t;
  1759   Div div = section.makeDiv();
  1760     t = jj_consume_token(6);
  1761     jj_consume_token(11);
  1762     a = GrammarBody(div, scope, a);
  1763                                                  topLevelComments(div);
  1764     jj_consume_token(12);
  1765     div.endDiv(makeLocation(t), a);
  1768   final public void IncludeDiv(GrammarSection section, Scope scope, Annotations a) throws ParseException {
  1769   Token t;
  1770   Div div = section.makeDiv();
  1771     t = jj_consume_token(6);
  1772     jj_consume_token(11);
  1773     a = IncludeBody(div, scope, a);
  1774                                                  topLevelComments(div);
  1775     jj_consume_token(12);
  1776     div.endDiv(makeLocation(t), a);
  1779   final public ParsedPattern ExternalRefExpr(Scope scope, Annotations a) throws ParseException {
  1780   Token t;
  1781   String href;
  1782   String ns;
  1783     t = jj_consume_token(33);
  1784     href = Literal();
  1785     ns = Inherit();
  1786     try {
  1787       {if (true) return sb.makeExternalRef(parseable, resolve(href), ns, scope, makeLocation(t), a);}
  1789     catch (IllegalSchemaException e) {
  1790       {if (true) return sb.makeErrorPattern();}
  1792     throw new Error("Missing return statement in function");
  1795   final public String Inherit() throws ParseException {
  1796   String ns = null;
  1797     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1798     case 15:
  1799       jj_consume_token(15);
  1800       jj_consume_token(2);
  1801       ns = Prefix();
  1802       break;
  1803     default:
  1804       jj_la1[44] = jj_gen;
  1807     if (ns == null)
  1808       ns = defaultNamespace;
  1809     {if (true) return ns;}
  1810     throw new Error("Missing return statement in function");
  1813   final public ParsedPattern ParentExpr(Scope scope, Annotations a) throws ParseException {
  1814   LocatedString name;
  1815     jj_consume_token(34);
  1816              a = addCommentsToChildAnnotations(a);
  1817     name = Identifier();
  1818     if(scope==null) {
  1819       error("parent_ref_outside_grammar",name.getToken());
  1820       {if (true) return sb.makeErrorPattern();}
  1821     } else {
  1822       {if (true) return scope.makeParentRef(name.getString(), name.getLocation(), a);}
  1824     throw new Error("Missing return statement in function");
  1827   final public ParsedPattern IdentifierExpr(Scope scope, Annotations a) throws ParseException {
  1828   LocatedString name;
  1829     name = Identifier();
  1830     if(scope==null) {
  1831       error("ref_outside_grammar",name.getToken());
  1832       {if (true) return sb.makeErrorPattern();}
  1833     } else {
  1834       {if (true) return scope.makeRef(name.getString(), name.getLocation(), a);}
  1836     throw new Error("Missing return statement in function");
  1839   final public ParsedPattern ValueExpr(boolean topLevel, Annotations a) throws ParseException {
  1840   LocatedString s;
  1841     s = LocatedLiteral();
  1842     if (topLevel && annotationsIncludeElements) {
  1843       error("top_level_follow_annotation", s.getToken());
  1844       a = null;
  1846     {if (true) return sb.makeValue("", "token", s.getString(), getContext(), defaultNamespace, s.getLocation(), a);}
  1847     throw new Error("Missing return statement in function");
  1850   final public ParsedPattern DataExpr(boolean topLevel, Scope scope, Annotations a, Token[] except) throws ParseException {
  1851   Token datatypeToken;
  1852   Location loc;
  1853   String datatype;
  1854   String datatypeUri = null;
  1855   String s = null;
  1856   ParsedPattern e = null;
  1857   DataPatternBuilder dpb;
  1858     datatypeToken = DatatypeName();
  1859     datatype = datatypeToken.image;
  1860     loc = makeLocation(datatypeToken);
  1861     int colon = datatype.indexOf(':');
  1862     if (colon < 0)
  1863       datatypeUri = "";
  1864     else {
  1865       String prefix = datatype.substring(0, colon);
  1866       datatypeUri = lookupDatatype(prefix, datatypeToken);
  1867       datatype = datatype.substring(colon + 1);
  1869     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1870     case LITERAL:
  1871       s = Literal();
  1872       if (topLevel && annotationsIncludeElements) {
  1873         error("top_level_follow_annotation", datatypeToken);
  1874         a = null;
  1876       {if (true) return sb.makeValue(datatypeUri, datatype, s, getContext(), defaultNamespace, loc, a);}
  1877       break;
  1878     default:
  1879       jj_la1[48] = jj_gen;
  1880         dpb = sb.makeDataPatternBuilder(datatypeUri, datatype, loc);
  1881       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1882       case 11:
  1883         Params(dpb);
  1884         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1885         case 30:
  1886           e = Except(scope, except);
  1887           break;
  1888         default:
  1889           jj_la1[45] = jj_gen;
  1892         break;
  1893       default:
  1894         jj_la1[47] = jj_gen;
  1895         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1896         case 30:
  1897           e = Except(scope, except);
  1898           break;
  1899         default:
  1900           jj_la1[46] = jj_gen;
  1904         {if (true) return e == null ? dpb.makePattern(loc, a) : dpb.makePattern(e, loc, a);}
  1906     throw new Error("Missing return statement in function");
  1909   final public Token DatatypeName() throws ParseException {
  1910   Token t;
  1911     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1912     case 35:
  1913       t = jj_consume_token(35);
  1914       break;
  1915     case 36:
  1916       t = jj_consume_token(36);
  1917       break;
  1918     case PREFIXED_NAME:
  1919       t = jj_consume_token(PREFIXED_NAME);
  1920       break;
  1921     default:
  1922       jj_la1[49] = jj_gen;
  1923       jj_consume_token(-1);
  1924       throw new ParseException();
  1926     {if (true) return t;}
  1927     throw new Error("Missing return statement in function");
  1930   final public LocatedString Identifier() throws ParseException {
  1931   LocatedString s;
  1932   Token t;
  1933     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1934     case IDENTIFIER:
  1935       t = jj_consume_token(IDENTIFIER);
  1936                       s = new LocatedString(t.image, t);
  1937       break;
  1938     case ESCAPED_IDENTIFIER:
  1939       t = jj_consume_token(ESCAPED_IDENTIFIER);
  1940                                s = new LocatedString(t.image.substring(1), t);
  1941       break;
  1942     default:
  1943       jj_la1[50] = jj_gen;
  1944       jj_consume_token(-1);
  1945       throw new ParseException();
  1947     {if (true) return s;}
  1948     throw new Error("Missing return statement in function");
  1951   final public String Prefix() throws ParseException {
  1952   Token t;
  1953   String prefix;
  1954     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1955     case IDENTIFIER:
  1956       t = jj_consume_token(IDENTIFIER);
  1957                       prefix = t.image;
  1958       break;
  1959     case ESCAPED_IDENTIFIER:
  1960       t = jj_consume_token(ESCAPED_IDENTIFIER);
  1961                                prefix = t.image.substring(1);
  1962       break;
  1963     case 5:
  1964     case 6:
  1965     case 7:
  1966     case 10:
  1967     case 13:
  1968     case 14:
  1969     case 15:
  1970     case 16:
  1971     case 17:
  1972     case 18:
  1973     case 19:
  1974     case 26:
  1975     case 27:
  1976     case 31:
  1977     case 32:
  1978     case 33:
  1979     case 34:
  1980     case 35:
  1981     case 36:
  1982       t = Keyword();
  1983                     prefix = t.image;
  1984       break;
  1985     default:
  1986       jj_la1[51] = jj_gen;
  1987       jj_consume_token(-1);
  1988       throw new ParseException();
  1990     {if (true) return lookupPrefix(prefix, t);}
  1991     throw new Error("Missing return statement in function");
  1994   final public LocatedString UnprefixedName() throws ParseException {
  1995   LocatedString s;
  1996   Token t;
  1997     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  1998     case IDENTIFIER:
  1999     case ESCAPED_IDENTIFIER:
  2000       s = Identifier();
  2001       break;
  2002     case 5:
  2003     case 6:
  2004     case 7:
  2005     case 10:
  2006     case 13:
  2007     case 14:
  2008     case 15:
  2009     case 16:
  2010     case 17:
  2011     case 18:
  2012     case 19:
  2013     case 26:
  2014     case 27:
  2015     case 31:
  2016     case 32:
  2017     case 33:
  2018     case 34:
  2019     case 35:
  2020     case 36:
  2021       t = Keyword();
  2022                      s = new LocatedString(t.image, t);
  2023       break;
  2024     default:
  2025       jj_la1[52] = jj_gen;
  2026       jj_consume_token(-1);
  2027       throw new ParseException();
  2029     {if (true) return s;}
  2030     throw new Error("Missing return statement in function");
  2033   final public void Params(DataPatternBuilder dpb) throws ParseException {
  2034     jj_consume_token(11);
  2035     label_18:
  2036     while (true) {
  2037       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2038       case 1:
  2039       case 5:
  2040       case 6:
  2041       case 7:
  2042       case 10:
  2043       case 13:
  2044       case 14:
  2045       case 15:
  2046       case 16:
  2047       case 17:
  2048       case 18:
  2049       case 19:
  2050       case 26:
  2051       case 27:
  2052       case 31:
  2053       case 32:
  2054       case 33:
  2055       case 34:
  2056       case 35:
  2057       case 36:
  2058       case DOCUMENTATION:
  2059       case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  2060       case IDENTIFIER:
  2061       case ESCAPED_IDENTIFIER:
  2063         break;
  2064       default:
  2065         jj_la1[53] = jj_gen;
  2066         break label_18;
  2068       Param(dpb);
  2070     jj_consume_token(12);
  2073   final public void Param(DataPatternBuilder dpb) throws ParseException {
  2074   LocatedString name;
  2075   Annotations a;
  2076   String value;
  2077     a = Annotations();
  2078     name = UnprefixedName();
  2079     jj_consume_token(2);
  2080                                                   a = addCommentsToLeadingAnnotations(a);
  2081     value = Literal();
  2082     dpb.addParam(name.getString(), value, getContext(), defaultNamespace, name.getLocation(), a);
  2085   final public ParsedPattern Except(Scope scope, Token[] except) throws ParseException {
  2086   Annotations a;
  2087   ParsedPattern p;
  2088   Token t;
  2089   Token[] innerExcept = new Token[1];
  2090     t = jj_consume_token(30);
  2091     a = Annotations();
  2092     p = PrimaryExpr(false, scope, a, innerExcept);
  2093     checkExcept(innerExcept);
  2094     except[0] = t;
  2095     {if (true) return p;}
  2096     throw new Error("Missing return statement in function");
  2099   final public ParsedElementAnnotation Documentation() throws ParseException {
  2100   CommentList comments = getComments();
  2101   ElementAnnotationBuilder eab;
  2102   Token t;
  2103     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2104     case DOCUMENTATION:
  2105       t = jj_consume_token(DOCUMENTATION);
  2106       break;
  2107     case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  2108       t = jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT);
  2109       break;
  2110     default:
  2111       jj_la1[54] = jj_gen;
  2112       jj_consume_token(-1);
  2113       throw new ParseException();
  2115     eab = sb.makeElementAnnotationBuilder(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS,
  2116                                           "documentation",
  2117                                           getCompatibilityPrefix(),
  2118                                           makeLocation(t),
  2119                                           comments,
  2120                                           getContext());
  2121     eab.addText(mungeComment(t.image), makeLocation(t), null);
  2122     label_19:
  2123     while (true) {
  2124       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2125       case DOCUMENTATION_CONTINUE:
  2127         break;
  2128       default:
  2129         jj_la1[55] = jj_gen;
  2130         break label_19;
  2132       t = jj_consume_token(DOCUMENTATION_CONTINUE);
  2133                                   eab.addText("\u005cn" + mungeComment(t.image), makeLocation(t), null);
  2135     {if (true) return eab.makeElementAnnotation();}
  2136     throw new Error("Missing return statement in function");
  2139   final public Annotations Annotations() throws ParseException {
  2140   CommentList comments = getComments();
  2141   Annotations a = null;
  2142   ParsedElementAnnotation e;
  2143     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2144     case DOCUMENTATION:
  2145     case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  2146       a = sb.makeAnnotations(comments, getContext());
  2147       label_20:
  2148       while (true) {
  2149         e = Documentation();
  2150                            a.addElement(e);
  2151         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2152         case DOCUMENTATION:
  2153         case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
  2155           break;
  2156         default:
  2157           jj_la1[56] = jj_gen;
  2158           break label_20;
  2161       comments = getComments();
  2162       if (comments != null)
  2163         a.addLeadingComment(comments);
  2164       break;
  2165     default:
  2166       jj_la1[57] = jj_gen;
  2169     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2170     case 1:
  2171       jj_consume_token(1);
  2172          if (a == null) a = sb.makeAnnotations(comments, getContext()); clearAttributeList(); annotationsIncludeElements = false;
  2173       label_21:
  2174       while (true) {
  2175         if (jj_2_7(2)) {
  2177         } else {
  2178           break label_21;
  2180         PrefixedAnnotationAttribute(a, false);
  2182       label_22:
  2183       while (true) {
  2184         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2185         case 5:
  2186         case 6:
  2187         case 7:
  2188         case 10:
  2189         case 13:
  2190         case 14:
  2191         case 15:
  2192         case 16:
  2193         case 17:
  2194         case 18:
  2195         case 19:
  2196         case 26:
  2197         case 27:
  2198         case 31:
  2199         case 32:
  2200         case 33:
  2201         case 34:
  2202         case 35:
  2203         case 36:
  2204         case IDENTIFIER:
  2205         case ESCAPED_IDENTIFIER:
  2206         case PREFIXED_NAME:
  2208           break;
  2209         default:
  2210           jj_la1[58] = jj_gen;
  2211           break label_22;
  2213         e = AnnotationElement(false);
  2214                                         a.addElement(e); annotationsIncludeElements = true;
  2216          a.addComment(getComments());
  2217       jj_consume_token(9);
  2218       break;
  2219     default:
  2220       jj_la1[59] = jj_gen;
  2223     if (a == null && comments != null)
  2224       a = sb.makeAnnotations(comments, getContext());
  2225     {if (true) return a;}
  2226     throw new Error("Missing return statement in function");
  2229   final public void AnnotationAttribute(Annotations a) throws ParseException {
  2230     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2231     case PREFIXED_NAME:
  2232       PrefixedAnnotationAttribute(a, true);
  2233       break;
  2234     case 5:
  2235     case 6:
  2236     case 7:
  2237     case 10:
  2238     case 13:
  2239     case 14:
  2240     case 15:
  2241     case 16:
  2242     case 17:
  2243     case 18:
  2244     case 19:
  2245     case 26:
  2246     case 27:
  2247     case 31:
  2248     case 32:
  2249     case 33:
  2250     case 34:
  2251     case 35:
  2252     case 36:
  2253     case IDENTIFIER:
  2254     case ESCAPED_IDENTIFIER:
  2255       UnprefixedAnnotationAttribute(a);
  2256       break;
  2257     default:
  2258       jj_la1[60] = jj_gen;
  2259       jj_consume_token(-1);
  2260       throw new ParseException();
  2264   final public void PrefixedAnnotationAttribute(Annotations a, boolean nested) throws ParseException {
  2265   Token t;
  2266   String value;
  2267     t = jj_consume_token(PREFIXED_NAME);
  2268     jj_consume_token(2);
  2269     value = Literal();
  2270     String qn = t.image;
  2271     int colon = qn.indexOf(':');
  2272     String prefix = qn.substring(0, colon);
  2273     String ns = lookupPrefix(prefix, t);
  2274     if (ns == this.inheritedNs)
  2275       error("inherited_annotation_namespace", t);
  2276     else if (ns.length() == 0 && !nested)
  2277       error("unqualified_annotation_attribute", t);
  2278     else if (ns.equals(WellKnownNamespaces.RELAX_NG) && !nested)
  2279       error("relax_ng_namespace", t);
  2280     /*else if (ns.length() == 0
  2281              && qn.length() - colon - 1 == 5
  2282              && qn.regionMatches(colon + 1, "xmlns", 0, 5))
  2283       error("xmlns_annotation_attribute", t);*/
  2284     else if (ns.equals(WellKnownNamespaces.XMLNS))
  2285       error("xmlns_annotation_attribute_uri", t);
  2286     else {
  2287       if (ns.length() == 0)
  2288         prefix = null;
  2289       addAttribute(a, ns, qn.substring(colon + 1), prefix, value, t);
  2293   final public void UnprefixedAnnotationAttribute(Annotations a) throws ParseException {
  2294   LocatedString name;
  2295   String value;
  2296     name = UnprefixedName();
  2297     jj_consume_token(2);
  2298     value = Literal();
  2299     if (name.getString().equals("xmlns"))
  2300       error("xmlns_annotation_attribute", name.getToken());
  2301     else
  2302       addAttribute(a, "", name.getString(), null, value, name.getToken());
  2305   final public ParsedElementAnnotation AnnotationElement(boolean nested) throws ParseException {
  2306   ParsedElementAnnotation a;
  2307     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2308     case PREFIXED_NAME:
  2309       a = PrefixedAnnotationElement(nested);
  2310       break;
  2311     case 5:
  2312     case 6:
  2313     case 7:
  2314     case 10:
  2315     case 13:
  2316     case 14:
  2317     case 15:
  2318     case 16:
  2319     case 17:
  2320     case 18:
  2321     case 19:
  2322     case 26:
  2323     case 27:
  2324     case 31:
  2325     case 32:
  2326     case 33:
  2327     case 34:
  2328     case 35:
  2329     case 36:
  2330     case IDENTIFIER:
  2331     case ESCAPED_IDENTIFIER:
  2332       a = UnprefixedAnnotationElement();
  2333       break;
  2334     default:
  2335       jj_la1[61] = jj_gen;
  2336       jj_consume_token(-1);
  2337       throw new ParseException();
  2339     {if (true) return a;}
  2340     throw new Error("Missing return statement in function");
  2343   final public ParsedElementAnnotation AnnotationElementNotKeyword() throws ParseException {
  2344   ParsedElementAnnotation a;
  2345     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2346     case PREFIXED_NAME:
  2347       a = PrefixedAnnotationElement(false);
  2348       break;
  2349     case IDENTIFIER:
  2350     case ESCAPED_IDENTIFIER:
  2351       a = IdentifierAnnotationElement();
  2352       break;
  2353     default:
  2354       jj_la1[62] = jj_gen;
  2355       jj_consume_token(-1);
  2356       throw new ParseException();
  2358     {if (true) return a;}
  2359     throw new Error("Missing return statement in function");
  2362   final public ParsedElementAnnotation PrefixedAnnotationElement(boolean nested) throws ParseException {
  2363   CommentList comments = getComments();
  2364   Token t;
  2365   ElementAnnotationBuilder eab;
  2366     t = jj_consume_token(PREFIXED_NAME);
  2367     String qn = t.image;
  2368     int colon = qn.indexOf(':');
  2369     String prefix = qn.substring(0, colon);
  2370     String ns = lookupPrefix(prefix, t);
  2371     if (ns == this.inheritedNs) {
  2372       error("inherited_annotation_namespace", t);
  2373       ns = "";
  2375     else if (!nested && ns.equals(WellKnownNamespaces.RELAX_NG)) {
  2376       error("relax_ng_namespace", t);
  2377       ns = "";
  2379     else {
  2380       if (ns.length() == 0)
  2381         prefix = null;
  2383     eab = sb.makeElementAnnotationBuilder(ns, qn.substring(colon + 1), prefix,
  2384                                           makeLocation(t), comments, getContext());
  2385     AnnotationElementContent(eab);
  2386     {if (true) return eab.makeElementAnnotation();}
  2387     throw new Error("Missing return statement in function");
  2390   final public ParsedElementAnnotation UnprefixedAnnotationElement() throws ParseException {
  2391   CommentList comments = getComments();
  2392   LocatedString name;
  2393   ElementAnnotationBuilder eab;
  2394     name = UnprefixedName();
  2395     eab = sb.makeElementAnnotationBuilder("", name.getString(), null,
  2396                                           name.getLocation(), comments, getContext());
  2397     AnnotationElementContent(eab);
  2398     {if (true) return eab.makeElementAnnotation();}
  2399     throw new Error("Missing return statement in function");
  2402   final public ParsedElementAnnotation IdentifierAnnotationElement() throws ParseException {
  2403   CommentList comments = getComments();
  2404   LocatedString name;
  2405   ElementAnnotationBuilder eab;
  2406     name = Identifier();
  2407     eab = sb.makeElementAnnotationBuilder("", name.getString(), null,
  2408                                           name.getLocation(), comments, getContext());
  2409     AnnotationElementContent(eab);
  2410     {if (true) return eab.makeElementAnnotation();}
  2411     throw new Error("Missing return statement in function");
  2414   final public void AnnotationElementContent(ElementAnnotationBuilder eab) throws ParseException {
  2415   ParsedElementAnnotation e;
  2416     jj_consume_token(1);
  2417         clearAttributeList();
  2418     label_23:
  2419     while (true) {
  2420       if (jj_2_8(2)) {
  2422       } else {
  2423         break label_23;
  2425       AnnotationAttribute(eab);
  2427     label_24:
  2428     while (true) {
  2429       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2430       case 5:
  2431       case 6:
  2432       case 7:
  2433       case 10:
  2434       case 13:
  2435       case 14:
  2436       case 15:
  2437       case 16:
  2438       case 17:
  2439       case 18:
  2440       case 19:
  2441       case 26:
  2442       case 27:
  2443       case 31:
  2444       case 32:
  2445       case 33:
  2446       case 34:
  2447       case 35:
  2448       case 36:
  2449       case IDENTIFIER:
  2450       case ESCAPED_IDENTIFIER:
  2451       case PREFIXED_NAME:
  2452       case LITERAL:
  2454         break;
  2455       default:
  2456         jj_la1[63] = jj_gen;
  2457         break label_24;
  2459       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2460       case LITERAL:
  2461         AnnotationElementLiteral(eab);
  2462         label_25:
  2463         while (true) {
  2464           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2465           case 8:
  2467             break;
  2468           default:
  2469             jj_la1[64] = jj_gen;
  2470             break label_25;
  2472           jj_consume_token(8);
  2473           AnnotationElementLiteral(eab);
  2475         break;
  2476       case 5:
  2477       case 6:
  2478       case 7:
  2479       case 10:
  2480       case 13:
  2481       case 14:
  2482       case 15:
  2483       case 16:
  2484       case 17:
  2485       case 18:
  2486       case 19:
  2487       case 26:
  2488       case 27:
  2489       case 31:
  2490       case 32:
  2491       case 33:
  2492       case 34:
  2493       case 35:
  2494       case 36:
  2495       case IDENTIFIER:
  2496       case ESCAPED_IDENTIFIER:
  2497       case PREFIXED_NAME:
  2498         e = AnnotationElement(true);
  2499                                    eab.addElement(e);
  2500         break;
  2501       default:
  2502         jj_la1[65] = jj_gen;
  2503         jj_consume_token(-1);
  2504         throw new ParseException();
  2507     eab.addComment(getComments());
  2508     jj_consume_token(9);
  2511   final public void AnnotationElementLiteral(ElementAnnotationBuilder eab) throws ParseException {
  2512   Token t;
  2513   CommentList comments = getComments();
  2514     t = jj_consume_token(LITERAL);
  2515                   eab.addText(unquote(t.image), makeLocation(t), comments);
  2518   final public String Literal() throws ParseException {
  2519   Token t;
  2520   String s;
  2521   StringBuffer buf;
  2522     t = jj_consume_token(LITERAL);
  2523     s = unquote(t.image);
  2524     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2525     case 8:
  2526       buf = new StringBuffer(s);
  2527       label_26:
  2528       while (true) {
  2529         jj_consume_token(8);
  2530         t = jj_consume_token(LITERAL);
  2531                          buf.append(unquote(t.image));
  2532         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2533         case 8:
  2535           break;
  2536         default:
  2537           jj_la1[66] = jj_gen;
  2538           break label_26;
  2541       s = buf.toString();
  2542       break;
  2543     default:
  2544       jj_la1[67] = jj_gen;
  2547     {if (true) return s;}
  2548     throw new Error("Missing return statement in function");
  2551   final public LocatedString LocatedLiteral() throws ParseException {
  2552   Token t;
  2553   Token t2;
  2554   String s;
  2555   StringBuffer buf;
  2556     t = jj_consume_token(LITERAL);
  2557     s = unquote(t.image);
  2558     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2559     case 8:
  2560       buf = new StringBuffer(s);
  2561       label_27:
  2562       while (true) {
  2563         jj_consume_token(8);
  2564         t2 = jj_consume_token(LITERAL);
  2565                           buf.append(unquote(t2.image));
  2566         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2567         case 8:
  2569           break;
  2570         default:
  2571           jj_la1[68] = jj_gen;
  2572           break label_27;
  2575       s = buf.toString();
  2576       break;
  2577     default:
  2578       jj_la1[69] = jj_gen;
  2581     {if (true) return new LocatedString(s, t);}
  2582     throw new Error("Missing return statement in function");
  2585   final public Token Keyword() throws ParseException {
  2586   Token t;
  2587     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  2588     case 26:
  2589       t = jj_consume_token(26);
  2590       break;
  2591     case 27:
  2592       t = jj_consume_token(27);
  2593       break;
  2594     case 13:
  2595       t = jj_consume_token(13);
  2596       break;
  2597     case 31:
  2598       t = jj_consume_token(31);
  2599       break;
  2600     case 32:
  2601       t = jj_consume_token(32);
  2602       break;
  2603     case 10:
  2604       t = jj_consume_token(10);
  2605       break;
  2606     case 17:
  2607       t = jj_consume_token(17);
  2608       break;
  2609     case 18:
  2610       t = jj_consume_token(18);
  2611       break;
  2612     case 34:
  2613       t = jj_consume_token(34);
  2614       break;
  2615     case 33:
  2616       t = jj_consume_token(33);
  2617       break;
  2618     case 19:
  2619       t = jj_consume_token(19);
  2620       break;
  2621     case 5:
  2622       t = jj_consume_token(5);
  2623       break;
  2624     case 7:
  2625       t = jj_consume_token(7);
  2626       break;
  2627     case 14:
  2628       t = jj_consume_token(14);
  2629       break;
  2630     case 15:
  2631       t = jj_consume_token(15);
  2632       break;
  2633     case 35:
  2634       t = jj_consume_token(35);
  2635       break;
  2636     case 36:
  2637       t = jj_consume_token(36);
  2638       break;
  2639     case 16:
  2640       t = jj_consume_token(16);
  2641       break;
  2642     case 6:
  2643       t = jj_consume_token(6);
  2644       break;
  2645     default:
  2646       jj_la1[70] = jj_gen;
  2647       jj_consume_token(-1);
  2648       throw new ParseException();
  2650     {if (true) return t;}
  2651     throw new Error("Missing return statement in function");
  2654   private boolean jj_2_1(int xla) {
  2655     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2656     try { return !jj_3_1(); }
  2657     catch(LookaheadSuccess ls) { return true; }
  2658     finally { jj_save(0, xla); }
  2661   private boolean jj_2_2(int xla) {
  2662     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2663     try { return !jj_3_2(); }
  2664     catch(LookaheadSuccess ls) { return true; }
  2665     finally { jj_save(1, xla); }
  2668   private boolean jj_2_3(int xla) {
  2669     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2670     try { return !jj_3_3(); }
  2671     catch(LookaheadSuccess ls) { return true; }
  2672     finally { jj_save(2, xla); }
  2675   private boolean jj_2_4(int xla) {
  2676     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2677     try { return !jj_3_4(); }
  2678     catch(LookaheadSuccess ls) { return true; }
  2679     finally { jj_save(3, xla); }
  2682   private boolean jj_2_5(int xla) {
  2683     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2684     try { return !jj_3_5(); }
  2685     catch(LookaheadSuccess ls) { return true; }
  2686     finally { jj_save(4, xla); }
  2689   private boolean jj_2_6(int xla) {
  2690     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2691     try { return !jj_3_6(); }
  2692     catch(LookaheadSuccess ls) { return true; }
  2693     finally { jj_save(5, xla); }
  2696   private boolean jj_2_7(int xla) {
  2697     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2698     try { return !jj_3_7(); }
  2699     catch(LookaheadSuccess ls) { return true; }
  2700     finally { jj_save(6, xla); }
  2703   private boolean jj_2_8(int xla) {
  2704     jj_la = xla; jj_lastpos = jj_scanpos = token;
  2705     try { return !jj_3_8(); }
  2706     catch(LookaheadSuccess ls) { return true; }
  2707     finally { jj_save(7, xla); }
  2710   private boolean jj_3R_43() {
  2711     if (jj_scan_token(1)) return true;
  2712     Token xsp;
  2713     while (true) {
  2714       xsp = jj_scanpos;
  2715       if (jj_3R_52()) { jj_scanpos = xsp; break; }
  2717     if (jj_scan_token(9)) return true;
  2718     return false;
  2721   private boolean jj_3R_51() {
  2722     if (jj_scan_token(ESCAPED_IDENTIFIER)) return true;
  2723     return false;
  2726   private boolean jj_3R_50() {
  2727     if (jj_scan_token(IDENTIFIER)) return true;
  2728     return false;
  2731   private boolean jj_3R_41() {
  2732     Token xsp;
  2733     xsp = jj_scanpos;
  2734     if (jj_3R_50()) {
  2735     jj_scanpos = xsp;
  2736     if (jj_3R_51()) return true;
  2738     return false;
  2741   private boolean jj_3R_47() {
  2742     if (jj_scan_token(PREFIXED_NAME)) return true;
  2743     if (jj_3R_56()) return true;
  2744     return false;
  2747   private boolean jj_3R_55() {
  2748     Token xsp;
  2749     xsp = jj_scanpos;
  2750     if (jj_scan_token(40)) {
  2751     jj_scanpos = xsp;
  2752     if (jj_scan_token(43)) return true;
  2754     while (true) {
  2755       xsp = jj_scanpos;
  2756       if (jj_scan_token(41)) { jj_scanpos = xsp; break; }
  2758     return false;
  2761   private boolean jj_3R_45() {
  2762     Token xsp;
  2763     if (jj_3R_55()) return true;
  2764     while (true) {
  2765       xsp = jj_scanpos;
  2766       if (jj_3R_55()) { jj_scanpos = xsp; break; }
  2768     return false;
  2771   private boolean jj_3R_38() {
  2772     if (jj_3R_48()) return true;
  2773     return false;
  2776   private boolean jj_3R_42() {
  2777     Token xsp;
  2778     xsp = jj_scanpos;
  2779     if (jj_scan_token(5)) {
  2780     jj_scanpos = xsp;
  2781     if (jj_scan_token(6)) {
  2782     jj_scanpos = xsp;
  2783     if (jj_scan_token(7)) return true;
  2786     return false;
  2789   private boolean jj_3R_37() {
  2790     if (jj_3R_47()) return true;
  2791     return false;
  2794   private boolean jj_3R_54() {
  2795     if (jj_3R_42()) return true;
  2796     return false;
  2799   private boolean jj_3R_29() {
  2800     Token xsp;
  2801     xsp = jj_scanpos;
  2802     if (jj_3R_37()) {
  2803     jj_scanpos = xsp;
  2804     if (jj_3R_38()) return true;
  2806     return false;
  2809   private boolean jj_3R_44() {
  2810     Token xsp;
  2811     xsp = jj_scanpos;
  2812     if (jj_3R_53()) {
  2813     jj_scanpos = xsp;
  2814     if (jj_3R_54()) return true;
  2816     return false;
  2819   private boolean jj_3R_53() {
  2820     if (jj_3R_41()) return true;
  2821     Token xsp;
  2822     xsp = jj_scanpos;
  2823     if (jj_scan_token(2)) {
  2824     jj_scanpos = xsp;
  2825     if (jj_scan_token(3)) {
  2826     jj_scanpos = xsp;
  2827     if (jj_scan_token(4)) return true;
  2830     return false;
  2833   private boolean jj_3R_36() {
  2834     if (jj_3R_45()) return true;
  2835     Token xsp;
  2836     xsp = jj_scanpos;
  2837     if (jj_3R_46()) jj_scanpos = xsp;
  2838     if (jj_3R_44()) return true;
  2839     return false;
  2842   private boolean jj_3R_35() {
  2843     if (jj_3R_43()) return true;
  2844     if (jj_3R_44()) return true;
  2845     return false;
  2848   private boolean jj_3R_34() {
  2849     if (jj_3R_42()) return true;
  2850     return false;
  2853   private boolean jj_3R_33() {
  2854     if (jj_3R_41()) return true;
  2855     Token xsp;
  2856     xsp = jj_scanpos;
  2857     if (jj_scan_token(1)) {
  2858     jj_scanpos = xsp;
  2859     if (jj_scan_token(2)) {
  2860     jj_scanpos = xsp;
  2861     if (jj_scan_token(3)) {
  2862     jj_scanpos = xsp;
  2863     if (jj_scan_token(4)) return true;
  2867     return false;
  2870   private boolean jj_3_1() {
  2871     if (jj_3R_28()) return true;
  2872     return false;
  2875   private boolean jj_3R_32() {
  2876     if (jj_scan_token(PREFIXED_NAME)) return true;
  2877     if (jj_scan_token(1)) return true;
  2878     return false;
  2881   private boolean jj_3R_28() {
  2882     Token xsp;
  2883     xsp = jj_scanpos;
  2884     if (jj_3R_32()) {
  2885     jj_scanpos = xsp;
  2886     if (jj_3R_33()) {
  2887     jj_scanpos = xsp;
  2888     if (jj_3R_34()) {
  2889     jj_scanpos = xsp;
  2890     if (jj_3R_35()) {
  2891     jj_scanpos = xsp;
  2892     if (jj_3R_36()) return true;
  2897     return false;
  2900   private boolean jj_3R_59() {
  2901     if (jj_3R_43()) return true;
  2902     return false;
  2905   private boolean jj_3_8() {
  2906     if (jj_3R_31()) return true;
  2907     return false;
  2910   private boolean jj_3R_56() {
  2911     if (jj_scan_token(1)) return true;
  2912     return false;
  2915   private boolean jj_3R_49() {
  2916     if (jj_3R_57()) return true;
  2917     if (jj_scan_token(2)) return true;
  2918     return false;
  2921   private boolean jj_3R_40() {
  2922     if (jj_3R_49()) return true;
  2923     return false;
  2926   private boolean jj_3_4() {
  2927     if (jj_3R_29()) return true;
  2928     return false;
  2931   private boolean jj_3R_48() {
  2932     if (jj_3R_41()) return true;
  2933     if (jj_3R_56()) return true;
  2934     return false;
  2937   private boolean jj_3_3() {
  2938     if (jj_3R_29()) return true;
  2939     return false;
  2942   private boolean jj_3_6() {
  2943     if (jj_3R_29()) return true;
  2944     return false;
  2947   private boolean jj_3R_62() {
  2948     Token xsp;
  2949     xsp = jj_scanpos;
  2950     if (jj_scan_token(26)) {
  2951     jj_scanpos = xsp;
  2952     if (jj_scan_token(27)) {
  2953     jj_scanpos = xsp;
  2954     if (jj_scan_token(13)) {
  2955     jj_scanpos = xsp;
  2956     if (jj_scan_token(31)) {
  2957     jj_scanpos = xsp;
  2958     if (jj_scan_token(32)) {
  2959     jj_scanpos = xsp;
  2960     if (jj_scan_token(10)) {
  2961     jj_scanpos = xsp;
  2962     if (jj_scan_token(17)) {
  2963     jj_scanpos = xsp;
  2964     if (jj_scan_token(18)) {
  2965     jj_scanpos = xsp;
  2966     if (jj_scan_token(34)) {
  2967     jj_scanpos = xsp;
  2968     if (jj_scan_token(33)) {
  2969     jj_scanpos = xsp;
  2970     if (jj_scan_token(19)) {
  2971     jj_scanpos = xsp;
  2972     if (jj_scan_token(5)) {
  2973     jj_scanpos = xsp;
  2974     if (jj_scan_token(7)) {
  2975     jj_scanpos = xsp;
  2976     if (jj_scan_token(14)) {
  2977     jj_scanpos = xsp;
  2978     if (jj_scan_token(15)) {
  2979     jj_scanpos = xsp;
  2980     if (jj_scan_token(35)) {
  2981     jj_scanpos = xsp;
  2982     if (jj_scan_token(36)) {
  2983     jj_scanpos = xsp;
  2984     if (jj_scan_token(16)) {
  2985     jj_scanpos = xsp;
  2986     if (jj_scan_token(6)) return true;
  3005     return false;
  3008   private boolean jj_3R_61() {
  3009     if (jj_3R_62()) return true;
  3010     return false;
  3013   private boolean jj_3_2() {
  3014     if (jj_3R_28()) return true;
  3015     return false;
  3018   private boolean jj_3R_30() {
  3019     if (jj_scan_token(PREFIXED_NAME)) return true;
  3020     if (jj_scan_token(2)) return true;
  3021     return false;
  3024   private boolean jj_3R_60() {
  3025     if (jj_3R_41()) return true;
  3026     return false;
  3029   private boolean jj_3R_58() {
  3030     if (jj_3R_57()) return true;
  3031     return false;
  3034   private boolean jj_3R_57() {
  3035     Token xsp;
  3036     xsp = jj_scanpos;
  3037     if (jj_3R_60()) {
  3038     jj_scanpos = xsp;
  3039     if (jj_3R_61()) return true;
  3041     return false;
  3044   private boolean jj_3_5() {
  3045     if (jj_3R_29()) return true;
  3046     return false;
  3049   private boolean jj_3R_31() {
  3050     Token xsp;
  3051     xsp = jj_scanpos;
  3052     if (jj_3R_39()) {
  3053     jj_scanpos = xsp;
  3054     if (jj_3R_40()) return true;
  3056     return false;
  3059   private boolean jj_3R_39() {
  3060     if (jj_3R_30()) return true;
  3061     return false;
  3064   private boolean jj_3_7() {
  3065     if (jj_3R_30()) return true;
  3066     return false;
  3069   private boolean jj_3R_46() {
  3070     if (jj_3R_43()) return true;
  3071     return false;
  3074   private boolean jj_3R_52() {
  3075     Token xsp;
  3076     xsp = jj_scanpos;
  3077     if (jj_scan_token(57)) {
  3078     jj_scanpos = xsp;
  3079     if (jj_3R_58()) {
  3080     jj_scanpos = xsp;
  3081     if (jj_scan_token(2)) {
  3082     jj_scanpos = xsp;
  3083     if (jj_scan_token(58)) {
  3084     jj_scanpos = xsp;
  3085     if (jj_scan_token(8)) {
  3086     jj_scanpos = xsp;
  3087     if (jj_3R_59()) return true;
  3093     return false;
  3096   /** Generated Token Manager. */
  3097   public CompactSyntaxTokenManager token_source;
  3098   JavaCharStream jj_input_stream;
  3099   /** Current token. */
  3100   public Token token;
  3101   /** Next token. */
  3102   public Token jj_nt;
  3103   private int jj_ntk;
  3104   private Token jj_scanpos, jj_lastpos;
  3105   private int jj_la;
  3106   private int jj_gen;
  3107   final private int[] jj_la1 = new int[71];
  3108   static private int[] jj_la1_0;
  3109   static private int[] jj_la1_1;
  3110   static {
  3111       jj_la1_init_0();
  3112       jj_la1_init_1();
  3114    private static void jj_la1_init_0() {
  3115       jj_la1_0 = new int[] {0x9c0e0402,0x1e,0x2,0xe2,0x1c,0xe0,0xe0,0x0,0x0,0x0,0x8c0fe5e6,0x8c0fe5e6,0x402,0x16000,0x16000,0x8c0fe4e0,0x6000,0x8000,0x0,0x9c0e0400,0x100000,0x200000,0x400000,0x700000,0x700000,0x3800000,0x0,0x3800000,0x9e0fe4e0,0x0,0x100000,0x100000,0x9e0fe4e0,0x9c0fe4e0,0x2000000,0x40000000,0x40000000,0xe2,0xe0,0x20,0x1c,0x800,0x62,0x60,0x8000,0x40000000,0x40000000,0x800,0x0,0x0,0x0,0x8c0fe4e0,0x8c0fe4e0,0x8c0fe4e2,0x0,0x0,0x0,0x0,0x8c0fe4e0,0x2,0x8c0fe4e0,0x8c0fe4e0,0x0,0x8c0fe4e0,0x100,0x8c0fe4e0,0x100,0x100,0x100,0x100,0x8c0fe4e0,};
  3117    private static void jj_la1_init_1() {
  3118       jj_la1_1 = new int[] {0x6c0091f,0x0,0x0,0x2c00900,0x0,0xc00000,0x0,0x900,0x200,0x900,0x6c0001f,0x6c0001f,0x900,0x0,0x0,0xc0001f,0x0,0x4000000,0x8000000,0x6c0001f,0x0,0x0,0x0,0x0,0x0,0x0,0x8000000,0x0,0x3c0001f,0x8000000,0x0,0x0,0x3c0001f,0x2c0001f,0x1000000,0x0,0x0,0xc00900,0xc00000,0xc00000,0x0,0x0,0xc00900,0xc00000,0x0,0x0,0x0,0x0,0x4000000,0x2000018,0xc00000,0xc0001f,0xc0001f,0xc0091f,0x900,0x200,0x900,0x900,0x2c0001f,0x0,0x2c0001f,0x2c0001f,0x2c00000,0x6c0001f,0x0,0x6c0001f,0x0,0x0,0x0,0x0,0x1f,};
  3120   final private JJCalls[] jj_2_rtns = new JJCalls[8];
  3121   private boolean jj_rescan = false;
  3122   private int jj_gc = 0;
  3124   /** Constructor with InputStream. */
  3125   public CompactSyntax(java.io.InputStream stream) {
  3126      this(stream, null);
  3128   /** Constructor with InputStream and supplied encoding */
  3129   public CompactSyntax(java.io.InputStream stream, String encoding) {
  3130     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
  3131     token_source = new CompactSyntaxTokenManager(jj_input_stream);
  3132     token = new Token();
  3133     jj_ntk = -1;
  3134     jj_gen = 0;
  3135     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3136     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3139   /** Reinitialise. */
  3140   public void ReInit(java.io.InputStream stream) {
  3141      ReInit(stream, null);
  3143   /** Reinitialise. */
  3144   public void ReInit(java.io.InputStream stream, String encoding) {
  3145     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
  3146     token_source.ReInit(jj_input_stream);
  3147     token = new Token();
  3148     jj_ntk = -1;
  3149     jj_gen = 0;
  3150     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3151     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3154   /** Constructor. */
  3155   public CompactSyntax(java.io.Reader stream) {
  3156     jj_input_stream = new JavaCharStream(stream, 1, 1);
  3157     token_source = new CompactSyntaxTokenManager(jj_input_stream);
  3158     token = new Token();
  3159     jj_ntk = -1;
  3160     jj_gen = 0;
  3161     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3162     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3165   /** Reinitialise. */
  3166   public void ReInit(java.io.Reader stream) {
  3167     jj_input_stream.ReInit(stream, 1, 1);
  3168     token_source.ReInit(jj_input_stream);
  3169     token = new Token();
  3170     jj_ntk = -1;
  3171     jj_gen = 0;
  3172     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3173     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3176   /** Constructor with generated Token Manager. */
  3177   public CompactSyntax(CompactSyntaxTokenManager tm) {
  3178     token_source = tm;
  3179     token = new Token();
  3180     jj_ntk = -1;
  3181     jj_gen = 0;
  3182     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3183     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3186   /** Reinitialise. */
  3187   public void ReInit(CompactSyntaxTokenManager tm) {
  3188     token_source = tm;
  3189     token = new Token();
  3190     jj_ntk = -1;
  3191     jj_gen = 0;
  3192     for (int i = 0; i < 71; i++) jj_la1[i] = -1;
  3193     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  3196   private Token jj_consume_token(int kind) throws ParseException {
  3197     Token oldToken;
  3198     if ((oldToken = token).next != null) token = token.next;
  3199     else token = token.next = token_source.getNextToken();
  3200     jj_ntk = -1;
  3201     if (token.kind == kind) {
  3202       jj_gen++;
  3203       if (++jj_gc > 100) {
  3204         jj_gc = 0;
  3205         for (int i = 0; i < jj_2_rtns.length; i++) {
  3206           JJCalls c = jj_2_rtns[i];
  3207           while (c != null) {
  3208             if (c.gen < jj_gen) c.first = null;
  3209             c = c.next;
  3213       return token;
  3215     token = oldToken;
  3216     jj_kind = kind;
  3217     throw generateParseException();
  3220   static private final class LookaheadSuccess extends java.lang.Error { }
  3221   final private LookaheadSuccess jj_ls = new LookaheadSuccess();
  3222   private boolean jj_scan_token(int kind) {
  3223     if (jj_scanpos == jj_lastpos) {
  3224       jj_la--;
  3225       if (jj_scanpos.next == null) {
  3226         jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
  3227       } else {
  3228         jj_lastpos = jj_scanpos = jj_scanpos.next;
  3230     } else {
  3231       jj_scanpos = jj_scanpos.next;
  3233     if (jj_rescan) {
  3234       int i = 0; Token tok = token;
  3235       while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
  3236       if (tok != null) jj_add_error_token(kind, i);
  3238     if (jj_scanpos.kind != kind) return true;
  3239     if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
  3240     return false;
  3244 /** Get the next Token. */
  3245   final public Token getNextToken() {
  3246     if (token.next != null) token = token.next;
  3247     else token = token.next = token_source.getNextToken();
  3248     jj_ntk = -1;
  3249     jj_gen++;
  3250     return token;
  3253 /** Get the specific Token. */
  3254   final public Token getToken(int index) {
  3255     Token t = token;
  3256     for (int i = 0; i < index; i++) {
  3257       if (t.next != null) t = t.next;
  3258       else t = t.next = token_source.getNextToken();
  3260     return t;
  3263   private int jj_ntk() {
  3264     if ((jj_nt=token.next) == null)
  3265       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
  3266     else
  3267       return (jj_ntk = jj_nt.kind);
  3270   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
  3271   private int[] jj_expentry;
  3272   private int jj_kind = -1;
  3273   private int[] jj_lasttokens = new int[100];
  3274   private int jj_endpos;
  3276   private void jj_add_error_token(int kind, int pos) {
  3277     if (pos >= 100) return;
  3278     if (pos == jj_endpos + 1) {
  3279       jj_lasttokens[jj_endpos++] = kind;
  3280     } else if (jj_endpos != 0) {
  3281       jj_expentry = new int[jj_endpos];
  3282       for (int i = 0; i < jj_endpos; i++) {
  3283         jj_expentry[i] = jj_lasttokens[i];
  3285       jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
  3286         int[] oldentry = (int[])(it.next());
  3287         if (oldentry.length == jj_expentry.length) {
  3288           for (int i = 0; i < jj_expentry.length; i++) {
  3289             if (oldentry[i] != jj_expentry[i]) {
  3290               continue jj_entries_loop;
  3293           jj_expentries.add(jj_expentry);
  3294           break jj_entries_loop;
  3297       if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
  3301   /** Generate ParseException. */
  3302   public ParseException generateParseException() {
  3303     jj_expentries.clear();
  3304     boolean[] la1tokens = new boolean[61];
  3305     if (jj_kind >= 0) {
  3306       la1tokens[jj_kind] = true;
  3307       jj_kind = -1;
  3309     for (int i = 0; i < 71; i++) {
  3310       if (jj_la1[i] == jj_gen) {
  3311         for (int j = 0; j < 32; j++) {
  3312           if ((jj_la1_0[i] & (1<<j)) != 0) {
  3313             la1tokens[j] = true;
  3315           if ((jj_la1_1[i] & (1<<j)) != 0) {
  3316             la1tokens[32+j] = true;
  3321     for (int i = 0; i < 61; i++) {
  3322       if (la1tokens[i]) {
  3323         jj_expentry = new int[1];
  3324         jj_expentry[0] = i;
  3325         jj_expentries.add(jj_expentry);
  3328     jj_endpos = 0;
  3329     jj_rescan_token();
  3330     jj_add_error_token(0, 0);
  3331     int[][] exptokseq = new int[jj_expentries.size()][];
  3332     for (int i = 0; i < jj_expentries.size(); i++) {
  3333       exptokseq[i] = jj_expentries.get(i);
  3335     return new ParseException(token, exptokseq, tokenImage);
  3338   /** Enable tracing. */
  3339   final public void enable_tracing() {
  3342   /** Disable tracing. */
  3343   final public void disable_tracing() {
  3346   private void jj_rescan_token() {
  3347     jj_rescan = true;
  3348     for (int i = 0; i < 8; i++) {
  3349     try {
  3350       JJCalls p = jj_2_rtns[i];
  3351       do {
  3352         if (p.gen > jj_gen) {
  3353           jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
  3354           switch (i) {
  3355             case 0: jj_3_1(); break;
  3356             case 1: jj_3_2(); break;
  3357             case 2: jj_3_3(); break;
  3358             case 3: jj_3_4(); break;
  3359             case 4: jj_3_5(); break;
  3360             case 5: jj_3_6(); break;
  3361             case 6: jj_3_7(); break;
  3362             case 7: jj_3_8(); break;
  3365         p = p.next;
  3366       } while (p != null);
  3367       } catch(LookaheadSuccess ls) { }
  3369     jj_rescan = false;
  3372   private void jj_save(int index, int xla) {
  3373     JJCalls p = jj_2_rtns[index];
  3374     while (p.gen > jj_gen) {
  3375       if (p.next == null) { p = p.next = new JJCalls(); break; }
  3376       p = p.next;
  3378     p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  3381   static final class JJCalls {
  3382     int gen;
  3383     Token first;
  3384     int arg;
  3385     JJCalls next;

mercurial