Skip to content

Commit f7a0a38

Browse files
committed
refactor($parse): don't make the lexer mark tokens as literals
1 parent a5df219 commit f7a0a38

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/ng/parse.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,9 @@ Lexer.prototype = {
120120

121121
lex: function (text) {
122122
this.text = text;
123-
124123
this.index = 0;
125124
this.ch = undefined;
126125
this.lastCh = ':'; // can start regexp
127-
128126
this.tokens = [];
129127

130128
while (this.index < this.text.length) {
@@ -243,7 +241,6 @@ Lexer.prototype = {
243241
this.tokens.push({
244242
index: start,
245243
text: number,
246-
literal: true,
247244
constant: true,
248245
fn: function() { return number; }
249246
});
@@ -296,7 +293,6 @@ Lexer.prototype = {
296293
// OPERATORS is our own object so we don't need to use special hasOwnPropertyFn
297294
if (OPERATORS.hasOwnProperty(ident)) {
298295
token.fn = OPERATORS[ident];
299-
token.literal = true;
300296
token.constant = true;
301297
} else {
302298
var getter = getterFn(ident, this.options, this.text);
@@ -313,7 +309,7 @@ Lexer.prototype = {
313309

314310
if (methodName) {
315311
this.tokens.push({
316-
index:lastDot,
312+
index: lastDot,
317313
text: '.'
318314
});
319315
this.tokens.push({
@@ -356,7 +352,6 @@ Lexer.prototype = {
356352
index: start,
357353
text: rawString,
358354
string: string,
359-
literal: true,
360355
constant: true,
361356
fn: function() { return string; }
362357
});
@@ -391,7 +386,6 @@ Parser.prototype = {
391386

392387
parse: function (text) {
393388
this.text = text;
394-
395389
this.tokens = this.lexer.lex(text);
396390

397391
var value = this.statements();
@@ -421,8 +415,10 @@ Parser.prototype = {
421415
if (!primary) {
422416
this.throwError('not a primary expression', token);
423417
}
424-
primary.literal = !!token.literal;
425-
primary.constant = !!token.constant;
418+
if (token.constant) {
419+
primary.constant = true;
420+
primary.literal = true;
421+
}
426422
}
427423

428424
var next, context;

0 commit comments

Comments
 (0)