1 2 package com.thaiopensource.relaxng.parse.compact; 3 4 import com.thaiopensource.relaxng.parse.SchemaBuilder; 5 import com.thaiopensource.relaxng.parse.Annotations; 6 import com.thaiopensource.relaxng.parse.DataPatternBuilder; 7 import com.thaiopensource.relaxng.parse.ParsedElementAnnotation; 8 import com.thaiopensource.relaxng.parse.ElementAnnotationBuilder; 9 import com.thaiopensource.relaxng.parse.CommentList; 10 import com.thaiopensource.relaxng.parse.ParsedPattern; 11 import com.thaiopensource.relaxng.parse.ParsedNameClass; 12 import com.thaiopensource.relaxng.parse.Scope; 13 import com.thaiopensource.relaxng.parse.GrammarSection; 14 import com.thaiopensource.relaxng.parse.Div; 15 import com.thaiopensource.relaxng.parse.Grammar; 16 import com.thaiopensource.relaxng.parse.Include; 17 import com.thaiopensource.relaxng.parse.IncludedGrammar; 18 import com.thaiopensource.relaxng.parse.IllegalSchemaException; 19 import com.thaiopensource.relaxng.parse.BuildException; 20 import com.thaiopensource.relaxng.parse.Location; 21 import com.thaiopensource.relaxng.parse.Context; 22 23 import com.thaiopensource.xml.util.WellKnownNamespaces; 24 25 import com.thaiopensource.util.Localizer; 26 27 import org.xml.sax.ErrorHandler; 28 import org.xml.sax.SAXException; 29 import org.xml.sax.SAXParseException; 30 import org.xml.sax.Locator; 31 import org.xml.sax.helpers.LocatorImpl; 32 33 import java.util.Hashtable; 34 import java.util.Enumeration; 35 import java.io.Reader; 36 import java.net.MalformedURLException; 37 import java.net.URL; 38 39 public class CompactSyntax implements Context, CompactSyntaxConstants { 40 private static final int IN_ELEMENT = 0; 41 private static final int IN_ATTRIBUTE = 1; 42 private static final int IN_ANY_NAME = 2; 43 private static final int IN_NS_NAME = 4; 44 45 private String defaultNamespace = SchemaBuilder.INHERIT_NS; 46 private String compatibilityPrefix = null; 47 private SchemaBuilder sb; 48 private String sourceUri; 49 private ErrorHandler eh; 50 private final Hashtable namespaceTable = new Hashtable(); 51 private final Hashtable datatypesTable = new Hashtable(); 52 private boolean hadError = false; 53 private static final Localizer localizer = new Localizer(CompactSyntax.class); 54 private final Hashtable attributeNameTable = new Hashtable(); 55 private boolean annotationsIncludeElements = false; 56 57 final class LocatedString { 58 private final String str; 59 private final Token tok; 60 61 LocatedString(String str, Token tok) { 62 this.str = str; 63 this.tok = tok; 64 } 65 66 String getString() { 67 return str; 68 } 69 70 Location getLocation() { 71 return makeLocation(tok); 72 } 73 74 Token getToken() { 75 return tok; 76 } 77 78 } 79 80 public CompactSyntax(Reader r, String sourceUri, SchemaBuilder sb, ErrorHandler eh) { 81 this(r); 82 this.sourceUri = sourceUri; 83 this.sb = sb; 84 this.eh = eh; 85 this.topLevelComments = sb.makeCommentList(); 88 } 89 90 ParsedPattern parse(Scope scope) throws IllegalSchemaException { 91 try { 92 ParsedPattern p = Input(scope); 93 if (!hadError) 94 return p; 95 } 96 catch (ParseException e) { 97 error("syntax_error", e.currentToken.next); 98 } 99 catch (EscapeSyntaxException e) { 100 reportEscapeSyntaxException(e); 101 } 102 throw new IllegalSchemaException(); 103 } 104 105 ParsedPattern parseInclude(IncludedGrammar g) throws IllegalSchemaException { 106 try { 107 ParsedPattern p = IncludedGrammar(g); 108 if (!hadError) 109 return p; 110 } 111 catch (ParseException e) { 112 error("syntax_error", e.currentToken.next); 113 } 114 catch (EscapeSyntaxException e) { 115 reportEscapeSyntaxException(e); 116 } 117 throw new IllegalSchemaException(); 118 } 119 120 private void checkNsName(int context, LocatedString ns) { 121 if ((context & IN_NS_NAME) != 0) 122 error("ns_name_except_contains_ns_name", ns.getToken()); 123 } 124 125 private void checkAnyName(int context, Token t) { 126 if ((context & IN_NS_NAME) != 0) 127 error("ns_name_except_contains_any_name", t); 128 if ((context & IN_ANY_NAME) != 0) 129 error("any_name_except_contains_any_name", t); 130 } 131 132 private void error(String key, Token tok) { 133 doError(localizer.message(key), tok); 134 } 135 136 private void error(String key, String arg, Token tok) { 137 doError(localizer.message(key, arg), tok); 138 } 139 140 private void error(String key, String arg1, String arg2, Token tok) { 141 doError(localizer.message(key, arg1, arg2), tok); 142 } 143 144 private void doError(String message, Token tok) { 145 hadError = true; 146 if (eh != null) { 147 LocatorImpl loc = new LocatorImpl(); 148 loc.setLineNumber(tok.beginLine); 149 loc.setColumnNumber(tok.beginColumn); 150 loc.setSystemId(sourceUri); 151 try { 152 eh.error(new SAXParseException(message, loc)); 153 } 154 catch (SAXException se) { 155 throw new BuildException(se); 156 } 157 } 158 } 159 160 private void reportEscapeSyntaxException(EscapeSyntaxException e) { 161 if (eh != null) { 162 LocatorImpl loc = new LocatorImpl(); 163 loc.setLineNumber(e.getLineNumber()); 164 loc.setColumnNumber(e.getColumnNumber()); 165 loc.setSystemId(sourceUri); 166 try { 167 eh.error(new SAXParseException(localizer.message(e.getKey()), loc)); 168 } 169 catch (SAXException se) { 170 throw new BuildException(se); 171 } 172 } 173 } 174 175 private static String unquote(String s) { 176 if (s.length() >= 6 && s.charAt(0) == s.charAt(1)) { 177 s = s.replace('\u0000', '\n'); 178 return s.substring(3, s.length() - 3); 179 } 180 else 181 return s.substring(1, s.length() - 1); 182 } 183 184 Location makeLocation(Token t) { 185 return sb.makeLocation(sourceUri, t.beginLine, t.beginColumn); 186 } 187 188 private static ParsedPattern[] addPattern(ParsedPattern[] patterns, int i, ParsedPattern p) { 189 if (i >= patterns.length) { 190 ParsedPattern[] oldPatterns = patterns; 191 patterns = new ParsedPattern[oldPatterns.length*2]; 192 System.arraycopy(oldPatterns, 0, patterns, 0, oldPatterns.length); 193 } 194 patterns[i] = p; 195 return patterns; 196 } 197 198 String getCompatibilityPrefix() { 199 if (compatibilityPrefix == null) { 200 compatibilityPrefix = "a"; 201 while (namespaceTable.get(compatibilityPrefix) != null) 202 compatibilityPrefix = compatibilityPrefix + "a"; 203 } 204 return compatibilityPrefix; 205 } 206 207 public String resolveNamespacePrefix(String prefix) { 208 String result = (String)namespaceTable.get(prefix); 209 if (result.length() == 0) 210 return null; 211 return result; 212 } 213 214 public Enumeration prefixes() { 215 return namespaceTable.keys(); 216 } 217 218 public String getBaseUri() { 219 return sourceUri; 220 } 221 222 public boolean isUnparsedEntity(String entityName) { 223 return false; 224 } 225 226 public boolean isNotation(String notationName) { 227 return false; 228 } 229 230 public Context copy() { 231 return this; 232 } 233 234 private Context getContext() { 235 return this; 236 } 237 238 private CommentList getComments() { 239 return getComments(getTopLevelComments()); 240 } 241 242 private CommentList topLevelComments; 243 244 private CommentList getTopLevelComments() { 245 CommentList tem = topLevelComments; 246 topLevelComments = null; 247 return tem; 248 } 249 250 private void noteTopLevelComments() { 251 topLevelComments = getComments(topLevelComments); 252 } 253 254 private void topLevelComments(GrammarSection section) { 255 section.topLevelComment(getComments(null)); 256 } 257 258 private Token lastCommentSourceToken = null; 259 260 private CommentList getComments(CommentList comments) { 261 Token nextToken = getToken(1); 262 if (lastCommentSourceToken != nextToken) { 263 if (lastCommentSourceToken == null) 264 lastCommentSourceToken = token; 265 do { 266 lastCommentSourceToken = lastCommentSourceToken.next; 267 Token t = lastCommentSourceToken.specialToken; 268 if (t != null) { 269 while (t.specialToken != null) 270 t = t.specialToken; 271 if (comments == null) 272 comments = sb.makeCommentList(); 273 for (; t != null; t = t.next) { 274 String s = mungeComment(t.image); 275 Location loc = makeLocation(t); 276 if (t.next != null 277 && t.next.kind == CompactSyntaxConstants.SINGLE_LINE_COMMENT_CONTINUE) { 278 StringBuffer buf = new StringBuffer(s); 279 do { 280 t = t.next; 281 buf.append('\n'); 282 buf.append(mungeComment(t.image)); 283 } while (t.next != null 284 && t.next.kind == CompactSyntaxConstants.SINGLE_LINE_COMMENT_CONTINUE); 285 s = buf.toString(); 286 } 287 comments.addComment(s, loc); 288 } 289 } 290 } while (lastCommentSourceToken != nextToken); 291 } 292 return comments; 293 } 294 295 private ParsedPattern afterComments(ParsedPattern p) { 296 CommentList comments = getComments(null); 297 if (comments == null) 298 return p; 299 return sb.commentAfter(p, comments); 300 } 301 302 private ParsedNameClass afterComments(ParsedNameClass nc) { 303 CommentList comments = getComments(null); 304 if (comments == null) 305 return nc; 306 return sb.commentAfter(nc, comments); 307 } 308 309 private static String mungeComment(String image) { 310 int i = image.indexOf('#') + 1; 311 while (i < image.length() && image.charAt(i) == '#') 312 i++; 313 if (i < image.length() && image.charAt(i) == ' ') 314 i++; 315 return image.substring(i); 316 } 317 318 private Annotations getCommentsAsAnnotations() { 319 CommentList comments = getComments(); 320 if (comments == null) 321 return null; 322 return sb.makeAnnotations(comments, getContext()); 323 } 324 325 private Annotations addCommentsToChildAnnotations(Annotations a) { 326 CommentList comments = getComments(); 327 if (comments == null) 328 return a; 329 if (a == null) 330 a = sb.makeAnnotations(null, getContext()); 331 a.addComment(comments); 332 return a; 333 } 334 335 private Annotations addCommentsToLeadingAnnotations(Annotations a) { 336 CommentList comments = getComments(); 337 if (comments == null) 338 return a; 339 if (a == null) 340 return sb.makeAnnotations(comments, getContext()); 341 a.addLeadingComment(comments); 342 return a; 343 } 344 345 private Annotations getTopLevelCommentsAsAnnotations() { 346 CommentList comments = getTopLevelComments(); 347 if (comments == null) 348 return null; 349 return sb.makeAnnotations(comments, getContext()); 350 } 351 352 private void clearAttributeList() { 353 attributeNameTable.clear(); 354 } 355 356 private void addAttribute(Annotations a, String ns, String localName, String prefix, String value, Token tok) { 357 String key = ns + "#" + localName; 358 if (attributeNameTable.get(key) != null) 359 error("duplicate_attribute", ns, localName, tok); 360 else { 361 attributeNameTable.put(key, key); 362 a.addAttribute(ns, localName, prefix, value, makeLocation(tok)); 363 } 364 } 365 366 private void checkExcept(Token[] except) { 367 if (except[0] != null) 368 error("except_missing_parentheses", except[0]); 369 } 370 371 private String lookupPrefix(String prefix, Token t) { 372 String ns = (String)namespaceTable.get(prefix); 373 if (ns == null) { 374 error("undeclared_prefix", prefix, t); 375 return "#error"; 376 } 377 return ns; 378 } 379 private String lookupDatatype(String prefix, Token t) { 380 String ns = (String)datatypesTable.get(prefix); 381 if (ns == null) { 382 error("undeclared_prefix", prefix, t); 383 return ""; } 385 return ns; 386 } 387 private String resolve(String str) { 388 try { 389 return new URL(new URL(sourceUri), str).toString(); 390 } 391 catch (MalformedURLException e) { } 392 return str; 393 } 394 395 final public ParsedPattern Input(Scope scope) throws ParseException { 396 ParsedPattern p; 397 Preamble(); 398 if (jj_2_1(2147483647)) { 399 p = TopLevelGrammar(scope); 400 } else { 401 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 402 case 1: 403 case 10: 404 case 17: 405 case 18: 406 case 19: 407 case 26: 408 case 27: 409 case 28: 410 case 31: 411 case 32: 412 case 33: 413 case 34: 414 case 35: 415 case 36: 416 case DOCUMENTATION: 417 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 418 case IDENTIFIER: 419 case ESCAPED_IDENTIFIER: 420 case PREFIXED_NAME: 421 case LITERAL: 422 p = Expr(true, scope, null, null); 423 p = afterComments(p); 424 jj_consume_token(0); 425 break; 426 default: 427 jj_la1[0] = jj_gen; 428 jj_consume_token(-1); 429 throw new ParseException(); 430 } 431 } 432 {if (true) return p;} 433 throw new Error("Missing return statement in function"); 434 } 435 436 final public void TopLevelLookahead() throws ParseException { 437 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 438 case PREFIXED_NAME: 439 jj_consume_token(PREFIXED_NAME); 440 jj_consume_token(1); 441 break; 442 case IDENTIFIER: 443 case ESCAPED_IDENTIFIER: 444 Identifier(); 445 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 446 case 1: 447 jj_consume_token(1); 448 break; 449 case 2: 450 jj_consume_token(2); 451 break; 452 case 3: 453 jj_consume_token(3); 454 break; 455 case 4: 456 jj_consume_token(4); 457 break; 458 default: 459 jj_la1[1] = jj_gen; 460 jj_consume_token(-1); 461 throw new ParseException(); 462 } 463 break; 464 case 5: 465 case 6: 466 case 7: 467 LookaheadGrammarKeyword(); 468 break; 469 case 1: 470 LookaheadBody(); 471 LookaheadAfterAnnotations(); 472 break; 473 case DOCUMENTATION: 474 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 475 LookaheadDocumentation(); 476 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 477 case 1: 478 LookaheadBody(); 479 break; 480 default: 481 jj_la1[2] = jj_gen; 482 ; 483 } 484 LookaheadAfterAnnotations(); 485 break; 486 default: 487 jj_la1[3] = jj_gen; 488 jj_consume_token(-1); 489 throw new ParseException(); 490 } 491 } 492 493 final public void LookaheadAfterAnnotations() throws ParseException { 494 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 495 case IDENTIFIER: 496 case ESCAPED_IDENTIFIER: 497 Identifier(); 498 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 499 case 2: 500 jj_consume_token(2); 501 break; 502 case 3: 503 jj_consume_token(3); 504 break; 505 case 4: 506 jj_consume_token(4); 507 break; 508 default: 509 jj_la1[4] = jj_gen; 510 jj_consume_token(-1); 511 throw new ParseException(); 512 } 513 break; 514 case 5: 515 case 6: 516 case 7: 517 LookaheadGrammarKeyword(); 518 break; 519 default: 520 jj_la1[5] = jj_gen; 521 jj_consume_token(-1); 522 throw new ParseException(); 523 } 524 } 525 526 final public void LookaheadGrammarKeyword() throws ParseException { 527 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 528 case 5: 529 jj_consume_token(5); 530 break; 531 case 6: 532 jj_consume_token(6); 533 break; 534 case 7: 535 jj_consume_token(7); 536 break; 537 default: 538 jj_la1[6] = jj_gen; 539 jj_consume_token(-1); 540 throw new ParseException(); 541 } 542 } 543 544 final public void LookaheadDocumentation() throws ParseException { 545 label_1: 546 while (true) { 547 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 548 case DOCUMENTATION: 549 jj_consume_token(DOCUMENTATION); 550 break; 551 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 552 jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT); 553 break; 554 default: 555 jj_la1[7] = jj_gen; 556 jj_consume_token(-1); 557 throw new ParseException(); 558 } 559 label_2: 560 while (true) { 561 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 562 case DOCUMENTATION_CONTINUE: 563 ; 564 break; 565 default: 566 jj_la1[8] = jj_gen; 567 break label_2; 568 } 569 jj_consume_token(DOCUMENTATION_CONTINUE); 570 } 571 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 572 case DOCUMENTATION: 573 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 574 ; 575 break; 576 default: 577 jj_la1[9] = jj_gen; 578 break label_1; 579 } 580 } 581 } 582 583 final public void LookaheadBody() throws ParseException { 584 jj_consume_token(1); 585 label_3: 586 while (true) { 587 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 588 case 1: 589 case 2: 590 case 5: 591 case 6: 592 case 7: 593 case 8: 594 case 10: 595 case 13: 596 case 14: 597 case 15: 598 case 16: 599 case 17: 600 case 18: 601 case 19: 602 case 26: 603 case 27: 604 case 31: 605 case 32: 606 case 33: 607 case 34: 608 case 35: 609 case 36: 610 case IDENTIFIER: 611 case ESCAPED_IDENTIFIER: 612 case PREFIXED_NAME: 613 case LITERAL: 614 ; 615 break; 616 default: 617 jj_la1[10] = jj_gen; 618 break label_3; 619 } 620 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 621 case PREFIXED_NAME: 622 jj_consume_token(PREFIXED_NAME); 623 break; 624 case 5: 625 case 6: 626 case 7: 627 case 10: 628 case 13: 629 case 14: 630 case 15: 631 case 16: 632 case 17: 633 case 18: 634 case 19: 635 case 26: 636 case 27: 637 case 31: 638 case 32: 639 case 33: 640 case 34: 641 case 35: 642 case 36: 643 case IDENTIFIER: 644 case ESCAPED_IDENTIFIER: 645 UnprefixedName(); 646 break; 647 case 2: 648 jj_consume_token(2); 649 break; 650 case LITERAL: 651 jj_consume_token(LITERAL); 652 break; 653 case 8: 654 jj_consume_token(8); 655 break; 656 case 1: 657 LookaheadBody(); 658 break; 659 default: 660 jj_la1[11] = jj_gen; 661 jj_consume_token(-1); 662 throw new ParseException(); 663 } 664 } 665 jj_consume_token(9); 666 } 667 668 final public ParsedPattern IncludedGrammar(IncludedGrammar g) throws ParseException { 669 Annotations a; 670 ParsedPattern p; 671 Preamble(); 672 if (jj_2_2(2147483647)) { 673 a = GrammarBody(g, g, getTopLevelCommentsAsAnnotations()); 674 } else { 675 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 676 case 1: 677 case 10: 678 case DOCUMENTATION: 679 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 680 a = Annotations(); 681 jj_consume_token(10); 682 jj_consume_token(11); 683 a = GrammarBody(g, g, a); 684 topLevelComments(g); 685 jj_consume_token(12); 686 break; 687 default: 688 jj_la1[12] = jj_gen; 689 jj_consume_token(-1); 690 throw new ParseException(); 691 } 692 } 693 p = afterComments(g.endIncludedGrammar(sb.makeLocation(sourceUri, 1, 1), a)); 694 jj_consume_token(0); 695 {if (true) return p;} 696 throw new Error("Missing return statement in function"); 697 } 698 699 final public ParsedPattern TopLevelGrammar(Scope scope) throws ParseException { 700 Annotations a = getTopLevelCommentsAsAnnotations(); 701 Grammar g; 702 ParsedPattern p; 703 g = sb.makeGrammar(scope); 704 a = GrammarBody(g, g, a); 705 p = afterComments(g.endGrammar(sb.makeLocation(sourceUri, 1, 1), a)); 706 jj_consume_token(0); 707 {if (true) return p;} 708 throw new Error("Missing return statement in function"); 709 } 710 711 final public void Preamble() throws ParseException { 712 label_4: 713 while (true) { 714 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 715 case 13: 716 case 14: 717 case 16: 718 ; 719 break; 720 default: 721 jj_la1[13] = jj_gen; 722 break label_4; 723 } 724 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 725 case 13: 726 case 14: 727 NamespaceDecl(); 728 break; 729 case 16: 730 DatatypesDecl(); 731 break; 732 default: 733 jj_la1[14] = jj_gen; 734 jj_consume_token(-1); 735 throw new ParseException(); 736 } 737 } 738 namespaceTable.put("xml", WellKnownNamespaces.XML); 739 if (datatypesTable.get("xsd") == null) 740 datatypesTable.put("xsd", WellKnownNamespaces.XML_SCHEMA_DATATYPES); 741 } 742 743 final public void NamespaceDecl() throws ParseException { 744 LocatedString prefix = null; 745 boolean isDefault = false; 746 String namespaceName; 747 noteTopLevelComments(); 748 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 749 case 13: 750 jj_consume_token(13); 751 prefix = UnprefixedName(); 752 break; 753 case 14: 754 jj_consume_token(14); 755 isDefault = true; 756 jj_consume_token(13); 757 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 758 case 5: 759 case 6: 760 case 7: 761 case 10: 762 case 13: 763 case 14: 764 case 15: 765 case 16: 766 case 17: 767 case 18: 768 case 19: 769 case 26: 770 case 27: 771 case 31: 772 case 32: 773 case 33: 774 case 34: 775 case 35: 776 case 36: 777 case IDENTIFIER: 778 case ESCAPED_IDENTIFIER: 779 prefix = UnprefixedName(); 780 break; 781 default: 782 jj_la1[15] = jj_gen; 783 ; 784 } 785 break; 786 default: 787 jj_la1[16] = jj_gen; 788 jj_consume_token(-1); 789 throw new ParseException(); 790 } 791 jj_consume_token(2); 792 namespaceName = NamespaceName(); 793 if (isDefault) 794 defaultNamespace = namespaceName; 795 if (prefix != null) { 796 if (prefix.getString().equals("xmlns")) 797 error("xmlns_prefix", prefix.getToken()); 798 else if (prefix.getString().equals("xml")) { 799 if (!namespaceName.equals(WellKnownNamespaces.XML)) 800 error("xml_prefix_bad_uri", prefix.getToken()); 801 } 802 else if (namespaceName.equals(WellKnownNamespaces.XML)) 803 error("xml_uri_bad_prefix", prefix.getToken()); 804 else { 805 if (namespaceName.equals(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS)) 806 compatibilityPrefix = prefix.getString(); 807 namespaceTable.put(prefix.getString(), namespaceName); 808 } 809 } 810 } 811 812 final public String NamespaceName() throws ParseException { 813 String r; 814 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 815 case LITERAL: 816 r = Literal(); 817 break; 818 case 15: 819 jj_consume_token(15); 820 r = SchemaBuilder.INHERIT_NS; 821 break; 822 default: 823 jj_la1[17] = jj_gen; 824 jj_consume_token(-1); 825 throw new ParseException(); 826 } 827 {if (true) return r;} 828 throw new Error("Missing return statement in function"); 829 } 830 831 final public void DatatypesDecl() throws ParseException { 832 LocatedString prefix; 833 String uri; 834 noteTopLevelComments(); 835 jj_consume_token(16); 836 prefix = UnprefixedName(); 837 jj_consume_token(2); 838 uri = Literal(); 839 datatypesTable.put(prefix.getString(), uri); 840 } 841 842 final public ParsedPattern AnnotatedPrimaryExpr(boolean topLevel, Scope scope, Token[] except) throws ParseException { 843 Annotations a; 844 ParsedPattern p; 845 ParsedElementAnnotation e; 846 Token t; 847 a = Annotations(); 848 p = PrimaryExpr(topLevel, scope, a, except); 849 label_5: 850 while (true) { 851 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 852 case FANNOTATE: 853 ; 854 break; 855 default: 856 jj_la1[18] = jj_gen; 857 break label_5; 858 } 859 t = jj_consume_token(FANNOTATE); 860 e = AnnotationElement(false); 861 if (topLevel) 862 error("top_level_follow_annotation", t); 863 else 864 p = sb.annotateAfter(p, e); 865 } 866 {if (true) return p;} 867 throw new Error("Missing return statement in function"); 868 } 869 870 final public ParsedPattern PrimaryExpr(boolean topLevel, Scope scope, Annotations a, Token[] except) throws ParseException { 871 ParsedPattern p; 872 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 873 case 26: 874 p = ElementExpr(scope, a); 875 break; 876 case 27: 877 p = AttributeExpr(scope, a); 878 break; 879 case 10: 880 p = GrammarExpr(scope, a); 881 break; 882 case 33: 883 p = ExternalRefExpr(scope, a); 884 break; 885 case 31: 886 p = ListExpr(scope, a); 887 break; 888 case 32: 889 p = MixedExpr(scope, a); 890 break; 891 case 28: 892 p = ParenExpr(topLevel, scope, a); 893 break; 894 case IDENTIFIER: 895 case ESCAPED_IDENTIFIER: 896 p = IdentifierExpr(scope, a); 897 break; 898 case 34: 899 p = ParentExpr(scope, a); 900 break; 901 case 35: 902 case 36: 903 case PREFIXED_NAME: 904 p = DataExpr(topLevel, scope, a, except); 905 break; 906 case LITERAL: 907 p = ValueExpr(topLevel, a); 908 break; 909 case 18: 910 p = TextExpr(a); 911 break; 912 case 17: 913 p = EmptyExpr(a); 914 break; 915 case 19: 916 p = NotAllowedExpr(a); 917 break; 918 default: 919 jj_la1[19] = jj_gen; 920 jj_consume_token(-1); 921 throw new ParseException(); 922 } 923 {if (true) return p;} 924 throw new Error("Missing return statement in function"); 925 } 926 927 final public ParsedPattern EmptyExpr(Annotations a) throws ParseException { 928 Token t; 929 t = jj_consume_token(17); 930 {if (true) return sb.makeEmpty(makeLocation(t), a);} 931 throw new Error("Missing return statement in function"); 932 } 933 934 final public ParsedPattern TextExpr(Annotations a) throws ParseException { 935 Token t; 936 t = jj_consume_token(18); 937 {if (true) return sb.makeText(makeLocation(t), a);} 938 throw new Error("Missing return statement in function"); 939 } 940 941 final public ParsedPattern NotAllowedExpr(Annotations a) throws ParseException { 942 Token t; 943 t = jj_consume_token(19); 944 {if (true) return sb.makeNotAllowed(makeLocation(t), a);} 945 throw new Error("Missing return statement in function"); 946 } 947 948 final public ParsedPattern Expr(boolean topLevel, Scope scope, Token t, Annotations a) throws ParseException { 949 ParsedPattern p; 950 ParsedPattern[] patterns = new ParsedPattern[2]; 951 int nPatterns = 1; 952 boolean[] hadOccur = new boolean[1]; 953 Token[] except = new Token[1]; 954 p = UnaryExpr(topLevel, scope, hadOccur, except); 955 patterns[0] = p; 956 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 957 case 20: 958 case 21: 959 case 22: 960 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 961 case 20: 962 checkExcept(except); 963 label_6: 964 while (true) { 965 t = jj_consume_token(20); 966 p = UnaryExpr(topLevel, scope, null, except); 967 patterns = addPattern(patterns, nPatterns++, p); checkExcept(except); 968 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 969 case 20: 970 ; 971 break; 972 default: 973 jj_la1[20] = jj_gen; 974 break label_6; 975 } 976 } 977 p = sb.makeChoice(patterns, nPatterns, makeLocation(t), a); 978 break; 979 case 21: 980 label_7: 981 while (true) { 982 t = jj_consume_token(21); 983 p = UnaryExpr(topLevel, scope, null, except); 984 patterns = addPattern(patterns, nPatterns++, p); checkExcept(except); 985 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 986 case 21: 987 ; 988 break; 989 default: 990 jj_la1[21] = jj_gen; 991 break label_7; 992 } 993 } 994 p = sb.makeInterleave(patterns, nPatterns, makeLocation(t), a); 995 break; 996 case 22: 997 label_8: 998 while (true) { 999 t = jj_consume_token(22); 1000 p = UnaryExpr(topLevel, scope, null, except); 1001 patterns = addPattern(patterns, nPatterns++, p); checkExcept(except); 1002 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1003 case 22: 1004 ; 1005 break; 1006 default: 1007 jj_la1[22] = jj_gen; 1008 break label_8; 1009 } 1010 } 1011 p = sb.makeGroup(patterns, nPatterns, makeLocation(t), a); 1012 break; 1013 default: 1014 jj_la1[23] = jj_gen; 1015 jj_consume_token(-1); 1016 throw new ParseException(); 1017 } 1018 break; 1019 default: 1020 jj_la1[24] = jj_gen; 1021 ; 1022 } 1023 if (nPatterns == 1 && a != null) { 1024 if (hadOccur[0]) 1025 p = sb.annotate(p, a); 1026 else 1027 p = sb.makeGroup(patterns, nPatterns, makeLocation(t), a); 1028 } 1029 {if (true) return p;} 1030 throw new Error("Missing return statement in function"); 1031 } 1032 1033 final public ParsedPattern UnaryExpr(boolean topLevel, Scope scope, boolean[] hadOccur, Token[] except) throws ParseException { 1034 ParsedPattern p; 1035 Token t; 1036 ParsedElementAnnotation e; 1037 p = AnnotatedPrimaryExpr(topLevel, scope, except); 1038 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1039 case 23: 1040 case 24: 1041 case 25: 1042 if (hadOccur != null) hadOccur[0] = true; 1043 p = afterComments(p); 1044 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1045 case 23: 1046 t = jj_consume_token(23); 1047 checkExcept(except); p = sb.makeOneOrMore(p, makeLocation(t), null); 1048 break; 1049 case 24: 1050 t = jj_consume_token(24); 1051 checkExcept(except); p = sb.makeOptional(p, makeLocation(t), null); 1052 break; 1053 case 25: 1054 t = jj_consume_token(25); 1055 checkExcept(except); p = sb.makeZeroOrMore(p, makeLocation(t), null); 1056 break; 1057 default: 1058 jj_la1[25] = jj_gen; 1059 jj_consume_token(-1); 1060 throw new ParseException(); 1061 } 1062 label_9: 1063 while (true) { 1064 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1065 case FANNOTATE: 1066 ; 1067 break; 1068 default: 1069 jj_la1[26] = jj_gen; 1070 break label_9; 1071 } 1072 t = jj_consume_token(FANNOTATE); 1073 e = AnnotationElement(false); 1074 if (topLevel) 1075 error("top_level_follow_annotation", t); 1076 else 1077 p = sb.annotateAfter(p, e); 1078 } 1079 break; 1080 default: 1081 jj_la1[27] = jj_gen; 1082 ; 1083 } 1084 {if (true) return p;} 1085 throw new Error("Missing return statement in function"); 1086 } 1087 1088 final public ParsedPattern ElementExpr(Scope scope, Annotations a) throws ParseException { 1089 Token t; 1090 ParsedNameClass nc; 1091 ParsedPattern p; 1092 t = jj_consume_token(26); 1093 nc = NameClass(IN_ELEMENT, null); 1094 jj_consume_token(11); 1095 p = Expr(false, scope, null, null); 1096 p = afterComments(p); 1097 jj_consume_token(12); 1098 {if (true) return sb.makeElement(nc, p, makeLocation(t), a);} 1099 throw new Error("Missing return statement in function"); 1100 } 1101 1102 final public ParsedPattern AttributeExpr(Scope scope, Annotations a) throws ParseException { 1103 Token t; 1104 ParsedNameClass nc; 1105 ParsedPattern p; 1106 t = jj_consume_token(27); 1107 nc = NameClass(IN_ATTRIBUTE, null); 1108 jj_consume_token(11); 1109 p = Expr(false, scope, null, null); 1110 p = afterComments(p); 1111 jj_consume_token(12); 1112 {if (true) return sb.makeAttribute(nc, p, makeLocation(t), a);} 1113 throw new Error("Missing return statement in function"); 1114 } 1115 1116 final public ParsedNameClass NameClass(int context, Annotations[] pa) throws ParseException { 1117 Annotations a; 1118 ParsedNameClass nc; 1119 a = Annotations(); 1120 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1121 case 5: 1122 case 6: 1123 case 7: 1124 case 10: 1125 case 13: 1126 case 14: 1127 case 15: 1128 case 16: 1129 case 17: 1130 case 18: 1131 case 19: 1132 case 26: 1133 case 27: 1134 case 28: 1135 case 31: 1136 case 32: 1137 case 33: 1138 case 34: 1139 case 35: 1140 case 36: 1141 case IDENTIFIER: 1142 case ESCAPED_IDENTIFIER: 1143 case PREFIXED_NAME: 1144 nc = PrimaryNameClass(context, a); 1145 nc = AnnotateAfter(nc); 1146 nc = NameClassAlternatives(context, nc, pa); 1147 break; 1148 case 25: 1149 nc = AnyNameExceptClass(context, a, pa); 1150 break; 1151 case PREFIX_STAR: 1152 nc = NsNameExceptClass(context, a, pa); 1153 break; 1154 default: 1155 jj_la1[28] = jj_gen; 1156 jj_consume_token(-1); 1157 throw new ParseException(); 1158 } 1159 {if (true) return nc;} 1160 throw new Error("Missing return statement in function"); 1161 } 1162 1163 final public ParsedNameClass AnnotateAfter(ParsedNameClass nc) throws ParseException { 1164 ParsedElementAnnotation e; 1165 label_10: 1166 while (true) { 1167 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1168 case FANNOTATE: 1169 ; 1170 break; 1171 default: 1172 jj_la1[29] = jj_gen; 1173 break label_10; 1174 } 1175 jj_consume_token(FANNOTATE); 1176 e = AnnotationElement(false); 1177 nc = sb.annotateAfter(nc, e); 1178 } 1179 {if (true) return nc;} 1180 throw new Error("Missing return statement in function"); 1181 } 1182 1183 final public ParsedNameClass NameClassAlternatives(int context, ParsedNameClass nc, Annotations[] pa) throws ParseException { 1184 Token t; 1185 ParsedNameClass[] nameClasses; 1186 int nNameClasses; 1187 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1188 case 20: 1189 nameClasses = new ParsedNameClass[2]; 1190 nameClasses[0] = nc; 1191 nNameClasses = 1; 1192 label_11: 1193 while (true) { 1194 t = jj_consume_token(20); 1195 nc = BasicNameClass(context); 1196 nc = AnnotateAfter(nc); 1197 if (nNameClasses >= nameClasses.length) { 1198 ParsedNameClass[] oldNameClasses = nameClasses; 1199 nameClasses = new ParsedNameClass[oldNameClasses.length*2]; 1200 System.arraycopy(oldNameClasses, 0, nameClasses, 0, oldNameClasses.length); 1201 } 1202 nameClasses[nNameClasses++] = nc; 1203 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1204 case 20: 1205 ; 1206 break; 1207 default: 1208 jj_la1[30] = jj_gen; 1209 break label_11; 1210 } 1211 } 1212 Annotations a; 1213 if (pa == null) 1214 a = null; 1215 else { 1216 a = pa[0]; 1217 pa[0] = null; 1218 } 1219 nc = sb.makeChoice(nameClasses, nNameClasses, makeLocation(t), a); 1220 break; 1221 default: 1222 jj_la1[31] = jj_gen; 1223 ; 1224 } 1225 {if (true) return nc;} 1226 throw new Error("Missing return statement in function"); 1227 } 1228 1229 final public ParsedNameClass BasicNameClass(int context) throws ParseException { 1230 Annotations a; 1231 ParsedNameClass nc; 1232 a = Annotations(); 1233 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1234 case 5: 1235 case 6: 1236 case 7: 1237 case 10: 1238 case 13: 1239 case 14: 1240 case 15: 1241 case 16: 1242 case 17: 1243 case 18: 1244 case 19: 1245 case 26: 1246 case 27: 1247 case 28: 1248 case 31: 1249 case 32: 1250 case 33: 1251 case 34: 1252 case 35: 1253 case 36: 1254 case IDENTIFIER: 1255 case ESCAPED_IDENTIFIER: 1256 case PREFIXED_NAME: 1257 nc = PrimaryNameClass(context, a); 1258 break; 1259 case 25: 1260 case PREFIX_STAR: 1261 nc = OpenNameClass(context, a); 1262 break; 1263 default: 1264 jj_la1[32] = jj_gen; 1265 jj_consume_token(-1); 1266 throw new ParseException(); 1267 } 1268 {if (true) return nc;} 1269 throw new Error("Missing return statement in function"); 1270 } 1271 1272 final public ParsedNameClass PrimaryNameClass(int context, Annotations a) throws ParseException { 1273 ParsedNameClass nc; 1274 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1275 case 5: 1276 case 6: 1277 case 7: 1278 case 10: 1279 case 13: 1280 case 14: 1281 case 15: 1282 case 16: 1283 case 17: 1284 case 18: 1285 case 19: 1286 case 26: 1287 case 27: 1288 case 31: 1289 case 32: 1290 case 33: 1291 case 34: 1292 case 35: 1293 case 36: 1294 case IDENTIFIER: 1295 case ESCAPED_IDENTIFIER: 1296 nc = UnprefixedNameClass(context, a); 1297 break; 1298 case PREFIXED_NAME: 1299 nc = PrefixedNameClass(a); 1300 break; 1301 case 28: 1302 nc = ParenNameClass(context, a); 1303 break; 1304 default: 1305 jj_la1[33] = jj_gen; 1306 jj_consume_token(-1); 1307 throw new ParseException(); 1308 } 1309 {if (true) return nc;} 1310 throw new Error("Missing return statement in function"); 1311 } 1312 1313 final public ParsedNameClass OpenNameClass(int context, Annotations a) throws ParseException { 1314 Token t; 1315 LocatedString ns; 1316 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1317 case PREFIX_STAR: 1318 ns = NsName(); 1319 checkNsName(context, ns); {if (true) return sb.makeNsName(ns.getString(), ns.getLocation(), a);} 1320 break; 1321 case 25: 1322 t = jj_consume_token(25); 1323 checkAnyName(context, t); {if (true) return sb.makeAnyName(makeLocation(t), a);} 1324 break; 1325 default: 1326 jj_la1[34] = jj_gen; 1327 jj_consume_token(-1); 1328 throw new ParseException(); 1329 } 1330 throw new Error("Missing return statement in function"); 1331 } 1332 1333 final public ParsedNameClass UnprefixedNameClass(int context, Annotations a) throws ParseException { 1334 LocatedString name; 1335 name = UnprefixedName(); 1336 String ns; 1337 if ((context & (IN_ATTRIBUTE|IN_ELEMENT)) == IN_ATTRIBUTE) 1338 ns = ""; 1339 else 1340 ns = defaultNamespace; 1341 {if (true) return sb.makeName(ns, name.getString(), null, name.getLocation(), a);} 1342 throw new Error("Missing return statement in function"); 1343 } 1344 1345 final public ParsedNameClass PrefixedNameClass(Annotations a) throws ParseException { 1346 Token t; 1347 t = jj_consume_token(PREFIXED_NAME); 1348 String qn = t.image; 1349 int colon = qn.indexOf(':'); 1350 String prefix = qn.substring(0, colon); 1351 {if (true) return sb.makeName(lookupPrefix(prefix, t), qn.substring(colon + 1), prefix, makeLocation(t), a);} 1352 throw new Error("Missing return statement in function"); 1353 } 1354 1355 final public ParsedNameClass NsNameExceptClass(int context, Annotations a, Annotations[] pa) throws ParseException { 1356 LocatedString ns; 1357 ParsedNameClass nc; 1358 ns = NsName(); 1359 checkNsName(context, ns); 1360 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1361 case 30: 1362 nc = ExceptNameClass(context | IN_NS_NAME); 1363 nc = sb.makeNsName(ns.getString(), nc, ns.getLocation(), a); 1364 nc = AnnotateAfter(nc); 1365 break; 1366 default: 1367 jj_la1[35] = jj_gen; 1368 nc = sb.makeNsName(ns.getString(), ns.getLocation(), a); 1369 nc = AnnotateAfter(nc); 1370 nc = NameClassAlternatives(context, nc, pa); 1371 } 1372 {if (true) return nc;} 1373 throw new Error("Missing return statement in function"); 1374 } 1375 1376 final public LocatedString NsName() throws ParseException { 1377 Token t; 1378 t = jj_consume_token(PREFIX_STAR); 1379 String qn = t.image; 1380 String prefix = qn.substring(0, qn.length() - 2); 1381 {if (true) return new LocatedString(lookupPrefix(prefix, t), t);} 1382 throw new Error("Missing return statement in function"); 1383 } 1384 1385 final public ParsedNameClass AnyNameExceptClass(int context, Annotations a, Annotations[] pa) throws ParseException { 1386 Token t; 1387 ParsedNameClass nc; 1388 t = jj_consume_token(25); 1389 checkAnyName(context, t); 1390 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1391 case 30: 1392 nc = ExceptNameClass(context | IN_ANY_NAME); 1393 nc = sb.makeAnyName(nc, makeLocation(t), a); 1394 nc = AnnotateAfter(nc); 1395 break; 1396 default: 1397 jj_la1[36] = jj_gen; 1398 nc = sb.makeAnyName(makeLocation(t), a); 1399 nc = AnnotateAfter(nc); 1400 nc = NameClassAlternatives(context, nc, pa); 1401 } 1402 {if (true) return nc;} 1403 throw new Error("Missing return statement in function"); 1404 } 1405 1406 final public ParsedNameClass ParenNameClass(int context, Annotations a) throws ParseException { 1407 Token t; 1408 ParsedNameClass nc; 1409 Annotations[] pa = new Annotations[]{ a }; 1410 t = jj_consume_token(28); 1411 nc = NameClass(context, pa); 1412 nc = afterComments(nc); 1413 jj_consume_token(29); 1414 if (pa[0] != null) 1415 nc = sb.makeChoice(new ParsedNameClass[] { nc }, 1, makeLocation(t), pa[0]); 1416 {if (true) return nc;} 1417 throw new Error("Missing return statement in function"); 1418 } 1419 1420 final public ParsedNameClass ExceptNameClass(int context) throws ParseException { 1421 ParsedNameClass nc; 1422 jj_consume_token(30); 1423 nc = BasicNameClass(context); 1424 {if (true) return nc;} 1425 throw new Error("Missing return statement in function"); 1426 } 1427 1428 final public ParsedPattern ListExpr(Scope scope, Annotations a) throws ParseException { 1429 Token t; 1430 ParsedPattern p; 1431 t = jj_consume_token(31); 1432 jj_consume_token(11); 1433 p = Expr(false, scope, null, null); 1434 p = afterComments(p); 1435 jj_consume_token(12); 1436 {if (true) return sb.makeList(p, makeLocation(t), a);} 1437 throw new Error("Missing return statement in function"); 1438 } 1439 1440 final public ParsedPattern MixedExpr(Scope scope, Annotations a) throws ParseException { 1441 Token t; 1442 ParsedPattern p; 1443 t = jj_consume_token(32); 1444 jj_consume_token(11); 1445 p = Expr(false, scope, null, null); 1446 p = afterComments(p); 1447 jj_consume_token(12); 1448 {if (true) return sb.makeMixed(p, makeLocation(t), a);} 1449 throw new Error("Missing return statement in function"); 1450 } 1451 1452 final public ParsedPattern GrammarExpr(Scope scope, Annotations a) throws ParseException { 1453 Token t; 1454 Grammar g; 1455 t = jj_consume_token(10); 1456 g = sb.makeGrammar(scope); 1457 jj_consume_token(11); 1458 a = GrammarBody(g, g, a); 1459 topLevelComments(g); 1460 jj_consume_token(12); 1461 {if (true) return g.endGrammar(makeLocation(t), a);} 1462 throw new Error("Missing return statement in function"); 1463 } 1464 1465 final public ParsedPattern ParenExpr(boolean topLevel, Scope scope, Annotations a) throws ParseException { 1466 Token t; 1467 ParsedPattern p; 1468 t = jj_consume_token(28); 1469 p = Expr(topLevel, scope, t, a); 1470 p = afterComments(p); 1471 jj_consume_token(29); 1472 {if (true) return p;} 1473 throw new Error("Missing return statement in function"); 1474 } 1475 1476 final public Annotations GrammarBody(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1477 ParsedElementAnnotation e; 1478 label_12: 1479 while (true) { 1480 if (jj_2_3(2)) { 1481 ; 1482 } else { 1483 break label_12; 1484 } 1485 e = AnnotationElementNotKeyword(); 1486 if (a == null) a = sb.makeAnnotations(null, getContext()); a.addElement(e); 1487 } 1488 label_13: 1489 while (true) { 1490 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1491 case 1: 1492 case 5: 1493 case 6: 1494 case 7: 1495 case DOCUMENTATION: 1496 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 1497 case IDENTIFIER: 1498 case ESCAPED_IDENTIFIER: 1499 ; 1500 break; 1501 default: 1502 jj_la1[37] = jj_gen; 1503 break label_13; 1504 } 1505 GrammarComponent(section, scope); 1506 } 1507 {if (true) return a;} 1508 throw new Error("Missing return statement in function"); 1509 } 1510 1511 final public void GrammarComponent(GrammarSection section, Scope scope) throws ParseException { 1512 ParsedElementAnnotation e; 1513 Annotations a; 1514 a = Annotations(); 1515 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1516 case 5: 1517 case IDENTIFIER: 1518 case ESCAPED_IDENTIFIER: 1519 Definition(section, scope, a); 1520 break; 1521 case 7: 1522 Include(section, scope, a); 1523 break; 1524 case 6: 1525 Div(section, scope, a); 1526 break; 1527 default: 1528 jj_la1[38] = jj_gen; 1529 jj_consume_token(-1); 1530 throw new ParseException(); 1531 } 1532 label_14: 1533 while (true) { 1534 if (jj_2_4(2)) { 1535 ; 1536 } else { 1537 break label_14; 1538 } 1539 e = AnnotationElementNotKeyword(); 1540 section.topLevelAnnotation(e); 1541 } 1542 } 1543 1544 final public void Definition(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1545 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1546 case IDENTIFIER: 1547 case ESCAPED_IDENTIFIER: 1548 Define(section, scope, a); 1549 break; 1550 case 5: 1551 Start(section, scope, a); 1552 break; 1553 default: 1554 jj_la1[39] = jj_gen; 1555 jj_consume_token(-1); 1556 throw new ParseException(); 1557 } 1558 } 1559 1560 final public void Start(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1561 Token t; 1562 GrammarSection.Combine combine; 1563 ParsedPattern p; 1564 t = jj_consume_token(5); 1565 combine = AssignOp(); 1566 p = Expr(false, scope, null, null); 1567 section.define(GrammarSection.START, combine, p, makeLocation(t), a); 1568 } 1569 1570 final public void Define(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1571 LocatedString name; 1572 GrammarSection.Combine combine; 1573 ParsedPattern p; 1574 name = Identifier(); 1575 combine = AssignOp(); 1576 p = Expr(false, scope, null, null); 1577 section.define(name.getString(), combine, p, name.getLocation(), a); 1578 } 1579 1580 final public GrammarSection.Combine AssignOp() throws ParseException { 1581 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1582 case 2: 1583 jj_consume_token(2); 1584 {if (true) return null;} 1585 break; 1586 case 4: 1587 jj_consume_token(4); 1588 {if (true) return GrammarSection.COMBINE_CHOICE;} 1589 break; 1590 case 3: 1591 jj_consume_token(3); 1592 {if (true) return GrammarSection.COMBINE_INTERLEAVE;} 1593 break; 1594 default: 1595 jj_la1[40] = jj_gen; 1596 jj_consume_token(-1); 1597 throw new ParseException(); 1598 } 1599 throw new Error("Missing return statement in function"); 1600 } 1601 1602 final public void Include(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1603 Token t; 1604 String href; 1605 String ns; 1606 Include include = section.makeInclude(); 1607 t = jj_consume_token(7); 1608 href = Literal(); 1609 ns = Inherit(); 1610 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1611 case 11: 1612 jj_consume_token(11); 1613 a = IncludeBody(include, scope, a); 1614 topLevelComments(include); 1615 jj_consume_token(12); 1616 break; 1617 default: 1618 jj_la1[41] = jj_gen; 1619 ; 1620 } 1621 try { 1622 include.endInclude(resolve(href), ns, makeLocation(t), a); 1623 } 1624 catch (IllegalSchemaException e) { } 1625 } 1626 1627 final public Annotations IncludeBody(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1628 ParsedElementAnnotation e; 1629 label_15: 1630 while (true) { 1631 if (jj_2_5(2)) { 1632 ; 1633 } else { 1634 break label_15; 1635 } 1636 e = AnnotationElementNotKeyword(); 1637 if (a == null) a = sb.makeAnnotations(null, getContext()); a.addElement(e); 1638 } 1639 label_16: 1640 while (true) { 1641 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1642 case 1: 1643 case 5: 1644 case 6: 1645 case DOCUMENTATION: 1646 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 1647 case IDENTIFIER: 1648 case ESCAPED_IDENTIFIER: 1649 ; 1650 break; 1651 default: 1652 jj_la1[42] = jj_gen; 1653 break label_16; 1654 } 1655 IncludeComponent(section, scope); 1656 } 1657 {if (true) return a;} 1658 throw new Error("Missing return statement in function"); 1659 } 1660 1661 final public void IncludeComponent(GrammarSection section, Scope scope) throws ParseException { 1662 ParsedElementAnnotation e; 1663 Annotations a; 1664 a = Annotations(); 1665 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1666 case 5: 1667 case IDENTIFIER: 1668 case ESCAPED_IDENTIFIER: 1669 Definition(section, scope, a); 1670 break; 1671 case 6: 1672 IncludeDiv(section, scope, a); 1673 break; 1674 default: 1675 jj_la1[43] = jj_gen; 1676 jj_consume_token(-1); 1677 throw new ParseException(); 1678 } 1679 label_17: 1680 while (true) { 1681 if (jj_2_6(2)) { 1682 ; 1683 } else { 1684 break label_17; 1685 } 1686 e = AnnotationElementNotKeyword(); 1687 section.topLevelAnnotation(e); 1688 } 1689 } 1690 1691 final public void Div(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1692 Token t; 1693 Div div = section.makeDiv(); 1694 t = jj_consume_token(6); 1695 jj_consume_token(11); 1696 a = GrammarBody(div, scope, a); 1697 topLevelComments(div); 1698 jj_consume_token(12); 1699 div.endDiv(makeLocation(t), a); 1700 } 1701 1702 final public void IncludeDiv(GrammarSection section, Scope scope, Annotations a) throws ParseException { 1703 Token t; 1704 Div div = section.makeDiv(); 1705 t = jj_consume_token(6); 1706 jj_consume_token(11); 1707 a = IncludeBody(div, scope, a); 1708 topLevelComments(div); 1709 jj_consume_token(12); 1710 div.endDiv(makeLocation(t), a); 1711 } 1712 1713 final public ParsedPattern ExternalRefExpr(Scope scope, Annotations a) throws ParseException { 1714 Token t; 1715 String href; 1716 String ns; 1717 t = jj_consume_token(33); 1718 href = Literal(); 1719 ns = Inherit(); 1720 try { 1721 {if (true) return sb.makeExternalRef(resolve(href), ns, scope, makeLocation(t), a);} 1722 } 1723 catch (IllegalSchemaException e) { 1724 {if (true) return sb.makeErrorPattern();} 1725 } 1726 throw new Error("Missing return statement in function"); 1727 } 1728 1729 final public String Inherit() throws ParseException { 1730 String ns = null; 1731 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1732 case 15: 1733 jj_consume_token(15); 1734 jj_consume_token(2); 1735 ns = Prefix(); 1736 break; 1737 default: 1738 jj_la1[44] = jj_gen; 1739 ; 1740 } 1741 if (ns == null) 1742 ns = defaultNamespace; 1743 {if (true) return ns;} 1744 throw new Error("Missing return statement in function"); 1745 } 1746 1747 final public ParsedPattern ParentExpr(Scope scope, Annotations a) throws ParseException { 1748 LocatedString name; 1749 jj_consume_token(34); 1750 a = addCommentsToChildAnnotations(a); 1751 name = Identifier(); 1752 {if (true) return scope.makeParentRef(name.getString(), name.getLocation(), a);} 1753 throw new Error("Missing return statement in function"); 1754 } 1755 1756 final public ParsedPattern IdentifierExpr(Scope scope, Annotations a) throws ParseException { 1757 LocatedString name; 1758 name = Identifier(); 1759 {if (true) return scope.makeRef(name.getString(), name.getLocation(), a);} 1760 throw new Error("Missing return statement in function"); 1761 } 1762 1763 final public ParsedPattern ValueExpr(boolean topLevel, Annotations a) throws ParseException { 1764 LocatedString s; 1765 s = LocatedLiteral(); 1766 if (topLevel && annotationsIncludeElements) { 1767 error("top_level_follow_annotation", s.getToken()); 1768 a = null; 1769 } 1770 {if (true) return sb.makeValue("", "token", s.getString(), getContext(), defaultNamespace, s.getLocation(), a);} 1771 throw new Error("Missing return statement in function"); 1772 } 1773 1774 final public ParsedPattern DataExpr(boolean topLevel, Scope scope, Annotations a, Token[] except) throws ParseException { 1775 Token datatypeToken; 1776 Location loc; 1777 String datatype; 1778 String datatypeUri = null; 1779 String s = null; 1780 ParsedPattern e = null; 1781 DataPatternBuilder dpb; 1782 datatypeToken = DatatypeName(); 1783 datatype = datatypeToken.image; 1784 loc = makeLocation(datatypeToken); 1785 int colon = datatype.indexOf(':'); 1786 if (colon < 0) 1787 datatypeUri = ""; 1788 else { 1789 String prefix = datatype.substring(0, colon); 1790 datatypeUri = lookupDatatype(prefix, datatypeToken); 1791 datatype = datatype.substring(colon + 1); 1792 } 1793 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1794 case LITERAL: 1795 s = Literal(); 1796 if (topLevel && annotationsIncludeElements) { 1797 error("top_level_follow_annotation", datatypeToken); 1798 a = null; 1799 } 1800 {if (true) return sb.makeValue(datatypeUri, datatype, s, getContext(), defaultNamespace, loc, a);} 1801 break; 1802 default: 1803 jj_la1[48] = jj_gen; 1804 dpb = sb.makeDataPatternBuilder(datatypeUri, datatype, loc); 1805 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1806 case 11: 1807 Params(dpb); 1808 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1809 case 30: 1810 e = Except(scope, except); 1811 break; 1812 default: 1813 jj_la1[45] = jj_gen; 1814 ; 1815 } 1816 break; 1817 default: 1818 jj_la1[47] = jj_gen; 1819 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1820 case 30: 1821 e = Except(scope, except); 1822 break; 1823 default: 1824 jj_la1[46] = jj_gen; 1825 ; 1826 } 1827 } 1828 {if (true) return e == null ? dpb.makePattern(loc, a) : dpb.makePattern(e, loc, a);} 1829 } 1830 throw new Error("Missing return statement in function"); 1831 } 1832 1833 final public Token DatatypeName() throws ParseException { 1834 Token t; 1835 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1836 case 35: 1837 t = jj_consume_token(35); 1838 break; 1839 case 36: 1840 t = jj_consume_token(36); 1841 break; 1842 case PREFIXED_NAME: 1843 t = jj_consume_token(PREFIXED_NAME); 1844 break; 1845 default: 1846 jj_la1[49] = jj_gen; 1847 jj_consume_token(-1); 1848 throw new ParseException(); 1849 } 1850 {if (true) return t;} 1851 throw new Error("Missing return statement in function"); 1852 } 1853 1854 final public LocatedString Identifier() throws ParseException { 1855 LocatedString s; 1856 Token t; 1857 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1858 case IDENTIFIER: 1859 t = jj_consume_token(IDENTIFIER); 1860 s = new LocatedString(t.image, t); 1861 break; 1862 case ESCAPED_IDENTIFIER: 1863 t = jj_consume_token(ESCAPED_IDENTIFIER); 1864 s = new LocatedString(t.image.substring(1), t); 1865 break; 1866 default: 1867 jj_la1[50] = jj_gen; 1868 jj_consume_token(-1); 1869 throw new ParseException(); 1870 } 1871 {if (true) return s;} 1872 throw new Error("Missing return statement in function"); 1873 } 1874 1875 final public String Prefix() throws ParseException { 1876 Token t; 1877 String prefix; 1878 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1879 case IDENTIFIER: 1880 t = jj_consume_token(IDENTIFIER); 1881 prefix = t.image; 1882 break; 1883 case ESCAPED_IDENTIFIER: 1884 t = jj_consume_token(ESCAPED_IDENTIFIER); 1885 prefix = t.image.substring(1); 1886 break; 1887 case 5: 1888 case 6: 1889 case 7: 1890 case 10: 1891 case 13: 1892 case 14: 1893 case 15: 1894 case 16: 1895 case 17: 1896 case 18: 1897 case 19: 1898 case 26: 1899 case 27: 1900 case 31: 1901 case 32: 1902 case 33: 1903 case 34: 1904 case 35: 1905 case 36: 1906 t = Keyword(); 1907 prefix = t.image; 1908 break; 1909 default: 1910 jj_la1[51] = jj_gen; 1911 jj_consume_token(-1); 1912 throw new ParseException(); 1913 } 1914 {if (true) return lookupPrefix(prefix, t);} 1915 throw new Error("Missing return statement in function"); 1916 } 1917 1918 final public LocatedString UnprefixedName() throws ParseException { 1919 LocatedString s; 1920 Token t; 1921 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1922 case IDENTIFIER: 1923 case ESCAPED_IDENTIFIER: 1924 s = Identifier(); 1925 break; 1926 case 5: 1927 case 6: 1928 case 7: 1929 case 10: 1930 case 13: 1931 case 14: 1932 case 15: 1933 case 16: 1934 case 17: 1935 case 18: 1936 case 19: 1937 case 26: 1938 case 27: 1939 case 31: 1940 case 32: 1941 case 33: 1942 case 34: 1943 case 35: 1944 case 36: 1945 t = Keyword(); 1946 s = new LocatedString(t.image, t); 1947 break; 1948 default: 1949 jj_la1[52] = jj_gen; 1950 jj_consume_token(-1); 1951 throw new ParseException(); 1952 } 1953 {if (true) return s;} 1954 throw new Error("Missing return statement in function"); 1955 } 1956 1957 final public void Params(DataPatternBuilder dpb) throws ParseException { 1958 jj_consume_token(11); 1959 label_18: 1960 while (true) { 1961 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 1962 case 1: 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 case DOCUMENTATION: 1983 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 1984 case IDENTIFIER: 1985 case ESCAPED_IDENTIFIER: 1986 ; 1987 break; 1988 default: 1989 jj_la1[53] = jj_gen; 1990 break label_18; 1991 } 1992 Param(dpb); 1993 } 1994 jj_consume_token(12); 1995 } 1996 1997 final public void Param(DataPatternBuilder dpb) throws ParseException { 1998 LocatedString name; 1999 Annotations a; 2000 String value; 2001 a = Annotations(); 2002 name = UnprefixedName(); 2003 jj_consume_token(2); 2004 a = addCommentsToLeadingAnnotations(a); 2005 value = Literal(); 2006 dpb.addParam(name.getString(), value, getContext(), defaultNamespace, name.getLocation(), a); 2007 } 2008 2009 final public ParsedPattern Except(Scope scope, Token[] except) throws ParseException { 2010 Annotations a; 2011 ParsedPattern p; 2012 Token t; 2013 Token[] innerExcept = new Token[1]; 2014 t = jj_consume_token(30); 2015 a = Annotations(); 2016 p = PrimaryExpr(false, scope, a, innerExcept); 2017 checkExcept(innerExcept); 2018 except[0] = t; 2019 {if (true) return p;} 2020 throw new Error("Missing return statement in function"); 2021 } 2022 2023 final public ParsedElementAnnotation Documentation() throws ParseException { 2024 CommentList comments = getComments(); 2025 ElementAnnotationBuilder eab; 2026 Token t; 2027 String s; 2028 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2029 case DOCUMENTATION: 2030 t = jj_consume_token(DOCUMENTATION); 2031 break; 2032 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 2033 t = jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT); 2034 break; 2035 default: 2036 jj_la1[54] = jj_gen; 2037 jj_consume_token(-1); 2038 throw new ParseException(); 2039 } 2040 eab = sb.makeElementAnnotationBuilder(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS, 2041 "documentation", 2042 getCompatibilityPrefix(), 2043 makeLocation(t), 2044 comments, 2045 getContext()); 2046 eab.addText(mungeComment(t.image), makeLocation(t), null); 2047 label_19: 2048 while (true) { 2049 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2050 case DOCUMENTATION_CONTINUE: 2051 ; 2052 break; 2053 default: 2054 jj_la1[55] = jj_gen; 2055 break label_19; 2056 } 2057 t = jj_consume_token(DOCUMENTATION_CONTINUE); 2058 eab.addText("\n" + mungeComment(t.image), makeLocation(t), null); 2059 } 2060 {if (true) return eab.makeElementAnnotation();} 2061 throw new Error("Missing return statement in function"); 2062 } 2063 2064 final public Annotations Annotations() throws ParseException { 2065 CommentList comments = getComments(); 2066 Annotations a = null; 2067 ParsedElementAnnotation e; 2068 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2069 case DOCUMENTATION: 2070 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 2071 a = sb.makeAnnotations(comments, getContext()); 2072 label_20: 2073 while (true) { 2074 e = Documentation(); 2075 a.addElement(e); 2076 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2077 case DOCUMENTATION: 2078 case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT: 2079 ; 2080 break; 2081 default: 2082 jj_la1[56] = jj_gen; 2083 break label_20; 2084 } 2085 } 2086 comments = getComments(); 2087 if (comments != null) 2088 a.addLeadingComment(comments); 2089 break; 2090 default: 2091 jj_la1[57] = jj_gen; 2092 ; 2093 } 2094 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2095 case 1: 2096 jj_consume_token(1); 2097 if (a == null) a = sb.makeAnnotations(comments, getContext()); clearAttributeList(); annotationsIncludeElements = false; 2098 label_21: 2099 while (true) { 2100 if (jj_2_7(2)) { 2101 ; 2102 } else { 2103 break label_21; 2104 } 2105 PrefixedAnnotationAttribute(a, false); 2106 } 2107 label_22: 2108 while (true) { 2109 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2110 case 5: 2111 case 6: 2112 case 7: 2113 case 10: 2114 case 13: 2115 case 14: 2116 case 15: 2117 case 16: 2118 case 17: 2119 case 18: 2120 case 19: 2121 case 26: 2122 case 27: 2123 case 31: 2124 case 32: 2125 case 33: 2126 case 34: 2127 case 35: 2128 case 36: 2129 case IDENTIFIER: 2130 case ESCAPED_IDENTIFIER: 2131 case PREFIXED_NAME: 2132 ; 2133 break; 2134 default: 2135 jj_la1[58] = jj_gen; 2136 break label_22; 2137 } 2138 e = AnnotationElement(false); 2139 a.addElement(e); annotationsIncludeElements = true; 2140 } 2141 a.addComment(getComments()); 2142 jj_consume_token(9); 2143 break; 2144 default: 2145 jj_la1[59] = jj_gen; 2146 ; 2147 } 2148 if (a == null && comments != null) 2149 a = sb.makeAnnotations(comments, getContext()); 2150 {if (true) return a;} 2151 throw new Error("Missing return statement in function"); 2152 } 2153 2154 final public void AnnotationAttribute(Annotations a) throws ParseException { 2155 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2156 case PREFIXED_NAME: 2157 PrefixedAnnotationAttribute(a, true); 2158 break; 2159 case 5: 2160 case 6: 2161 case 7: 2162 case 10: 2163 case 13: 2164 case 14: 2165 case 15: 2166 case 16: 2167 case 17: 2168 case 18: 2169 case 19: 2170 case 26: 2171 case 27: 2172 case 31: 2173 case 32: 2174 case 33: 2175 case 34: 2176 case 35: 2177 case 36: 2178 case IDENTIFIER: 2179 case ESCAPED_IDENTIFIER: 2180 UnprefixedAnnotationAttribute(a); 2181 break; 2182 default: 2183 jj_la1[60] = jj_gen; 2184 jj_consume_token(-1); 2185 throw new ParseException(); 2186 } 2187 } 2188 2189 final public void PrefixedAnnotationAttribute(Annotations a, boolean nested) throws ParseException { 2190 Token t; 2191 String value; 2192 t = jj_consume_token(PREFIXED_NAME); 2193 jj_consume_token(2); 2194 value = Literal(); 2195 String qn = t.image; 2196 int colon = qn.indexOf(':'); 2197 String prefix = qn.substring(0, colon); 2198 String ns = lookupPrefix(prefix, t); 2199 if (ns == SchemaBuilder.INHERIT_NS) 2200 error("inherited_annotation_namespace", t); 2201 else if (ns.length() == 0 && !nested) 2202 error("unqualified_annotation_attribute", t); 2203 else if (ns.equals(WellKnownNamespaces.RELAX_NG) && !nested) 2204 error("relax_ng_namespace", t); 2205 2209 else if (ns.equals(WellKnownNamespaces.XMLNS)) 2210 error("xmlns_annotation_attribute_uri", t); 2211 else { 2212 if (ns.length() == 0) 2213 prefix = null; 2214 addAttribute(a, ns, qn.substring(colon + 1), prefix, value, t); 2215 } 2216 } 2217 2218 final public void UnprefixedAnnotationAttribute(Annotations a) throws ParseException { 2219 LocatedString name; 2220 String value; 2221 name = UnprefixedName(); 2222 jj_consume_token(2); 2223 value = Literal(); 2224 if (name.getString().equals("xmlns")) 2225 error("xmlns_annotation_attribute", name.getToken()); 2226 else 2227 addAttribute(a, "", name.getString(), null, value, name.getToken()); 2228 } 2229 2230 final public ParsedElementAnnotation AnnotationElement(boolean nested) throws ParseException { 2231 ParsedElementAnnotation a; 2232 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2233 case PREFIXED_NAME: 2234 a = PrefixedAnnotationElement(nested); 2235 break; 2236 case 5: 2237 case 6: 2238 case 7: 2239 case 10: 2240 case 13: 2241 case 14: 2242 case 15: 2243 case 16: 2244 case 17: 2245 case 18: 2246 case 19: 2247 case 26: 2248 case 27: 2249 case 31: 2250 case 32: 2251 case 33: 2252 case 34: 2253 case 35: 2254 case 36: 2255 case IDENTIFIER: 2256 case ESCAPED_IDENTIFIER: 2257 a = UnprefixedAnnotationElement(); 2258 break; 2259 default: 2260 jj_la1[61] = jj_gen; 2261 jj_consume_token(-1); 2262 throw new ParseException(); 2263 } 2264 {if (true) return a;} 2265 throw new Error("Missing return statement in function"); 2266 } 2267 2268 final public ParsedElementAnnotation AnnotationElementNotKeyword() throws ParseException { 2269 ParsedElementAnnotation a; 2270 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2271 case PREFIXED_NAME: 2272 a = PrefixedAnnotationElement(false); 2273 break; 2274 case IDENTIFIER: 2275 case ESCAPED_IDENTIFIER: 2276 a = IdentifierAnnotationElement(); 2277 break; 2278 default: 2279 jj_la1[62] = jj_gen; 2280 jj_consume_token(-1); 2281 throw new ParseException(); 2282 } 2283 {if (true) return a;} 2284 throw new Error("Missing return statement in function"); 2285 } 2286 2287 final public ParsedElementAnnotation PrefixedAnnotationElement(boolean nested) throws ParseException { 2288 CommentList comments = getComments(); 2289 Token t; 2290 ElementAnnotationBuilder eab; 2291 t = jj_consume_token(PREFIXED_NAME); 2292 String qn = t.image; 2293 int colon = qn.indexOf(':'); 2294 String prefix = qn.substring(0, colon); 2295 String ns = lookupPrefix(prefix, t); 2296 if (ns == SchemaBuilder.INHERIT_NS) { 2297 error("inherited_annotation_namespace", t); 2298 ns = ""; 2299 } 2300 else if (!nested && ns.equals(WellKnownNamespaces.RELAX_NG)) { 2301 error("relax_ng_namespace", t); 2302 ns = ""; 2303 } 2304 else { 2305 if (ns.length() == 0) 2306 prefix = null; 2307 } 2308 eab = sb.makeElementAnnotationBuilder(ns, qn.substring(colon + 1), prefix, 2309 makeLocation(t), comments, getContext()); 2310 AnnotationElementContent(eab); 2311 {if (true) return eab.makeElementAnnotation();} 2312 throw new Error("Missing return statement in function"); 2313 } 2314 2315 final public ParsedElementAnnotation UnprefixedAnnotationElement() throws ParseException { 2316 CommentList comments = getComments(); 2317 LocatedString name; 2318 ElementAnnotationBuilder eab; 2319 name = UnprefixedName(); 2320 eab = sb.makeElementAnnotationBuilder("", name.getString(), null, 2321 name.getLocation(), comments, getContext()); 2322 AnnotationElementContent(eab); 2323 {if (true) return eab.makeElementAnnotation();} 2324 throw new Error("Missing return statement in function"); 2325 } 2326 2327 final public ParsedElementAnnotation IdentifierAnnotationElement() throws ParseException { 2328 CommentList comments = getComments(); 2329 LocatedString name; 2330 ElementAnnotationBuilder eab; 2331 name = Identifier(); 2332 eab = sb.makeElementAnnotationBuilder("", name.getString(), null, 2333 name.getLocation(), comments, getContext()); 2334 AnnotationElementContent(eab); 2335 {if (true) return eab.makeElementAnnotation();} 2336 throw new Error("Missing return statement in function"); 2337 } 2338 2339 final public void AnnotationElementContent(ElementAnnotationBuilder eab) throws ParseException { 2340 ParsedElementAnnotation e; 2341 jj_consume_token(1); 2342 clearAttributeList(); 2343 label_23: 2344 while (true) { 2345 if (jj_2_8(2)) { 2346 ; 2347 } else { 2348 break label_23; 2349 } 2350 AnnotationAttribute(eab); 2351 } 2352 label_24: 2353 while (true) { 2354 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2355 case 5: 2356 case 6: 2357 case 7: 2358 case 10: 2359 case 13: 2360 case 14: 2361 case 15: 2362 case 16: 2363 case 17: 2364 case 18: 2365 case 19: 2366 case 26: 2367 case 27: 2368 case 31: 2369 case 32: 2370 case 33: 2371 case 34: 2372 case 35: 2373 case 36: 2374 case IDENTIFIER: 2375 case ESCAPED_IDENTIFIER: 2376 case PREFIXED_NAME: 2377 case LITERAL: 2378 ; 2379 break; 2380 default: 2381 jj_la1[63] = jj_gen; 2382 break label_24; 2383 } 2384 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2385 case LITERAL: 2386 AnnotationElementLiteral(eab); 2387 label_25: 2388 while (true) { 2389 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2390 case 8: 2391 ; 2392 break; 2393 default: 2394 jj_la1[64] = jj_gen; 2395 break label_25; 2396 } 2397 jj_consume_token(8); 2398 AnnotationElementLiteral(eab); 2399 } 2400 break; 2401 case 5: 2402 case 6: 2403 case 7: 2404 case 10: 2405 case 13: 2406 case 14: 2407 case 15: 2408 case 16: 2409 case 17: 2410 case 18: 2411 case 19: 2412 case 26: 2413 case 27: 2414 case 31: 2415 case 32: 2416 case 33: 2417 case 34: 2418 case 35: 2419 case 36: 2420 case IDENTIFIER: 2421 case ESCAPED_IDENTIFIER: 2422 case PREFIXED_NAME: 2423 e = AnnotationElement(true); 2424 eab.addElement(e); 2425 break; 2426 default: 2427 jj_la1[65] = jj_gen; 2428 jj_consume_token(-1); 2429 throw new ParseException(); 2430 } 2431 } 2432 eab.addComment(getComments()); 2433 jj_consume_token(9); 2434 } 2435 2436 final public void AnnotationElementLiteral(ElementAnnotationBuilder eab) throws ParseException { 2437 Token t; 2438 CommentList comments = getComments(); 2439 t = jj_consume_token(LITERAL); 2440 eab.addText(unquote(t.image), makeLocation(t), comments); 2441 } 2442 2443 final public String Literal() throws ParseException { 2444 Token t; 2445 String s; 2446 StringBuffer buf; 2447 t = jj_consume_token(LITERAL); 2448 s = unquote(t.image); 2449 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2450 case 8: 2451 buf = new StringBuffer(s); 2452 label_26: 2453 while (true) { 2454 jj_consume_token(8); 2455 t = jj_consume_token(LITERAL); 2456 buf.append(unquote(t.image)); 2457 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2458 case 8: 2459 ; 2460 break; 2461 default: 2462 jj_la1[66] = jj_gen; 2463 break label_26; 2464 } 2465 } 2466 s = buf.toString(); 2467 break; 2468 default: 2469 jj_la1[67] = jj_gen; 2470 ; 2471 } 2472 {if (true) return s;} 2473 throw new Error("Missing return statement in function"); 2474 } 2475 2476 final public LocatedString LocatedLiteral() throws ParseException { 2477 Token t; 2478 Token t2; 2479 String s; 2480 StringBuffer buf; 2481 t = jj_consume_token(LITERAL); 2482 s = unquote(t.image); 2483 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2484 case 8: 2485 buf = new StringBuffer(s); 2486 label_27: 2487 while (true) { 2488 jj_consume_token(8); 2489 t2 = jj_consume_token(LITERAL); 2490 buf.append(unquote(t2.image)); 2491 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2492 case 8: 2493 ; 2494 break; 2495 default: 2496 jj_la1[68] = jj_gen; 2497 break label_27; 2498 } 2499 } 2500 s = buf.toString(); 2501 break; 2502 default: 2503 jj_la1[69] = jj_gen; 2504 ; 2505 } 2506 {if (true) return new LocatedString(s, t);} 2507 throw new Error("Missing return statement in function"); 2508 } 2509 2510 final public Token Keyword() throws ParseException { 2511 Token t; 2512 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { 2513 case 26: 2514 t = jj_consume_token(26); 2515 break; 2516 case 27: 2517 t = jj_consume_token(27); 2518 break; 2519 case 13: 2520 t = jj_consume_token(13); 2521 break; 2522 case 31: 2523 t = jj_consume_token(31); 2524 break; 2525 case 32: 2526 t = jj_consume_token(32); 2527 break; 2528 case 10: 2529 t = jj_consume_token(10); 2530 break; 2531 case 17: 2532 t = jj_consume_token(17); 2533 break; 2534 case 18: 2535 t = jj_consume_token(18); 2536 break; 2537 case 34: 2538 t = jj_consume_token(34); 2539 break; 2540 case 33: 2541 t = jj_consume_token(33); 2542 break; 2543 case 19: 2544 t = jj_consume_token(19); 2545 break; 2546 case 5: 2547 t = jj_consume_token(5); 2548 break; 2549 case 7: 2550 t = jj_consume_token(7); 2551 break; 2552 case 14: 2553 t = jj_consume_token(14); 2554 break; 2555 case 15: 2556 t = jj_consume_token(15); 2557 break; 2558 case 35: 2559 t = jj_consume_token(35); 2560 break; 2561 case 36: 2562 t = jj_consume_token(36); 2563 break; 2564 case 16: 2565 t = jj_consume_token(16); 2566 break; 2567 case 6: 2568 t = jj_consume_token(6); 2569 break; 2570 default: 2571 jj_la1[70] = jj_gen; 2572 jj_consume_token(-1); 2573 throw new ParseException(); 2574 } 2575 {if (true) return t;} 2576 throw new Error("Missing return statement in function"); 2577 } 2578 2579 final private boolean jj_2_1(int xla) { 2580 jj_la = xla; jj_lastpos = jj_scanpos = token; 2581 boolean retval = !jj_3_1(); 2582 jj_save(0, xla); 2583 return retval; 2584 } 2585 2586 final private boolean jj_2_2(int xla) { 2587 jj_la = xla; jj_lastpos = jj_scanpos = token; 2588 boolean retval = !jj_3_2(); 2589 jj_save(1, xla); 2590 return retval; 2591 } 2592 2593 final private boolean jj_2_3(int xla) { 2594 jj_la = xla; jj_lastpos = jj_scanpos = token; 2595 boolean retval = !jj_3_3(); 2596 jj_save(2, xla); 2597 return retval; 2598 } 2599 2600 final private boolean jj_2_4(int xla) { 2601 jj_la = xla; jj_lastpos = jj_scanpos = token; 2602 boolean retval = !jj_3_4(); 2603 jj_save(3, xla); 2604 return retval; 2605 } 2606 2607 final private boolean jj_2_5(int xla) { 2608 jj_la = xla; jj_lastpos = jj_scanpos = token; 2609 boolean retval = !jj_3_5(); 2610 jj_save(4, xla); 2611 return retval; 2612 } 2613 2614 final private boolean jj_2_6(int xla) { 2615 jj_la = xla; jj_lastpos = jj_scanpos = token; 2616 boolean retval = !jj_3_6(); 2617 jj_save(5, xla); 2618 return retval; 2619 } 2620 2621 final private boolean jj_2_7(int xla) { 2622 jj_la = xla; jj_lastpos = jj_scanpos = token; 2623 boolean retval = !jj_3_7(); 2624 jj_save(6, xla); 2625 return retval; 2626 } 2627 2628 final private boolean jj_2_8(int xla) { 2629 jj_la = xla; jj_lastpos = jj_scanpos = token; 2630 boolean retval = !jj_3_8(); 2631 jj_save(7, xla); 2632 return retval; 2633 } 2634 2635 final private boolean jj_3R_92() { 2636 if (jj_scan_token(7)) return true; 2637 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2638 return false; 2639 } 2640 2641 final private boolean jj_3R_91() { 2642 if (jj_scan_token(5)) return true; 2643 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2644 return false; 2645 } 2646 2647 final private boolean jj_3R_90() { 2648 if (jj_scan_token(19)) return true; 2649 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2650 return false; 2651 } 2652 2653 final private boolean jj_3R_89() { 2654 if (jj_scan_token(33)) return true; 2655 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2656 return false; 2657 } 2658 2659 final private boolean jj_3R_88() { 2660 if (jj_scan_token(34)) return true; 2661 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2662 return false; 2663 } 2664 2665 final private boolean jj_3R_87() { 2666 if (jj_scan_token(18)) return true; 2667 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2668 return false; 2669 } 2670 2671 final private boolean jj_3R_86() { 2672 if (jj_scan_token(17)) return true; 2673 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2674 return false; 2675 } 2676 2677 final private boolean jj_3R_85() { 2678 if (jj_scan_token(10)) return true; 2679 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2680 return false; 2681 } 2682 2683 final private boolean jj_3R_84() { 2684 if (jj_scan_token(32)) return true; 2685 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2686 return false; 2687 } 2688 2689 final private boolean jj_3R_83() { 2690 if (jj_scan_token(31)) return true; 2691 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2692 return false; 2693 } 2694 2695 final private boolean jj_3R_82() { 2696 if (jj_scan_token(13)) return true; 2697 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2698 return false; 2699 } 2700 2701 final private boolean jj_3R_81() { 2702 if (jj_scan_token(27)) return true; 2703 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2704 return false; 2705 } 2706 2707 final private boolean jj_3R_80() { 2708 if (jj_scan_token(26)) return true; 2709 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2710 return false; 2711 } 2712 2713 final private boolean jj_3R_79() { 2714 Token xsp; 2715 xsp = jj_scanpos; 2716 if (jj_3R_80()) { 2717 jj_scanpos = xsp; 2718 if (jj_3R_81()) { 2719 jj_scanpos = xsp; 2720 if (jj_3R_82()) { 2721 jj_scanpos = xsp; 2722 if (jj_3R_83()) { 2723 jj_scanpos = xsp; 2724 if (jj_3R_84()) { 2725 jj_scanpos = xsp; 2726 if (jj_3R_85()) { 2727 jj_scanpos = xsp; 2728 if (jj_3R_86()) { 2729 jj_scanpos = xsp; 2730 if (jj_3R_87()) { 2731 jj_scanpos = xsp; 2732 if (jj_3R_88()) { 2733 jj_scanpos = xsp; 2734 if (jj_3R_89()) { 2735 jj_scanpos = xsp; 2736 if (jj_3R_90()) { 2737 jj_scanpos = xsp; 2738 if (jj_3R_91()) { 2739 jj_scanpos = xsp; 2740 if (jj_3R_92()) { 2741 jj_scanpos = xsp; 2742 if (jj_3R_93()) { 2743 jj_scanpos = xsp; 2744 if (jj_3R_94()) { 2745 jj_scanpos = xsp; 2746 if (jj_3R_95()) { 2747 jj_scanpos = xsp; 2748 if (jj_3R_96()) { 2749 jj_scanpos = xsp; 2750 if (jj_3R_97()) { 2751 jj_scanpos = xsp; 2752 if (jj_3R_98()) return true; 2753 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2754 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2755 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2756 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2757 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2758 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2759 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2760 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2761 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2762 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2763 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2764 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2765 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2766 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2767 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2768 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2769 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2770 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2771 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2772 return false; 2773 } 2774 2775 final private boolean jj_3R_30() { 2776 if (jj_scan_token(PREFIXED_NAME)) return true; 2777 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2778 if (jj_scan_token(2)) return true; 2779 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2780 return false; 2781 } 2782 2783 final private boolean jj_3R_39() { 2784 if (jj_3R_30()) return true; 2785 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2786 return false; 2787 } 2788 2789 final private boolean jj_3R_31() { 2790 Token xsp; 2791 xsp = jj_scanpos; 2792 if (jj_3R_39()) { 2793 jj_scanpos = xsp; 2794 if (jj_3R_40()) return true; 2795 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2796 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2797 return false; 2798 } 2799 2800 final private boolean jj_3_7() { 2801 if (jj_3R_30()) return true; 2802 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2803 return false; 2804 } 2805 2806 final private boolean jj_3R_70() { 2807 if (jj_3R_47()) return true; 2808 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2809 return false; 2810 } 2811 2812 final private boolean jj_3R_69() { 2813 if (jj_scan_token(8)) return true; 2814 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2815 return false; 2816 } 2817 2818 final private boolean jj_3R_76() { 2819 if (jj_scan_token(DOCUMENTATION_CONTINUE)) return true; 2820 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2821 return false; 2822 } 2823 2824 final private boolean jj_3_8() { 2825 if (jj_3R_31()) return true; 2826 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2827 return false; 2828 } 2829 2830 final private boolean jj_3R_68() { 2831 if (jj_scan_token(LITERAL)) return true; 2832 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2833 return false; 2834 } 2835 2836 final private boolean jj_3R_63() { 2837 if (jj_scan_token(1)) return true; 2838 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2839 return false; 2840 } 2841 2842 final private boolean jj_3R_67() { 2843 if (jj_scan_token(2)) return true; 2844 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2845 return false; 2846 } 2847 2848 final private boolean jj_3R_52() { 2849 if (jj_3R_41()) return true; 2850 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2851 if (jj_3R_63()) return true; 2852 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2853 return false; 2854 } 2855 2856 final private boolean jj_3_6() { 2857 if (jj_3R_29()) return true; 2858 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2859 return false; 2860 } 2861 2862 final private boolean jj_3_2() { 2863 if (jj_3R_28()) return true; 2864 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2865 return false; 2866 } 2867 2868 final private boolean jj_3R_66() { 2869 if (jj_3R_64()) return true; 2870 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2871 return false; 2872 } 2873 2874 final private boolean jj_3_5() { 2875 if (jj_3R_29()) return true; 2876 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2877 return false; 2878 } 2879 2880 final private boolean jj_3R_75() { 2881 if (jj_scan_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT)) return true; 2882 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2883 return false; 2884 } 2885 2886 final private boolean jj_3R_78() { 2887 if (jj_3R_79()) return true; 2888 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2889 return false; 2890 } 2891 2892 final private boolean jj_3R_73() { 2893 if (jj_scan_token(4)) return true; 2894 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2895 return false; 2896 } 2897 2898 final private boolean jj_3R_77() { 2899 if (jj_3R_41()) return true; 2900 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2901 return false; 2902 } 2903 2904 final private boolean jj_3R_45() { 2905 if (jj_scan_token(4)) return true; 2906 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2907 return false; 2908 } 2909 2910 final private boolean jj_3R_64() { 2911 Token xsp; 2912 xsp = jj_scanpos; 2913 if (jj_3R_77()) { 2914 jj_scanpos = xsp; 2915 if (jj_3R_78()) return true; 2916 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2917 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2918 return false; 2919 } 2920 2921 final private boolean jj_3R_58() { 2922 if (jj_scan_token(7)) return true; 2923 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2924 return false; 2925 } 2926 2927 final private boolean jj_3R_50() { 2928 if (jj_3R_47()) return true; 2929 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2930 return false; 2931 } 2932 2933 final private boolean jj_3R_59() { 2934 Token xsp; 2935 xsp = jj_scanpos; 2936 if (jj_3R_65()) { 2937 jj_scanpos = xsp; 2938 if (jj_3R_66()) { 2939 jj_scanpos = xsp; 2940 if (jj_3R_67()) { 2941 jj_scanpos = xsp; 2942 if (jj_3R_68()) { 2943 jj_scanpos = xsp; 2944 if (jj_3R_69()) { 2945 jj_scanpos = xsp; 2946 if (jj_3R_70()) return true; 2947 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2948 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2949 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2950 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2951 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2952 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2953 return false; 2954 } 2955 2956 final private boolean jj_3R_65() { 2957 if (jj_scan_token(PREFIXED_NAME)) return true; 2958 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2959 return false; 2960 } 2961 2962 final private boolean jj_3R_72() { 2963 if (jj_scan_token(3)) return true; 2964 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2965 return false; 2966 } 2967 2968 final private boolean jj_3R_47() { 2969 if (jj_scan_token(1)) return true; 2970 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2971 Token xsp; 2972 while (true) { 2973 xsp = jj_scanpos; 2974 if (jj_3R_59()) { jj_scanpos = xsp; break; } 2975 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2976 } 2977 if (jj_scan_token(9)) return true; 2978 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2979 return false; 2980 } 2981 2982 final private boolean jj_3R_44() { 2983 if (jj_scan_token(3)) return true; 2984 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2985 return false; 2986 } 2987 2988 final private boolean jj_3R_57() { 2989 if (jj_scan_token(6)) return true; 2990 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2991 return false; 2992 } 2993 2994 final private boolean jj_3R_74() { 2995 if (jj_scan_token(DOCUMENTATION)) return true; 2996 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 2997 return false; 2998 } 2999 3000 final private boolean jj_3R_62() { 3001 Token xsp; 3002 xsp = jj_scanpos; 3003 if (jj_3R_74()) { 3004 jj_scanpos = xsp; 3005 if (jj_3R_75()) return true; 3006 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3007 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3008 while (true) { 3009 xsp = jj_scanpos; 3010 if (jj_3R_76()) { jj_scanpos = xsp; break; } 3011 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3012 } 3013 return false; 3014 } 3015 3016 final private boolean jj_3R_71() { 3017 if (jj_scan_token(2)) return true; 3018 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3019 return false; 3020 } 3021 3022 final private boolean jj_3R_49() { 3023 Token xsp; 3024 if (jj_3R_62()) return true; 3025 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3026 while (true) { 3027 xsp = jj_scanpos; 3028 if (jj_3R_62()) { jj_scanpos = xsp; break; } 3029 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3030 } 3031 return false; 3032 } 3033 3034 final private boolean jj_3R_43() { 3035 if (jj_scan_token(2)) return true; 3036 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3037 return false; 3038 } 3039 3040 final private boolean jj_3R_46() { 3041 Token xsp; 3042 xsp = jj_scanpos; 3043 if (jj_3R_56()) { 3044 jj_scanpos = xsp; 3045 if (jj_3R_57()) { 3046 jj_scanpos = xsp; 3047 if (jj_3R_58()) return true; 3048 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3049 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3050 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3051 return false; 3052 } 3053 3054 final private boolean jj_3R_42() { 3055 if (jj_scan_token(1)) return true; 3056 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3057 return false; 3058 } 3059 3060 final private boolean jj_3R_56() { 3061 if (jj_scan_token(5)) return true; 3062 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3063 return false; 3064 } 3065 3066 final private boolean jj_3R_55() { 3067 if (jj_scan_token(ESCAPED_IDENTIFIER)) return true; 3068 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3069 return false; 3070 } 3071 3072 final private boolean jj_3R_54() { 3073 if (jj_scan_token(IDENTIFIER)) return true; 3074 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3075 return false; 3076 } 3077 3078 final private boolean jj_3R_61() { 3079 if (jj_3R_46()) return true; 3080 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3081 return false; 3082 } 3083 3084 final private boolean jj_3R_41() { 3085 Token xsp; 3086 xsp = jj_scanpos; 3087 if (jj_3R_54()) { 3088 jj_scanpos = xsp; 3089 if (jj_3R_55()) return true; 3090 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3091 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3092 return false; 3093 } 3094 3095 final private boolean jj_3R_51() { 3096 if (jj_scan_token(PREFIXED_NAME)) return true; 3097 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3098 if (jj_3R_63()) return true; 3099 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3100 return false; 3101 } 3102 3103 final private boolean jj_3R_48() { 3104 Token xsp; 3105 xsp = jj_scanpos; 3106 if (jj_3R_60()) { 3107 jj_scanpos = xsp; 3108 if (jj_3R_61()) return true; 3109 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3110 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3111 return false; 3112 } 3113 3114 final private boolean jj_3R_60() { 3115 if (jj_3R_41()) return true; 3116 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3117 Token xsp; 3118 xsp = jj_scanpos; 3119 if (jj_3R_71()) { 3120 jj_scanpos = xsp; 3121 if (jj_3R_72()) { 3122 jj_scanpos = xsp; 3123 if (jj_3R_73()) return true; 3124 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3125 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3126 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3127 return false; 3128 } 3129 3130 final private boolean jj_3R_36() { 3131 if (jj_3R_49()) return true; 3132 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3133 Token xsp; 3134 xsp = jj_scanpos; 3135 if (jj_3R_50()) jj_scanpos = xsp; 3136 else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3137 if (jj_3R_48()) return true; 3138 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3139 return false; 3140 } 3141 3142 final private boolean jj_3R_35() { 3143 if (jj_3R_47()) return true; 3144 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3145 if (jj_3R_48()) return true; 3146 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3147 return false; 3148 } 3149 3150 final private boolean jj_3R_34() { 3151 if (jj_3R_46()) return true; 3152 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3153 return false; 3154 } 3155 3156 final private boolean jj_3R_38() { 3157 if (jj_3R_52()) return true; 3158 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3159 return false; 3160 } 3161 3162 final private boolean jj_3_1() { 3163 if (jj_3R_28()) return true; 3164 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3165 return false; 3166 } 3167 3168 final private boolean jj_3R_33() { 3169 if (jj_3R_41()) return true; 3170 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3171 Token xsp; 3172 xsp = jj_scanpos; 3173 if (jj_3R_42()) { 3174 jj_scanpos = xsp; 3175 if (jj_3R_43()) { 3176 jj_scanpos = xsp; 3177 if (jj_3R_44()) { 3178 jj_scanpos = xsp; 3179 if (jj_3R_45()) return true; 3180 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3181 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3182 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3183 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3184 return false; 3185 } 3186 3187 final private boolean jj_3R_37() { 3188 if (jj_3R_51()) return true; 3189 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3190 return false; 3191 } 3192 3193 final private boolean jj_3R_28() { 3194 Token xsp; 3195 xsp = jj_scanpos; 3196 if (jj_3R_32()) { 3197 jj_scanpos = xsp; 3198 if (jj_3R_33()) { 3199 jj_scanpos = xsp; 3200 if (jj_3R_34()) { 3201 jj_scanpos = xsp; 3202 if (jj_3R_35()) { 3203 jj_scanpos = xsp; 3204 if (jj_3R_36()) return true; 3205 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3206 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3207 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3208 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3209 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3210 return false; 3211 } 3212 3213 final private boolean jj_3R_32() { 3214 if (jj_scan_token(PREFIXED_NAME)) return true; 3215 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3216 if (jj_scan_token(1)) return true; 3217 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3218 return false; 3219 } 3220 3221 final private boolean jj_3R_29() { 3222 Token xsp; 3223 xsp = jj_scanpos; 3224 if (jj_3R_37()) { 3225 jj_scanpos = xsp; 3226 if (jj_3R_38()) return true; 3227 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3228 } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3229 return false; 3230 } 3231 3232 final private boolean jj_3_4() { 3233 if (jj_3R_29()) return true; 3234 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3235 return false; 3236 } 3237 3238 final private boolean jj_3R_53() { 3239 if (jj_3R_64()) return true; 3240 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3241 if (jj_scan_token(2)) return true; 3242 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3243 return false; 3244 } 3245 3246 final private boolean jj_3R_40() { 3247 if (jj_3R_53()) return true; 3248 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3249 return false; 3250 } 3251 3252 final private boolean jj_3R_98() { 3253 if (jj_scan_token(6)) return true; 3254 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3255 return false; 3256 } 3257 3258 final private boolean jj_3_3() { 3259 if (jj_3R_29()) return true; 3260 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3261 return false; 3262 } 3263 3264 final private boolean jj_3R_97() { 3265 if (jj_scan_token(16)) return true; 3266 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3267 return false; 3268 } 3269 3270 final private boolean jj_3R_96() { 3271 if (jj_scan_token(36)) return true; 3272 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3273 return false; 3274 } 3275 3276 final private boolean jj_3R_95() { 3277 if (jj_scan_token(35)) return true; 3278 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3279 return false; 3280 } 3281 3282 final private boolean jj_3R_94() { 3283 if (jj_scan_token(15)) return true; 3284 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3285 return false; 3286 } 3287 3288 final private boolean jj_3R_93() { 3289 if (jj_scan_token(14)) return true; 3290 if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; 3291 return false; 3292 } 3293 3294 public CompactSyntaxTokenManager token_source; 3295 UCode_UCodeESC_CharStream jj_input_stream; 3296 public Token token, jj_nt; 3297 private int jj_ntk; 3298 private Token jj_scanpos, jj_lastpos; 3299 private int jj_la; 3300 public boolean lookingAhead = false; 3301 private boolean jj_semLA; 3302 private int jj_gen; 3303 final private int[] jj_la1 = new int[71]; 3304 final private int[] jj_la1_0 = {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,}; 3305 final private int[] jj_la1_1 = {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,}; 3306 final private JJCalls[] jj_2_rtns = new JJCalls[8]; 3307 private boolean jj_rescan = false; 3308 private int jj_gc = 0; 3309 3310 public CompactSyntax(java.io.InputStream stream) { 3311 jj_input_stream = new UCode_UCodeESC_CharStream(stream, 1, 1); 3312 token_source = new CompactSyntaxTokenManager(jj_input_stream); 3313 token = new Token(); 3314 jj_ntk = -1; 3315 jj_gen = 0; 3316 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3317 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3318 } 3319 3320 public void ReInit(java.io.InputStream stream) { 3321 jj_input_stream.ReInit(stream, 1, 1); 3322 token_source.ReInit(jj_input_stream); 3323 token = new Token(); 3324 jj_ntk = -1; 3325 jj_gen = 0; 3326 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3327 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3328 } 3329 3330 public CompactSyntax(java.io.Reader stream) { 3331 jj_input_stream = new UCode_UCodeESC_CharStream(stream, 1, 1); 3332 token_source = new CompactSyntaxTokenManager(jj_input_stream); 3333 token = new Token(); 3334 jj_ntk = -1; 3335 jj_gen = 0; 3336 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3337 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3338 } 3339 3340 public void ReInit(java.io.Reader stream) { 3341 jj_input_stream.ReInit(stream, 1, 1); 3342 token_source.ReInit(jj_input_stream); 3343 token = new Token(); 3344 jj_ntk = -1; 3345 jj_gen = 0; 3346 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3347 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3348 } 3349 3350 public CompactSyntax(CompactSyntaxTokenManager tm) { 3351 token_source = tm; 3352 token = new Token(); 3353 jj_ntk = -1; 3354 jj_gen = 0; 3355 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3356 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3357 } 3358 3359 public void ReInit(CompactSyntaxTokenManager tm) { 3360 token_source = tm; 3361 token = new Token(); 3362 jj_ntk = -1; 3363 jj_gen = 0; 3364 for (int i = 0; i < 71; i++) jj_la1[i] = -1; 3365 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); 3366 } 3367 3368 final private Token jj_consume_token(int kind) throws ParseException { 3369 Token oldToken; 3370 if ((oldToken = token).next != null) token = token.next; 3371 else token = token.next = token_source.getNextToken(); 3372 jj_ntk = -1; 3373 if (token.kind == kind) { 3374 jj_gen++; 3375 if (++jj_gc > 100) { 3376 jj_gc = 0; 3377 for (int i = 0; i < jj_2_rtns.length; i++) { 3378 JJCalls c = jj_2_rtns[i]; 3379 while (c != null) { 3380 if (c.gen < jj_gen) c.first = null; 3381 c = c.next; 3382 } 3383 } 3384 } 3385 return token; 3386 } 3387 token = oldToken; 3388 jj_kind = kind; 3389 throw generateParseException(); 3390 } 3391 3392 final private boolean jj_scan_token(int kind) { 3393 if (jj_scanpos == jj_lastpos) { 3394 jj_la--; 3395 if (jj_scanpos.next == null) { 3396 jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); 3397 } else { 3398 jj_lastpos = jj_scanpos = jj_scanpos.next; 3399 } 3400 } else { 3401 jj_scanpos = jj_scanpos.next; 3402 } 3403 if (jj_rescan) { 3404 int i = 0; Token tok = token; 3405 while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } 3406 if (tok != null) jj_add_error_token(kind, i); 3407 } 3408 return (jj_scanpos.kind != kind); 3409 } 3410 3411 final public Token getNextToken() { 3412 if (token.next != null) token = token.next; 3413 else token = token.next = token_source.getNextToken(); 3414 jj_ntk = -1; 3415 jj_gen++; 3416 return token; 3417 } 3418 3419 final public Token getToken(int index) { 3420 Token t = lookingAhead ? jj_scanpos : token; 3421 for (int i = 0; i < index; i++) { 3422 if (t.next != null) t = t.next; 3423 else t = t.next = token_source.getNextToken(); 3424 } 3425 return t; 3426 } 3427 3428 final private int jj_ntk() { 3429 if ((jj_nt=token.next) == null) 3430 return (jj_ntk = (token.next=token_source.getNextToken()).kind); 3431 else 3432 return (jj_ntk = jj_nt.kind); 3433 } 3434 3435 private java.util.Vector jj_expentries = new java.util.Vector(); 3436 private int[] jj_expentry; 3437 private int jj_kind = -1; 3438 private int[] jj_lasttokens = new int[100]; 3439 private int jj_endpos; 3440 3441 private void jj_add_error_token(int kind, int pos) { 3442 if (pos >= 100) return; 3443 if (pos == jj_endpos + 1) { 3444 jj_lasttokens[jj_endpos++] = kind; 3445 } else if (jj_endpos != 0) { 3446 jj_expentry = new int[jj_endpos]; 3447 for (int i = 0; i < jj_endpos; i++) { 3448 jj_expentry[i] = jj_lasttokens[i]; 3449 } 3450 boolean exists = false; 3451 for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) { 3452 int[] oldentry = (int[])(enum.nextElement()); 3453 if (oldentry.length == jj_expentry.length) { 3454 exists = true; 3455 for (int i = 0; i < jj_expentry.length; i++) { 3456 if (oldentry[i] != jj_expentry[i]) { 3457 exists = false; 3458 break; 3459 } 3460 } 3461 if (exists) break; 3462 } 3463 } 3464 if (!exists) jj_expentries.addElement(jj_expentry); 3465 if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; 3466 } 3467 } 3468 3469 final public ParseException generateParseException() { 3470 jj_expentries.removeAllElements(); 3471 boolean[] la1tokens = new boolean[61]; 3472 for (int i = 0; i < 61; i++) { 3473 la1tokens[i] = false; 3474 } 3475 if (jj_kind >= 0) { 3476 la1tokens[jj_kind] = true; 3477 jj_kind = -1; 3478 } 3479 for (int i = 0; i < 71; i++) { 3480 if (jj_la1[i] == jj_gen) { 3481 for (int j = 0; j < 32; j++) { 3482 if ((jj_la1_0[i] & (1<<j)) != 0) { 3483 la1tokens[j] = true; 3484 } 3485 if ((jj_la1_1[i] & (1<<j)) != 0) { 3486 la1tokens[32+j] = true; 3487 } 3488 } 3489 } 3490 } 3491 for (int i = 0; i < 61; i++) { 3492 if (la1tokens[i]) { 3493 jj_expentry = new int[1]; 3494 jj_expentry[0] = i; 3495 jj_expentries.addElement(jj_expentry); 3496 } 3497 } 3498 jj_endpos = 0; 3499 jj_rescan_token(); 3500 jj_add_error_token(0, 0); 3501 int[][] exptokseq = new int[jj_expentries.size()][]; 3502 for (int i = 0; i < jj_expentries.size(); i++) { 3503 exptokseq[i] = (int[])jj_expentries.elementAt(i); 3504 } 3505 return new ParseException(token, exptokseq, tokenImage); 3506 } 3507 3508 final public void enable_tracing() { 3509 } 3510 3511 final public void disable_tracing() { 3512 } 3513 3514 final private void jj_rescan_token() { 3515 jj_rescan = true; 3516 for (int i = 0; i < 8; i++) { 3517 JJCalls p = jj_2_rtns[i]; 3518 do { 3519 if (p.gen > jj_gen) { 3520 jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; 3521 switch (i) { 3522 case 0: jj_3_1(); break; 3523 case 1: jj_3_2(); break; 3524 case 2: jj_3_3(); break; 3525 case 3: jj_3_4(); break; 3526 case 4: jj_3_5(); break; 3527 case 5: jj_3_6(); break; 3528 case 6: jj_3_7(); break; 3529 case 7: jj_3_8(); break; 3530 } 3531 } 3532 p = p.next; 3533 } while (p != null); 3534 } 3535 jj_rescan = false; 3536 } 3537 3538 final private void jj_save(int index, int xla) { 3539 JJCalls p = jj_2_rtns[index]; 3540 while (p.gen > jj_gen) { 3541 if (p.next == null) { p = p.next = new JJCalls(); break; } 3542 p = p.next; 3543 } 3544 p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; 3545 } 3546 3547 static final class JJCalls { 3548 int gen; 3549 Token first; 3550 int arg; 3551 JJCalls next; 3552 } 3553 3554} 3555 | Popular Tags |