diff options
Diffstat (limited to 'src/monkey/seaspider/org/gnunet/seaspider/parser/nodes/NodeToken.java')
-rw-r--r-- | src/monkey/seaspider/org/gnunet/seaspider/parser/nodes/NodeToken.java | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/monkey/seaspider/org/gnunet/seaspider/parser/nodes/NodeToken.java b/src/monkey/seaspider/org/gnunet/seaspider/parser/nodes/NodeToken.java new file mode 100644 index 000000000..90db44d7a --- /dev/null +++ b/src/monkey/seaspider/org/gnunet/seaspider/parser/nodes/NodeToken.java | |||
@@ -0,0 +1,87 @@ | |||
1 | // | ||
2 | // Generated by JTB 1.3.2 | ||
3 | // | ||
4 | |||
5 | package org.gnunet.seaspider.parser.nodes; | ||
6 | |||
7 | import java.util.*; | ||
8 | /** | ||
9 | * Represents a single token in the grammar. If the "-tk" option | ||
10 | * is used, also contains a Vector of preceding special tokens. | ||
11 | */ | ||
12 | public class NodeToken implements Node { | ||
13 | public NodeToken(String s) { | ||
14 | this(s, -1, -1, -1, -1, -1); } | ||
15 | |||
16 | public NodeToken(String s, int kind, int beginLine, int beginColumn, int endLine, int endColumn) { | ||
17 | tokenImage = s; | ||
18 | specialTokens = null; | ||
19 | this.kind = kind; | ||
20 | this.beginLine = beginLine; | ||
21 | this.beginColumn = beginColumn; | ||
22 | this.endLine = endLine; | ||
23 | this.endColumn = endColumn; | ||
24 | } | ||
25 | |||
26 | public NodeToken getSpecialAt(int i) { | ||
27 | if ( specialTokens == null ) | ||
28 | throw new java.util.NoSuchElementException("No specials in token"); | ||
29 | return specialTokens.elementAt(i); | ||
30 | } | ||
31 | |||
32 | public int numSpecials() { | ||
33 | if ( specialTokens == null ) return 0; | ||
34 | return specialTokens.size(); | ||
35 | } | ||
36 | |||
37 | public void addSpecial(NodeToken s) { | ||
38 | if ( specialTokens == null ) specialTokens = new Vector<NodeToken>(); | ||
39 | specialTokens.addElement(s); | ||
40 | } | ||
41 | |||
42 | public void trimSpecials() { | ||
43 | if ( specialTokens == null ) return; | ||
44 | specialTokens.trimToSize(); | ||
45 | } | ||
46 | |||
47 | public String toString() { return tokenImage; } | ||
48 | |||
49 | public String withSpecials() { | ||
50 | if ( specialTokens == null ) | ||
51 | return tokenImage; | ||
52 | |||
53 | StringBuffer buf = new StringBuffer(); | ||
54 | |||
55 | for ( Enumeration<NodeToken> e = specialTokens.elements(); e.hasMoreElements(); ) | ||
56 | buf.append(e.nextElement().toString()); | ||
57 | |||
58 | buf.append(tokenImage); | ||
59 | return buf.toString(); | ||
60 | } | ||
61 | |||
62 | public void accept(org.gnunet.seaspider.parser.visitors.Visitor v) { | ||
63 | v.visit(this); | ||
64 | } | ||
65 | public <R,A> R accept(org.gnunet.seaspider.parser.visitors.GJVisitor<R,A> v, A argu) { | ||
66 | return v.visit(this,argu); | ||
67 | } | ||
68 | public <R> R accept(org.gnunet.seaspider.parser.visitors.GJNoArguVisitor<R> v) { | ||
69 | return v.visit(this); | ||
70 | } | ||
71 | public <A> void accept(org.gnunet.seaspider.parser.visitors.GJVoidVisitor<A> v, A argu) { | ||
72 | v.visit(this,argu); | ||
73 | } | ||
74 | |||
75 | public String tokenImage; | ||
76 | |||
77 | // Stores a list of NodeTokens | ||
78 | public Vector<NodeToken> specialTokens; | ||
79 | |||
80 | // -1 for these ints means no position info is available. | ||
81 | public int beginLine, beginColumn, endLine, endColumn; | ||
82 | |||
83 | // Equal to the JavaCC token "kind" integer. | ||
84 | // -1 if not available. | ||
85 | public int kind; | ||
86 | } | ||
87 | |||