001: /*
002: * RegexpAnalyzer.java
003: *
004: * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT!
005: *
006: * This work is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published
008: * by the Free Software Foundation; either version 2 of the License,
009: * or (at your option) any later version.
010: *
011: * This work is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * As a special exception, the copyright holders of this library give
022: * you permission to link this library with independent modules to
023: * produce an executable, regardless of the license terms of these
024: * independent modules, and to copy and distribute the resulting
025: * executable under terms of your choice, provided that you also meet,
026: * for each linked independent module, the terms and conditions of the
027: * license of that module. An independent module is a module which is
028: * not derived from or based on this library. If you modify this
029: * library, you may extend this exception to your version of the
030: * library, but you are not obligated to do so. If you do not wish to
031: * do so, delete this exception statement from your version.
032: *
033: * Copyright (c) 2003 Per Cederberg. All rights reserved.
034: */
035:
036: package net.percederberg.grammatica.test;
037:
038: import net.percederberg.grammatica.parser.Analyzer;
039: import net.percederberg.grammatica.parser.Node;
040: import net.percederberg.grammatica.parser.ParseException;
041: import net.percederberg.grammatica.parser.Production;
042: import net.percederberg.grammatica.parser.Token;
043:
044: /**
045: * A class providing callback methods for the parser.
046: *
047: * @author Per Cederberg, <per at percederberg dot net>
048: * @version 1.0
049: */
050: abstract class RegexpAnalyzer extends Analyzer {
051:
052: /**
053: * Called when entering a parse tree node.
054: *
055: * @param node the node being entered
056: *
057: * @throws ParseException if the node analysis discovered errors
058: */
059: protected void enter(Node node) throws ParseException {
060: switch (node.getId()) {
061: case RegexpConstants.LEFT_PAREN:
062: enterLeftParen((Token) node);
063: break;
064: case RegexpConstants.RIGHT_PAREN:
065: enterRightParen((Token) node);
066: break;
067: case RegexpConstants.LEFT_BRACKET:
068: enterLeftBracket((Token) node);
069: break;
070: case RegexpConstants.RIGHT_BRACKET:
071: enterRightBracket((Token) node);
072: break;
073: case RegexpConstants.LEFT_BRACE:
074: enterLeftBrace((Token) node);
075: break;
076: case RegexpConstants.RIGHT_BRACE:
077: enterRightBrace((Token) node);
078: break;
079: case RegexpConstants.QUESTION:
080: enterQuestion((Token) node);
081: break;
082: case RegexpConstants.ASTERISK:
083: enterAsterisk((Token) node);
084: break;
085: case RegexpConstants.PLUS:
086: enterPlus((Token) node);
087: break;
088: case RegexpConstants.VERTICAL_BAR:
089: enterVerticalBar((Token) node);
090: break;
091: case RegexpConstants.DOT:
092: enterDot((Token) node);
093: break;
094: case RegexpConstants.COMMA:
095: enterComma((Token) node);
096: break;
097: case RegexpConstants.NUMBER:
098: enterNumber((Token) node);
099: break;
100: case RegexpConstants.CHAR:
101: enterChar((Token) node);
102: break;
103: case RegexpConstants.EXPR:
104: enterExpr((Production) node);
105: break;
106: case RegexpConstants.TERM:
107: enterTerm((Production) node);
108: break;
109: case RegexpConstants.FACT:
110: enterFact((Production) node);
111: break;
112: case RegexpConstants.ATOM:
113: enterAtom((Production) node);
114: break;
115: case RegexpConstants.ATOM_MODIFIER:
116: enterAtomModifier((Production) node);
117: break;
118: case RegexpConstants.CHARACTER_SET:
119: enterCharacterSet((Production) node);
120: break;
121: case RegexpConstants.CHARACTER:
122: enterCharacter((Production) node);
123: break;
124: }
125: }
126:
127: /**
128: * Called when exiting a parse tree node.
129: *
130: * @param node the node being exited
131: *
132: * @return the node to add to the parse tree, or
133: * null if no parse tree should be created
134: *
135: * @throws ParseException if the node analysis discovered errors
136: */
137: protected Node exit(Node node) throws ParseException {
138: switch (node.getId()) {
139: case RegexpConstants.LEFT_PAREN:
140: return exitLeftParen((Token) node);
141: case RegexpConstants.RIGHT_PAREN:
142: return exitRightParen((Token) node);
143: case RegexpConstants.LEFT_BRACKET:
144: return exitLeftBracket((Token) node);
145: case RegexpConstants.RIGHT_BRACKET:
146: return exitRightBracket((Token) node);
147: case RegexpConstants.LEFT_BRACE:
148: return exitLeftBrace((Token) node);
149: case RegexpConstants.RIGHT_BRACE:
150: return exitRightBrace((Token) node);
151: case RegexpConstants.QUESTION:
152: return exitQuestion((Token) node);
153: case RegexpConstants.ASTERISK:
154: return exitAsterisk((Token) node);
155: case RegexpConstants.PLUS:
156: return exitPlus((Token) node);
157: case RegexpConstants.VERTICAL_BAR:
158: return exitVerticalBar((Token) node);
159: case RegexpConstants.DOT:
160: return exitDot((Token) node);
161: case RegexpConstants.COMMA:
162: return exitComma((Token) node);
163: case RegexpConstants.NUMBER:
164: return exitNumber((Token) node);
165: case RegexpConstants.CHAR:
166: return exitChar((Token) node);
167: case RegexpConstants.EXPR:
168: return exitExpr((Production) node);
169: case RegexpConstants.TERM:
170: return exitTerm((Production) node);
171: case RegexpConstants.FACT:
172: return exitFact((Production) node);
173: case RegexpConstants.ATOM:
174: return exitAtom((Production) node);
175: case RegexpConstants.ATOM_MODIFIER:
176: return exitAtomModifier((Production) node);
177: case RegexpConstants.CHARACTER_SET:
178: return exitCharacterSet((Production) node);
179: case RegexpConstants.CHARACTER:
180: return exitCharacter((Production) node);
181: }
182: return node;
183: }
184:
185: /**
186: * Called when adding a child to a parse tree node.
187: *
188: * @param node the parent node
189: * @param child the child node, or null
190: *
191: * @throws ParseException if the node analysis discovered errors
192: */
193: protected void child(Production node, Node child)
194: throws ParseException {
195:
196: switch (node.getId()) {
197: case RegexpConstants.EXPR:
198: childExpr(node, child);
199: break;
200: case RegexpConstants.TERM:
201: childTerm(node, child);
202: break;
203: case RegexpConstants.FACT:
204: childFact(node, child);
205: break;
206: case RegexpConstants.ATOM:
207: childAtom(node, child);
208: break;
209: case RegexpConstants.ATOM_MODIFIER:
210: childAtomModifier(node, child);
211: break;
212: case RegexpConstants.CHARACTER_SET:
213: childCharacterSet(node, child);
214: break;
215: case RegexpConstants.CHARACTER:
216: childCharacter(node, child);
217: break;
218: }
219: }
220:
221: /**
222: * Called when entering a parse tree node.
223: *
224: * @param node the node being entered
225: *
226: * @throws ParseException if the node analysis discovered errors
227: */
228: protected void enterLeftParen(Token node) throws ParseException {
229: }
230:
231: /**
232: * Called when exiting a parse tree node.
233: *
234: * @param node the node being exited
235: *
236: * @return the node to add to the parse tree, or
237: * null if no parse tree should be created
238: *
239: * @throws ParseException if the node analysis discovered errors
240: */
241: protected Node exitLeftParen(Token node) throws ParseException {
242: return node;
243: }
244:
245: /**
246: * Called when entering a parse tree node.
247: *
248: * @param node the node being entered
249: *
250: * @throws ParseException if the node analysis discovered errors
251: */
252: protected void enterRightParen(Token node) throws ParseException {
253: }
254:
255: /**
256: * Called when exiting a parse tree node.
257: *
258: * @param node the node being exited
259: *
260: * @return the node to add to the parse tree, or
261: * null if no parse tree should be created
262: *
263: * @throws ParseException if the node analysis discovered errors
264: */
265: protected Node exitRightParen(Token node) throws ParseException {
266: return node;
267: }
268:
269: /**
270: * Called when entering a parse tree node.
271: *
272: * @param node the node being entered
273: *
274: * @throws ParseException if the node analysis discovered errors
275: */
276: protected void enterLeftBracket(Token node) throws ParseException {
277: }
278:
279: /**
280: * Called when exiting a parse tree node.
281: *
282: * @param node the node being exited
283: *
284: * @return the node to add to the parse tree, or
285: * null if no parse tree should be created
286: *
287: * @throws ParseException if the node analysis discovered errors
288: */
289: protected Node exitLeftBracket(Token node) throws ParseException {
290: return node;
291: }
292:
293: /**
294: * Called when entering a parse tree node.
295: *
296: * @param node the node being entered
297: *
298: * @throws ParseException if the node analysis discovered errors
299: */
300: protected void enterRightBracket(Token node) throws ParseException {
301: }
302:
303: /**
304: * Called when exiting a parse tree node.
305: *
306: * @param node the node being exited
307: *
308: * @return the node to add to the parse tree, or
309: * null if no parse tree should be created
310: *
311: * @throws ParseException if the node analysis discovered errors
312: */
313: protected Node exitRightBracket(Token node) throws ParseException {
314: return node;
315: }
316:
317: /**
318: * Called when entering a parse tree node.
319: *
320: * @param node the node being entered
321: *
322: * @throws ParseException if the node analysis discovered errors
323: */
324: protected void enterLeftBrace(Token node) throws ParseException {
325: }
326:
327: /**
328: * Called when exiting a parse tree node.
329: *
330: * @param node the node being exited
331: *
332: * @return the node to add to the parse tree, or
333: * null if no parse tree should be created
334: *
335: * @throws ParseException if the node analysis discovered errors
336: */
337: protected Node exitLeftBrace(Token node) throws ParseException {
338: return node;
339: }
340:
341: /**
342: * Called when entering a parse tree node.
343: *
344: * @param node the node being entered
345: *
346: * @throws ParseException if the node analysis discovered errors
347: */
348: protected void enterRightBrace(Token node) throws ParseException {
349: }
350:
351: /**
352: * Called when exiting a parse tree node.
353: *
354: * @param node the node being exited
355: *
356: * @return the node to add to the parse tree, or
357: * null if no parse tree should be created
358: *
359: * @throws ParseException if the node analysis discovered errors
360: */
361: protected Node exitRightBrace(Token node) throws ParseException {
362: return node;
363: }
364:
365: /**
366: * Called when entering a parse tree node.
367: *
368: * @param node the node being entered
369: *
370: * @throws ParseException if the node analysis discovered errors
371: */
372: protected void enterQuestion(Token node) throws ParseException {
373: }
374:
375: /**
376: * Called when exiting a parse tree node.
377: *
378: * @param node the node being exited
379: *
380: * @return the node to add to the parse tree, or
381: * null if no parse tree should be created
382: *
383: * @throws ParseException if the node analysis discovered errors
384: */
385: protected Node exitQuestion(Token node) throws ParseException {
386: return node;
387: }
388:
389: /**
390: * Called when entering a parse tree node.
391: *
392: * @param node the node being entered
393: *
394: * @throws ParseException if the node analysis discovered errors
395: */
396: protected void enterAsterisk(Token node) throws ParseException {
397: }
398:
399: /**
400: * Called when exiting a parse tree node.
401: *
402: * @param node the node being exited
403: *
404: * @return the node to add to the parse tree, or
405: * null if no parse tree should be created
406: *
407: * @throws ParseException if the node analysis discovered errors
408: */
409: protected Node exitAsterisk(Token node) throws ParseException {
410: return node;
411: }
412:
413: /**
414: * Called when entering a parse tree node.
415: *
416: * @param node the node being entered
417: *
418: * @throws ParseException if the node analysis discovered errors
419: */
420: protected void enterPlus(Token node) throws ParseException {
421: }
422:
423: /**
424: * Called when exiting a parse tree node.
425: *
426: * @param node the node being exited
427: *
428: * @return the node to add to the parse tree, or
429: * null if no parse tree should be created
430: *
431: * @throws ParseException if the node analysis discovered errors
432: */
433: protected Node exitPlus(Token node) throws ParseException {
434: return node;
435: }
436:
437: /**
438: * Called when entering a parse tree node.
439: *
440: * @param node the node being entered
441: *
442: * @throws ParseException if the node analysis discovered errors
443: */
444: protected void enterVerticalBar(Token node) throws ParseException {
445: }
446:
447: /**
448: * Called when exiting a parse tree node.
449: *
450: * @param node the node being exited
451: *
452: * @return the node to add to the parse tree, or
453: * null if no parse tree should be created
454: *
455: * @throws ParseException if the node analysis discovered errors
456: */
457: protected Node exitVerticalBar(Token node) throws ParseException {
458: return node;
459: }
460:
461: /**
462: * Called when entering a parse tree node.
463: *
464: * @param node the node being entered
465: *
466: * @throws ParseException if the node analysis discovered errors
467: */
468: protected void enterDot(Token node) throws ParseException {
469: }
470:
471: /**
472: * Called when exiting a parse tree node.
473: *
474: * @param node the node being exited
475: *
476: * @return the node to add to the parse tree, or
477: * null if no parse tree should be created
478: *
479: * @throws ParseException if the node analysis discovered errors
480: */
481: protected Node exitDot(Token node) throws ParseException {
482: return node;
483: }
484:
485: /**
486: * Called when entering a parse tree node.
487: *
488: * @param node the node being entered
489: *
490: * @throws ParseException if the node analysis discovered errors
491: */
492: protected void enterComma(Token node) throws ParseException {
493: }
494:
495: /**
496: * Called when exiting a parse tree node.
497: *
498: * @param node the node being exited
499: *
500: * @return the node to add to the parse tree, or
501: * null if no parse tree should be created
502: *
503: * @throws ParseException if the node analysis discovered errors
504: */
505: protected Node exitComma(Token node) throws ParseException {
506: return node;
507: }
508:
509: /**
510: * Called when entering a parse tree node.
511: *
512: * @param node the node being entered
513: *
514: * @throws ParseException if the node analysis discovered errors
515: */
516: protected void enterNumber(Token node) throws ParseException {
517: }
518:
519: /**
520: * Called when exiting a parse tree node.
521: *
522: * @param node the node being exited
523: *
524: * @return the node to add to the parse tree, or
525: * null if no parse tree should be created
526: *
527: * @throws ParseException if the node analysis discovered errors
528: */
529: protected Node exitNumber(Token node) throws ParseException {
530: return node;
531: }
532:
533: /**
534: * Called when entering a parse tree node.
535: *
536: * @param node the node being entered
537: *
538: * @throws ParseException if the node analysis discovered errors
539: */
540: protected void enterChar(Token node) throws ParseException {
541: }
542:
543: /**
544: * Called when exiting a parse tree node.
545: *
546: * @param node the node being exited
547: *
548: * @return the node to add to the parse tree, or
549: * null if no parse tree should be created
550: *
551: * @throws ParseException if the node analysis discovered errors
552: */
553: protected Node exitChar(Token node) throws ParseException {
554: return node;
555: }
556:
557: /**
558: * Called when entering a parse tree node.
559: *
560: * @param node the node being entered
561: *
562: * @throws ParseException if the node analysis discovered errors
563: */
564: protected void enterExpr(Production node) throws ParseException {
565: }
566:
567: /**
568: * Called when exiting a parse tree node.
569: *
570: * @param node the node being exited
571: *
572: * @return the node to add to the parse tree, or
573: * null if no parse tree should be created
574: *
575: * @throws ParseException if the node analysis discovered errors
576: */
577: protected Node exitExpr(Production node) throws ParseException {
578: return node;
579: }
580:
581: /**
582: * Called when adding a child to a parse tree node.
583: *
584: * @param node the parent node
585: * @param child the child node, or null
586: *
587: * @throws ParseException if the node analysis discovered errors
588: */
589: protected void childExpr(Production node, Node child)
590: throws ParseException {
591:
592: node.addChild(child);
593: }
594:
595: /**
596: * Called when entering a parse tree node.
597: *
598: * @param node the node being entered
599: *
600: * @throws ParseException if the node analysis discovered errors
601: */
602: protected void enterTerm(Production node) throws ParseException {
603: }
604:
605: /**
606: * Called when exiting a parse tree node.
607: *
608: * @param node the node being exited
609: *
610: * @return the node to add to the parse tree, or
611: * null if no parse tree should be created
612: *
613: * @throws ParseException if the node analysis discovered errors
614: */
615: protected Node exitTerm(Production node) throws ParseException {
616: return node;
617: }
618:
619: /**
620: * Called when adding a child to a parse tree node.
621: *
622: * @param node the parent node
623: * @param child the child node, or null
624: *
625: * @throws ParseException if the node analysis discovered errors
626: */
627: protected void childTerm(Production node, Node child)
628: throws ParseException {
629:
630: node.addChild(child);
631: }
632:
633: /**
634: * Called when entering a parse tree node.
635: *
636: * @param node the node being entered
637: *
638: * @throws ParseException if the node analysis discovered errors
639: */
640: protected void enterFact(Production node) throws ParseException {
641: }
642:
643: /**
644: * Called when exiting a parse tree node.
645: *
646: * @param node the node being exited
647: *
648: * @return the node to add to the parse tree, or
649: * null if no parse tree should be created
650: *
651: * @throws ParseException if the node analysis discovered errors
652: */
653: protected Node exitFact(Production node) throws ParseException {
654: return node;
655: }
656:
657: /**
658: * Called when adding a child to a parse tree node.
659: *
660: * @param node the parent node
661: * @param child the child node, or null
662: *
663: * @throws ParseException if the node analysis discovered errors
664: */
665: protected void childFact(Production node, Node child)
666: throws ParseException {
667:
668: node.addChild(child);
669: }
670:
671: /**
672: * Called when entering a parse tree node.
673: *
674: * @param node the node being entered
675: *
676: * @throws ParseException if the node analysis discovered errors
677: */
678: protected void enterAtom(Production node) throws ParseException {
679: }
680:
681: /**
682: * Called when exiting a parse tree node.
683: *
684: * @param node the node being exited
685: *
686: * @return the node to add to the parse tree, or
687: * null if no parse tree should be created
688: *
689: * @throws ParseException if the node analysis discovered errors
690: */
691: protected Node exitAtom(Production node) throws ParseException {
692: return node;
693: }
694:
695: /**
696: * Called when adding a child to a parse tree node.
697: *
698: * @param node the parent node
699: * @param child the child node, or null
700: *
701: * @throws ParseException if the node analysis discovered errors
702: */
703: protected void childAtom(Production node, Node child)
704: throws ParseException {
705:
706: node.addChild(child);
707: }
708:
709: /**
710: * Called when entering a parse tree node.
711: *
712: * @param node the node being entered
713: *
714: * @throws ParseException if the node analysis discovered errors
715: */
716: protected void enterAtomModifier(Production node)
717: throws ParseException {
718: }
719:
720: /**
721: * Called when exiting a parse tree node.
722: *
723: * @param node the node being exited
724: *
725: * @return the node to add to the parse tree, or
726: * null if no parse tree should be created
727: *
728: * @throws ParseException if the node analysis discovered errors
729: */
730: protected Node exitAtomModifier(Production node)
731: throws ParseException {
732:
733: return node;
734: }
735:
736: /**
737: * Called when adding a child to a parse tree node.
738: *
739: * @param node the parent node
740: * @param child the child node, or null
741: *
742: * @throws ParseException if the node analysis discovered errors
743: */
744: protected void childAtomModifier(Production node, Node child)
745: throws ParseException {
746:
747: node.addChild(child);
748: }
749:
750: /**
751: * Called when entering a parse tree node.
752: *
753: * @param node the node being entered
754: *
755: * @throws ParseException if the node analysis discovered errors
756: */
757: protected void enterCharacterSet(Production node)
758: throws ParseException {
759: }
760:
761: /**
762: * Called when exiting a parse tree node.
763: *
764: * @param node the node being exited
765: *
766: * @return the node to add to the parse tree, or
767: * null if no parse tree should be created
768: *
769: * @throws ParseException if the node analysis discovered errors
770: */
771: protected Node exitCharacterSet(Production node)
772: throws ParseException {
773:
774: return node;
775: }
776:
777: /**
778: * Called when adding a child to a parse tree node.
779: *
780: * @param node the parent node
781: * @param child the child node, or null
782: *
783: * @throws ParseException if the node analysis discovered errors
784: */
785: protected void childCharacterSet(Production node, Node child)
786: throws ParseException {
787:
788: node.addChild(child);
789: }
790:
791: /**
792: * Called when entering a parse tree node.
793: *
794: * @param node the node being entered
795: *
796: * @throws ParseException if the node analysis discovered errors
797: */
798: protected void enterCharacter(Production node)
799: throws ParseException {
800: }
801:
802: /**
803: * Called when exiting a parse tree node.
804: *
805: * @param node the node being exited
806: *
807: * @return the node to add to the parse tree, or
808: * null if no parse tree should be created
809: *
810: * @throws ParseException if the node analysis discovered errors
811: */
812: protected Node exitCharacter(Production node) throws ParseException {
813:
814: return node;
815: }
816:
817: /**
818: * Called when adding a child to a parse tree node.
819: *
820: * @param node the parent node
821: * @param child the child node, or null
822: *
823: * @throws ParseException if the node analysis discovered errors
824: */
825: protected void childCharacter(Production node, Node child)
826: throws ParseException {
827:
828: node.addChild(child);
829: }
830: }
|