|
@@ -106,7 +106,6 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements T
|
106
|
106
|
next.position,
|
107
|
107
|
factory.create(
|
108
|
108
|
other,
|
109
|
|
- next.token.getWhitespaceBefore(),
|
110
|
109
|
next.token.getContent()));
|
111
|
110
|
}
|
112
|
111
|
|
|
@@ -126,27 +125,8 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements T
|
126
|
125
|
// =======================
|
127
|
126
|
// === Private methods ===
|
128
|
127
|
// =======================
|
129
|
|
-
|
130
|
|
- /**
|
131
|
|
- * Advances to the next non - whitespace token.
|
132
|
|
- */
|
|
128
|
+
|
133
|
129
|
private void advance()
|
134
|
|
- {
|
135
|
|
- StringBuilder whitespace = new StringBuilder();
|
136
|
|
- while (true) {
|
137
|
|
- advanceToken(whitespace.toString());
|
138
|
|
- if (next.token.getType().isWhitespace()) {
|
139
|
|
- whitespace.append(next.token.getContent());
|
140
|
|
- } else {
|
141
|
|
- break;
|
142
|
|
- }
|
143
|
|
- }
|
144
|
|
- }
|
145
|
|
-
|
146
|
|
- /**
|
147
|
|
- * Advances to the next token.
|
148
|
|
- */
|
149
|
|
- private void advanceToken(String whitespace)
|
150
|
130
|
{
|
151
|
131
|
if (nextChar < 0) {
|
152
|
132
|
CodePosition position = new CodePosition(
|
|
@@ -156,7 +136,7 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements T
|
156
|
136
|
line,
|
157
|
137
|
lineOffset);
|
158
|
138
|
|
159
|
|
- next = new PositionedToken(position, factory.create(eof, whitespace, ""));
|
|
139
|
+ next = new PositionedToken(position, factory.create(eof, ""));
|
160
|
140
|
return;
|
161
|
141
|
}
|
162
|
142
|
|
|
@@ -180,17 +160,17 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements T
|
180
|
160
|
if (dfa.finals[state] != null) {
|
181
|
161
|
if (state == 0) {
|
182
|
162
|
value.append((char) nextChar);
|
183
|
|
- next = new PositionedToken(position, factory.create(invalid, value.toString(), whitespace));
|
|
163
|
+ next = new PositionedToken(position, factory.create(invalid, value.toString()));
|
184
|
164
|
nextChar = reader.read();
|
185
|
165
|
}
|
186
|
166
|
|
187
|
|
- next = new PositionedToken(position, factory.create(dfa.finals[state], value.toString(), whitespace));
|
|
167
|
+ next = new PositionedToken(position, factory.create(dfa.finals[state], value.toString()));
|
188
|
168
|
} else {
|
189
|
169
|
if (nextChar < 0 && value.length() == 0)
|
190
|
170
|
return; // happens on comments at the end of files
|
191
|
171
|
|
192
|
172
|
value.append((char) nextChar);
|
193
|
|
- next = new PositionedToken(position, factory.create(invalid, value.toString(), whitespace));
|
|
173
|
+ next = new PositionedToken(position, factory.create(invalid, value.toString()));
|
194
|
174
|
nextChar = reader.read();
|
195
|
175
|
}
|
196
|
176
|
} catch (IOException ex) {
|