1 23 24 package net.percederberg.grammatica.test; 25 26 import net.percederberg.grammatica.parser.Analyzer; 27 import net.percederberg.grammatica.parser.Node; 28 import net.percederberg.grammatica.parser.ParseException; 29 import net.percederberg.grammatica.parser.Production; 30 import net.percederberg.grammatica.parser.Token; 31 32 38 abstract class RegexpAnalyzer extends Analyzer { 39 40 47 protected void enter(Node node) throws ParseException { 48 switch (node.getId()) { 49 case RegexpConstants.LEFT_PAREN: 50 enterLeftParen((Token) node); 51 break; 52 case RegexpConstants.RIGHT_PAREN: 53 enterRightParen((Token) node); 54 break; 55 case RegexpConstants.LEFT_BRACKET: 56 enterLeftBracket((Token) node); 57 break; 58 case RegexpConstants.RIGHT_BRACKET: 59 enterRightBracket((Token) node); 60 break; 61 case RegexpConstants.LEFT_BRACE: 62 enterLeftBrace((Token) node); 63 break; 64 case RegexpConstants.RIGHT_BRACE: 65 enterRightBrace((Token) node); 66 break; 67 case RegexpConstants.QUESTION: 68 enterQuestion((Token) node); 69 break; 70 case RegexpConstants.ASTERISK: 71 enterAsterisk((Token) node); 72 break; 73 case RegexpConstants.PLUS: 74 enterPlus((Token) node); 75 break; 76 case RegexpConstants.VERTICAL_BAR: 77 enterVerticalBar((Token) node); 78 break; 79 case RegexpConstants.DOT: 80 enterDot((Token) node); 81 break; 82 case RegexpConstants.COMMA: 83 enterComma((Token) node); 84 break; 85 case RegexpConstants.NUMBER: 86 enterNumber((Token) node); 87 break; 88 case RegexpConstants.CHAR: 89 enterChar((Token) node); 90 break; 91 case RegexpConstants.EXPR: 92 enterExpr((Production) node); 93 break; 94 case RegexpConstants.TERM: 95 enterTerm((Production) node); 96 break; 97 case RegexpConstants.FACT: 98 enterFact((Production) node); 99 break; 100 case RegexpConstants.ATOM: 101 enterAtom((Production) node); 102 break; 103 case RegexpConstants.ATOM_MODIFIER: 104 enterAtomModifier((Production) node); 105 break; 106 case RegexpConstants.CHARACTER_SET: 107 enterCharacterSet((Production) node); 108 break; 109 case RegexpConstants.CHARACTER: 110 enterCharacter((Production) node); 111 break; 112 } 113 } 114 115 125 protected Node exit(Node node) throws ParseException { 126 switch (node.getId()) { 127 case RegexpConstants.LEFT_PAREN: 128 return exitLeftParen((Token) node); 129 case RegexpConstants.RIGHT_PAREN: 130 return exitRightParen((Token) node); 131 case RegexpConstants.LEFT_BRACKET: 132 return exitLeftBracket((Token) node); 133 case RegexpConstants.RIGHT_BRACKET: 134 return exitRightBracket((Token) node); 135 case RegexpConstants.LEFT_BRACE: 136 return exitLeftBrace((Token) node); 137 case RegexpConstants.RIGHT_BRACE: 138 return exitRightBrace((Token) node); 139 case RegexpConstants.QUESTION: 140 return exitQuestion((Token) node); 141 case RegexpConstants.ASTERISK: 142 return exitAsterisk((Token) node); 143 case RegexpConstants.PLUS: 144 return exitPlus((Token) node); 145 case RegexpConstants.VERTICAL_BAR: 146 return exitVerticalBar((Token) node); 147 case RegexpConstants.DOT: 148 return exitDot((Token) node); 149 case RegexpConstants.COMMA: 150 return exitComma((Token) node); 151 case RegexpConstants.NUMBER: 152 return exitNumber((Token) node); 153 case RegexpConstants.CHAR: 154 return exitChar((Token) node); 155 case RegexpConstants.EXPR: 156 return exitExpr((Production) node); 157 case RegexpConstants.TERM: 158 return exitTerm((Production) node); 159 case RegexpConstants.FACT: 160 return exitFact((Production) node); 161 case RegexpConstants.ATOM: 162 return exitAtom((Production) node); 163 case RegexpConstants.ATOM_MODIFIER: 164 return exitAtomModifier((Production) node); 165 case RegexpConstants.CHARACTER_SET: 166 return exitCharacterSet((Production) node); 167 case RegexpConstants.CHARACTER: 168 return exitCharacter((Production) node); 169 } 170 return node; 171 } 172 173 181 protected void child(Production node, Node child) 182 throws ParseException { 183 184 switch (node.getId()) { 185 case RegexpConstants.EXPR: 186 childExpr(node, child); 187 break; 188 case RegexpConstants.TERM: 189 childTerm(node, child); 190 break; 191 case RegexpConstants.FACT: 192 childFact(node, child); 193 break; 194 case RegexpConstants.ATOM: 195 childAtom(node, child); 196 break; 197 case RegexpConstants.ATOM_MODIFIER: 198 childAtomModifier(node, child); 199 break; 200 case RegexpConstants.CHARACTER_SET: 201 childCharacterSet(node, child); 202 break; 203 case RegexpConstants.CHARACTER: 204 childCharacter(node, child); 205 break; 206 } 207 } 208 209 216 protected void enterLeftParen(Token node) throws ParseException { 217 } 218 219 229 protected Node exitLeftParen(Token node) throws ParseException { 230 return node; 231 } 232 233 240 protected void enterRightParen(Token node) throws ParseException { 241 } 242 243 253 protected Node exitRightParen(Token node) throws ParseException { 254 return node; 255 } 256 257 264 protected void enterLeftBracket(Token node) throws ParseException { 265 } 266 267 277 protected Node exitLeftBracket(Token node) throws ParseException { 278 return node; 279 } 280 281 288 protected void enterRightBracket(Token node) throws ParseException { 289 } 290 291 301 protected Node exitRightBracket(Token node) throws ParseException { 302 return node; 303 } 304 305 312 protected void enterLeftBrace(Token node) throws ParseException { 313 } 314 315 325 protected Node exitLeftBrace(Token node) throws ParseException { 326 return node; 327 } 328 329 336 protected void enterRightBrace(Token node) throws ParseException { 337 } 338 339 349 protected Node exitRightBrace(Token node) throws ParseException { 350 return node; 351 } 352 353 360 protected void enterQuestion(Token node) throws ParseException { 361 } 362 363 373 protected Node exitQuestion(Token node) throws ParseException { 374 return node; 375 } 376 377 384 protected void enterAsterisk(Token node) throws ParseException { 385 } 386 387 397 protected Node exitAsterisk(Token node) throws ParseException { 398 return node; 399 } 400 401 408 protected void enterPlus(Token node) throws ParseException { 409 } 410 411 421 protected Node exitPlus(Token node) throws ParseException { 422 return node; 423 } 424 425 432 protected void enterVerticalBar(Token node) throws ParseException { 433 } 434 435 445 protected Node exitVerticalBar(Token node) throws ParseException { 446 return node; 447 } 448 449 456 protected void enterDot(Token node) throws ParseException { 457 } 458 459 469 protected Node exitDot(Token node) throws ParseException { 470 return node; 471 } 472 473 480 protected void enterComma(Token node) throws ParseException { 481 } 482 483 493 protected Node exitComma(Token node) throws ParseException { 494 return node; 495 } 496 497 504 protected void enterNumber(Token node) throws ParseException { 505 } 506 507 517 protected Node exitNumber(Token node) throws ParseException { 518 return node; 519 } 520 521 528 protected void enterChar(Token node) throws ParseException { 529 } 530 531 541 protected Node exitChar(Token node) throws ParseException { 542 return node; 543 } 544 545 552 protected void enterExpr(Production node) throws ParseException { 553 } 554 555 565 protected Node exitExpr(Production node) throws ParseException { 566 return node; 567 } 568 569 577 protected void childExpr(Production node, Node child) 578 throws ParseException { 579 580 node.addChild(child); 581 } 582 583 590 protected void enterTerm(Production node) throws ParseException { 591 } 592 593 603 protected Node exitTerm(Production node) throws ParseException { 604 return node; 605 } 606 607 615 protected void childTerm(Production node, Node child) 616 throws ParseException { 617 618 node.addChild(child); 619 } 620 621 628 protected void enterFact(Production node) throws ParseException { 629 } 630 631 641 protected Node exitFact(Production node) throws ParseException { 642 return node; 643 } 644 645 653 protected void childFact(Production node, Node child) 654 throws ParseException { 655 656 node.addChild(child); 657 } 658 659 666 protected void enterAtom(Production node) throws ParseException { 667 } 668 669 679 protected Node exitAtom(Production node) throws ParseException { 680 return node; 681 } 682 683 691 protected void childAtom(Production node, Node child) 692 throws ParseException { 693 694 node.addChild(child); 695 } 696 697 704 protected void enterAtomModifier(Production node) 705 throws ParseException { 706 } 707 708 718 protected Node exitAtomModifier(Production node) 719 throws ParseException { 720 721 return node; 722 } 723 724 732 protected void childAtomModifier(Production node, Node child) 733 throws ParseException { 734 735 node.addChild(child); 736 } 737 738 745 protected void enterCharacterSet(Production node) 746 throws ParseException { 747 } 748 749 759 protected Node exitCharacterSet(Production node) 760 throws ParseException { 761 762 return node; 763 } 764 765 773 protected void childCharacterSet(Production node, Node child) 774 throws ParseException { 775 776 node.addChild(child); 777 } 778 779 786 protected void enterCharacter(Production node) 787 throws ParseException { 788 } 789 790 800 protected Node exitCharacter(Production node) 801 throws ParseException { 802 803 return node; 804 } 805 806 814 protected void childCharacter(Production node, Node child) 815 throws ParseException { 816 817 node.addChild(child); 818 } 819 } 820 | Popular Tags |