KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > percederberg > grammatica > test > RegexpAnalyzer


1 /*
2  * RegexpAnalyzer.java
3  *
4  * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation; either version 2.1
9  * of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307, USA.
20  *
21  * Copyright (c) 2003 Per Cederberg. All rights reserved.
22  */

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 /**
33  * A class providing callback methods for the parser.
34  *
35  * @author Per Cederberg, <per at percederberg dot net>
36  * @version 1.0
37  */

38 abstract class RegexpAnalyzer extends Analyzer {
39
40     /**
41      * Called when entering a parse tree node.
42      *
43      * @param node the node being entered
44      *
45      * @throws ParseException if the node analysis discovered errors
46      */

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     /**
116      * Called when exiting a parse tree node.
117      *
118      * @param node the node being exited
119      *
120      * @return the node to add to the parse tree, or
121      * null if no parse tree should be created
122      *
123      * @throws ParseException if the node analysis discovered errors
124      */

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     /**
174      * Called when adding a child to a parse tree node.
175      *
176      * @param node the parent node
177      * @param child the child node, or null
178      *
179      * @throws ParseException if the node analysis discovered errors
180      */

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     /**
210      * Called when entering a parse tree node.
211      *
212      * @param node the node being entered
213      *
214      * @throws ParseException if the node analysis discovered errors
215      */

216     protected void enterLeftParen(Token node) throws ParseException {
217     }
218
219     /**
220      * Called when exiting a parse tree node.
221      *
222      * @param node the node being exited
223      *
224      * @return the node to add to the parse tree, or
225      * null if no parse tree should be created
226      *
227      * @throws ParseException if the node analysis discovered errors
228      */

229     protected Node exitLeftParen(Token node) throws ParseException {
230         return node;
231     }
232
233     /**
234      * Called when entering a parse tree node.
235      *
236      * @param node the node being entered
237      *
238      * @throws ParseException if the node analysis discovered errors
239      */

240     protected void enterRightParen(Token node) throws ParseException {
241     }
242
243     /**
244      * Called when exiting a parse tree node.
245      *
246      * @param node the node being exited
247      *
248      * @return the node to add to the parse tree, or
249      * null if no parse tree should be created
250      *
251      * @throws ParseException if the node analysis discovered errors
252      */

253     protected Node exitRightParen(Token node) throws ParseException {
254         return node;
255     }
256
257     /**
258      * Called when entering a parse tree node.
259      *
260      * @param node the node being entered
261      *
262      * @throws ParseException if the node analysis discovered errors
263      */

264     protected void enterLeftBracket(Token node) throws ParseException {
265     }
266
267     /**
268      * Called when exiting a parse tree node.
269      *
270      * @param node the node being exited
271      *
272      * @return the node to add to the parse tree, or
273      * null if no parse tree should be created
274      *
275      * @throws ParseException if the node analysis discovered errors
276      */

277     protected Node exitLeftBracket(Token node) throws ParseException {
278         return node;
279     }
280
281     /**
282      * Called when entering a parse tree node.
283      *
284      * @param node the node being entered
285      *
286      * @throws ParseException if the node analysis discovered errors
287      */

288     protected void enterRightBracket(Token node) throws ParseException {
289     }
290
291     /**
292      * Called when exiting a parse tree node.
293      *
294      * @param node the node being exited
295      *
296      * @return the node to add to the parse tree, or
297      * null if no parse tree should be created
298      *
299      * @throws ParseException if the node analysis discovered errors
300      */

301     protected Node exitRightBracket(Token node) throws ParseException {
302         return node;
303     }
304
305     /**
306      * Called when entering a parse tree node.
307      *
308      * @param node the node being entered
309      *
310      * @throws ParseException if the node analysis discovered errors
311      */

312     protected void enterLeftBrace(Token node) throws ParseException {
313     }
314
315     /**
316      * Called when exiting a parse tree node.
317      *
318      * @param node the node being exited
319      *
320      * @return the node to add to the parse tree, or
321      * null if no parse tree should be created
322      *
323      * @throws ParseException if the node analysis discovered errors
324      */

325     protected Node exitLeftBrace(Token node) throws ParseException {
326         return node;
327     }
328
329     /**
330      * Called when entering a parse tree node.
331      *
332      * @param node the node being entered
333      *
334      * @throws ParseException if the node analysis discovered errors
335      */

336     protected void enterRightBrace(Token node) throws ParseException {
337     }
338
339     /**
340      * Called when exiting a parse tree node.
341      *
342      * @param node the node being exited
343      *
344      * @return the node to add to the parse tree, or
345      * null if no parse tree should be created
346      *
347      * @throws ParseException if the node analysis discovered errors
348      */

349     protected Node exitRightBrace(Token node) throws ParseException {
350         return node;
351     }
352
353     /**
354      * Called when entering a parse tree node.
355      *
356      * @param node the node being entered
357      *
358      * @throws ParseException if the node analysis discovered errors
359      */

360     protected void enterQuestion(Token node) throws ParseException {
361     }
362
363     /**
364      * Called when exiting a parse tree node.
365      *
366      * @param node the node being exited
367      *
368      * @return the node to add to the parse tree, or
369      * null if no parse tree should be created
370      *
371      * @throws ParseException if the node analysis discovered errors
372      */

373     protected Node exitQuestion(Token node) throws ParseException {
374         return node;
375     }
376
377     /**
378      * Called when entering a parse tree node.
379      *
380      * @param node the node being entered
381      *
382      * @throws ParseException if the node analysis discovered errors
383      */

384     protected void enterAsterisk(Token node) throws ParseException {
385     }
386
387     /**
388      * Called when exiting a parse tree node.
389      *
390      * @param node the node being exited
391      *
392      * @return the node to add to the parse tree, or
393      * null if no parse tree should be created
394      *
395      * @throws ParseException if the node analysis discovered errors
396      */

397     protected Node exitAsterisk(Token node) throws ParseException {
398         return node;
399     }
400
401     /**
402      * Called when entering a parse tree node.
403      *
404      * @param node the node being entered
405      *
406      * @throws ParseException if the node analysis discovered errors
407      */

408     protected void enterPlus(Token node) throws ParseException {
409     }
410
411     /**
412      * Called when exiting a parse tree node.
413      *
414      * @param node the node being exited
415      *
416      * @return the node to add to the parse tree, or
417      * null if no parse tree should be created
418      *
419      * @throws ParseException if the node analysis discovered errors
420      */

421     protected Node exitPlus(Token node) throws ParseException {
422         return node;
423     }
424
425     /**
426      * Called when entering a parse tree node.
427      *
428      * @param node the node being entered
429      *
430      * @throws ParseException if the node analysis discovered errors
431      */

432     protected void enterVerticalBar(Token node) throws ParseException {
433     }
434
435     /**
436      * Called when exiting a parse tree node.
437      *
438      * @param node the node being exited
439      *
440      * @return the node to add to the parse tree, or
441      * null if no parse tree should be created
442      *
443      * @throws ParseException if the node analysis discovered errors
444      */

445     protected Node exitVerticalBar(Token node) throws ParseException {
446         return node;
447     }
448
449     /**
450      * Called when entering a parse tree node.
451      *
452      * @param node the node being entered
453      *
454      * @throws ParseException if the node analysis discovered errors
455      */

456     protected void enterDot(Token node) throws ParseException {
457     }
458
459     /**
460      * Called when exiting a parse tree node.
461      *
462      * @param node the node being exited
463      *
464      * @return the node to add to the parse tree, or
465      * null if no parse tree should be created
466      *
467      * @throws ParseException if the node analysis discovered errors
468      */

469     protected Node exitDot(Token node) throws ParseException {
470         return node;
471     }
472
473     /**
474      * Called when entering a parse tree node.
475      *
476      * @param node the node being entered
477      *
478      * @throws ParseException if the node analysis discovered errors
479      */

480     protected void enterComma(Token node) throws ParseException {
481     }
482
483     /**
484      * Called when exiting a parse tree node.
485      *
486      * @param node the node being exited
487      *
488      * @return the node to add to the parse tree, or
489      * null if no parse tree should be created
490      *
491      * @throws ParseException if the node analysis discovered errors
492      */

493     protected Node exitComma(Token node) throws ParseException {
494         return node;
495     }
496
497     /**
498      * Called when entering a parse tree node.
499      *
500      * @param node the node being entered
501      *
502      * @throws ParseException if the node analysis discovered errors
503      */

504     protected void enterNumber(Token node) throws ParseException {
505     }
506
507     /**
508      * Called when exiting a parse tree node.
509      *
510      * @param node the node being exited
511      *
512      * @return the node to add to the parse tree, or
513      * null if no parse tree should be created
514      *
515      * @throws ParseException if the node analysis discovered errors
516      */

517     protected Node exitNumber(Token node) throws ParseException {
518         return node;
519     }
520
521     /**
522      * Called when entering a parse tree node.
523      *
524      * @param node the node being entered
525      *
526      * @throws ParseException if the node analysis discovered errors
527      */

528     protected void enterChar(Token node) throws ParseException {
529     }
530
531     /**
532      * Called when exiting a parse tree node.
533      *
534      * @param node the node being exited
535      *
536      * @return the node to add to the parse tree, or
537      * null if no parse tree should be created
538      *
539      * @throws ParseException if the node analysis discovered errors
540      */

541     protected Node exitChar(Token node) throws ParseException {
542         return node;
543     }
544
545     /**
546      * Called when entering a parse tree node.
547      *
548      * @param node the node being entered
549      *
550      * @throws ParseException if the node analysis discovered errors
551      */

552     protected void enterExpr(Production node) throws ParseException {
553     }
554
555     /**
556      * Called when exiting a parse tree node.
557      *
558      * @param node the node being exited
559      *
560      * @return the node to add to the parse tree, or
561      * null if no parse tree should be created
562      *
563      * @throws ParseException if the node analysis discovered errors
564      */

565     protected Node exitExpr(Production node) throws ParseException {
566         return node;
567     }
568
569     /**
570      * Called when adding a child to a parse tree node.
571      *
572      * @param node the parent node
573      * @param child the child node, or null
574      *
575      * @throws ParseException if the node analysis discovered errors
576      */

577     protected void childExpr(Production node, Node child)
578         throws ParseException {
579
580         node.addChild(child);
581     }
582
583     /**
584      * Called when entering a parse tree node.
585      *
586      * @param node the node being entered
587      *
588      * @throws ParseException if the node analysis discovered errors
589      */

590     protected void enterTerm(Production node) throws ParseException {
591     }
592
593     /**
594      * Called when exiting a parse tree node.
595      *
596      * @param node the node being exited
597      *
598      * @return the node to add to the parse tree, or
599      * null if no parse tree should be created
600      *
601      * @throws ParseException if the node analysis discovered errors
602      */

603     protected Node exitTerm(Production node) throws ParseException {
604         return node;
605     }
606
607     /**
608      * Called when adding a child to a parse tree node.
609      *
610      * @param node the parent node
611      * @param child the child node, or null
612      *
613      * @throws ParseException if the node analysis discovered errors
614      */

615     protected void childTerm(Production node, Node child)
616         throws ParseException {
617
618         node.addChild(child);
619     }
620
621     /**
622      * Called when entering a parse tree node.
623      *
624      * @param node the node being entered
625      *
626      * @throws ParseException if the node analysis discovered errors
627      */

628     protected void enterFact(Production node) throws ParseException {
629     }
630
631     /**
632      * Called when exiting a parse tree node.
633      *
634      * @param node the node being exited
635      *
636      * @return the node to add to the parse tree, or
637      * null if no parse tree should be created
638      *
639      * @throws ParseException if the node analysis discovered errors
640      */

641     protected Node exitFact(Production node) throws ParseException {
642         return node;
643     }
644
645     /**
646      * Called when adding a child to a parse tree node.
647      *
648      * @param node the parent node
649      * @param child the child node, or null
650      *
651      * @throws ParseException if the node analysis discovered errors
652      */

653     protected void childFact(Production node, Node child)
654         throws ParseException {
655
656         node.addChild(child);
657     }
658
659     /**
660      * Called when entering a parse tree node.
661      *
662      * @param node the node being entered
663      *
664      * @throws ParseException if the node analysis discovered errors
665      */

666     protected void enterAtom(Production node) throws ParseException {
667     }
668
669     /**
670      * Called when exiting a parse tree node.
671      *
672      * @param node the node being exited
673      *
674      * @return the node to add to the parse tree, or
675      * null if no parse tree should be created
676      *
677      * @throws ParseException if the node analysis discovered errors
678      */

679     protected Node exitAtom(Production node) throws ParseException {
680         return node;
681     }
682
683     /**
684      * Called when adding a child to a parse tree node.
685      *
686      * @param node the parent node
687      * @param child the child node, or null
688      *
689      * @throws ParseException if the node analysis discovered errors
690      */

691     protected void childAtom(Production node, Node child)
692         throws ParseException {
693
694         node.addChild(child);
695     }
696
697     /**
698      * Called when entering a parse tree node.
699      *
700      * @param node the node being entered
701      *
702      * @throws ParseException if the node analysis discovered errors
703      */

704     protected void enterAtomModifier(Production node)
705         throws ParseException {
706     }
707
708     /**
709      * Called when exiting a parse tree node.
710      *
711      * @param node the node being exited
712      *
713      * @return the node to add to the parse tree, or
714      * null if no parse tree should be created
715      *
716      * @throws ParseException if the node analysis discovered errors
717      */

718     protected Node exitAtomModifier(Production node)
719         throws ParseException {
720
721         return node;
722     }
723
724     /**
725      * Called when adding a child to a parse tree node.
726      *
727      * @param node the parent node
728      * @param child the child node, or null
729      *
730      * @throws ParseException if the node analysis discovered errors
731      */

732     protected void childAtomModifier(Production node, Node child)
733         throws ParseException {
734
735         node.addChild(child);
736     }
737
738     /**
739      * Called when entering a parse tree node.
740      *
741      * @param node the node being entered
742      *
743      * @throws ParseException if the node analysis discovered errors
744      */

745     protected void enterCharacterSet(Production node)
746         throws ParseException {
747     }
748
749     /**
750      * Called when exiting a parse tree node.
751      *
752      * @param node the node being exited
753      *
754      * @return the node to add to the parse tree, or
755      * null if no parse tree should be created
756      *
757      * @throws ParseException if the node analysis discovered errors
758      */

759     protected Node exitCharacterSet(Production node)
760         throws ParseException {
761
762         return node;
763     }
764
765     /**
766      * Called when adding a child to a parse tree node.
767      *
768      * @param node the parent node
769      * @param child the child node, or null
770      *
771      * @throws ParseException if the node analysis discovered errors
772      */

773     protected void childCharacterSet(Production node, Node child)
774         throws ParseException {
775
776         node.addChild(child);
777     }
778
779     /**
780      * Called when entering a parse tree node.
781      *
782      * @param node the node being entered
783      *
784      * @throws ParseException if the node analysis discovered errors
785      */

786     protected void enterCharacter(Production node)
787         throws ParseException {
788     }
789
790     /**
791      * Called when exiting a parse tree node.
792      *
793      * @param node the node being exited
794      *
795      * @return the node to add to the parse tree, or
796      * null if no parse tree should be created
797      *
798      * @throws ParseException if the node analysis discovered errors
799      */

800     protected Node exitCharacter(Production node)
801         throws ParseException {
802
803         return node;
804     }
805
806     /**
807      * Called when adding a child to a parse tree node.
808      *
809      * @param node the parent node
810      * @param child the child node, or null
811      *
812      * @throws ParseException if the node analysis discovered errors
813      */

814     protected void childCharacter(Production node, Node child)
815         throws ParseException {
816
817         node.addChild(child);
818     }
819 }
820
Popular Tags