|
129 | 129 | };
|
130 | 130 | }
|
131 | 131 |
|
132 |
| - |
133 | 132 | // Type constants used to define functions.
|
134 | 133 | var TYPE_NUMBER = 0;
|
135 | 134 | var TYPE_ANY = 1;
|
|
142 | 141 | var TYPE_ARRAY_NUMBER = 8;
|
143 | 142 | var TYPE_ARRAY_STRING = 9;
|
144 | 143 |
|
145 |
| - |
146 | 144 | var TOK_EOF = "EOF";
|
147 | 145 | var TOK_UNQUOTEDIDENTIFIER = "UnquotedIdentifier";
|
148 | 146 | var TOK_QUOTEDIDENTIFIER = "QuotedIdentifier";
|
|
192 | 190 | "@": TOK_CURRENT
|
193 | 191 | };
|
194 | 192 |
|
195 |
| - var identifierStart = { |
196 |
| - a: true, b: true, c: true, d: true, e: true, f: true, g: true, h: true, |
197 |
| - i: true, j: true, k: true, l: true, m: true, n: true, o: true, p: true, |
198 |
| - q: true, r: true, s: true, t: true, u: true, v: true, w: true, x: true, |
199 |
| - y: true, z: true, A: true, B: true, C: true, D: true, E: true, F: true, |
200 |
| - G: true, H: true, I: true, J: true, K: true, L: true, M: true, N: true, |
201 |
| - O: true, P: true, Q: true, R: true, S: true, T: true, U: true, V: true, |
202 |
| - W: true, X: true, Y: true, Z: true, _: true |
203 |
| - }; |
204 |
| - |
205 | 193 | var operatorStartToken = {
|
206 | 194 | "<": true,
|
207 | 195 | ">": true,
|
|
223 | 211 | "-": true
|
224 | 212 | };
|
225 | 213 |
|
226 |
| - var identifierTrailing = merge(identifierStart, numbers); |
227 |
| - |
228 | 214 | var skipChars = {
|
229 | 215 | " ": true,
|
230 | 216 | "\t": true,
|
231 | 217 | "\n": true
|
232 | 218 | };
|
233 | 219 |
|
234 | 220 |
|
| 221 | + function isAlpha(ch) { |
| 222 | + return (ch >= "a" && ch <= "z") || |
| 223 | + (ch >= "A" && ch <= "Z") || |
| 224 | + ch === "_" |
| 225 | + } |
| 226 | + |
| 227 | + function isAlphaNum(ch) { |
| 228 | + return (ch >= "a" && ch <= "z") || |
| 229 | + (ch >= "A" && ch <= "Z") || |
| 230 | + (ch >= "0" && ch <= "9") || |
| 231 | + ch === "_" |
| 232 | + } |
| 233 | + |
235 | 234 | function Lexer() {
|
236 | 235 | }
|
237 | 236 | Lexer.prototype = {
|
|
242 | 241 | var identifier;
|
243 | 242 | var token;
|
244 | 243 | while (this.current < stream.length) {
|
245 |
| - if (identifierStart[stream[this.current]] !== undefined) { |
| 244 | + if (isAlpha(stream[this.current])) { |
246 | 245 | start = this.current;
|
247 | 246 | identifier = this.consumeUnquotedIdentifier(stream);
|
248 | 247 | tokens.push({type: TOK_UNQUOTEDIDENTIFIER,
|
|
314 | 313 | consumeUnquotedIdentifier: function(stream) {
|
315 | 314 | var start = this.current;
|
316 | 315 | this.current++;
|
317 |
| - while (identifierTrailing[stream[this.current]] !== undefined) { |
| 316 | + while (this.current < stream.length && isAlphaNum(stream[this.current])) { |
318 | 317 | this.current++;
|
319 | 318 | }
|
320 | 319 | return stream.slice(start, this.current);
|
|
0 commit comments