1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
---|
2 | * JFlex 1.4.3 *
|
---|
3 | * Copyright (C) 1998-2009 Gerwin Klein <[email protected]> *
|
---|
4 | * All rights reserved. *
|
---|
5 | * *
|
---|
6 | * This program is free software; you can redistribute it and/or modify *
|
---|
7 | * it under the terms of the GNU General Public License. See the file *
|
---|
8 | * COPYRIGHT for more information. *
|
---|
9 | * *
|
---|
10 | * This program is distributed in the hope that it will be useful, *
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
---|
13 | * GNU General Public License for more details. *
|
---|
14 | * *
|
---|
15 | * You should have received a copy of the GNU General Public License along *
|
---|
16 | * with this program; if not, write to the Free Software Foundation, Inc., *
|
---|
17 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
---|
18 | * *
|
---|
19 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
---|
20 |
|
---|
21 | package JFlex;
|
---|
22 |
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Stores a regular expression from the rules section of a JFlex specification.
|
---|
26 | *
|
---|
27 | * This class provides storage for one Object of content.
|
---|
28 | * It is used for all regular expressions that are constructed from one object.
|
---|
29 | *
|
---|
30 | * For instance: a* is new RegExp1(sym.STAR, new Character ('a'));
|
---|
31 | *
|
---|
32 | * @author Gerwin Klein
|
---|
33 | * @version JFlex 1.4.3, $Revision: 433 $, $Date: 2009-01-31 19:52:34 +1100 (Sat, 31 Jan 2009) $
|
---|
34 | */
|
---|
35 | public class RegExp1 extends RegExp {
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * The child of this expression node in the syntax tree of a regular expression.
|
---|
39 | */
|
---|
40 | Object content;
|
---|
41 |
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Constructs a new regular expression with one child object.
|
---|
45 | *
|
---|
46 | * @param type a value from the cup generated class sym, defining the
|
---|
47 | * kind of this regular expression
|
---|
48 | *
|
---|
49 | * @param content the child of this expression
|
---|
50 | */
|
---|
51 | public RegExp1(int type, Object content) {
|
---|
52 | super(type);
|
---|
53 | this.content = content;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Returns a String-representation of this regular expression
|
---|
59 | * with the specified indentation.
|
---|
60 | *
|
---|
61 | * @param tab a String that should contain only space characters and
|
---|
62 | * that is inserted in front of standard String-representation
|
---|
63 | * pf this object.
|
---|
64 | */
|
---|
65 | public String print(String tab) {
|
---|
66 | if (content instanceof RegExp) {
|
---|
67 | return tab+"type = "+type+Out.NL+tab+"content :"+Out.NL+((RegExp)content).print(tab+" ");
|
---|
68 | }
|
---|
69 | else
|
---|
70 | return tab+"type = "+type+Out.NL+tab+"content :"+Out.NL+tab+" "+content;
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Returns a String-representation of this regular expression
|
---|
76 | */
|
---|
77 | public String toString() {
|
---|
78 | return print("");
|
---|
79 | }
|
---|
80 | }
|
---|