feat(ExpressionParser): add support for this

This commit is contained in:
Victor Berchet
2016-08-04 10:14:44 -07:00
committed by Alex Rickabaugh
parent 26c9e1dc70
commit 0ca05eee45
9 changed files with 75 additions and 23 deletions

View File

@ -8,7 +8,6 @@
import {Injectable} from '@angular/core';
import * as chars from '../chars';
import {BaseException} from '../facade/exceptions';
import {NumberWrapper, StringJoiner, StringWrapper, isPresent} from '../facade/lang';
export enum TokenType {
@ -21,7 +20,7 @@ export enum TokenType {
Error
}
const KEYWORDS = ['var', 'let', 'null', 'undefined', 'true', 'false', 'if', 'else'];
const KEYWORDS = ['var', 'let', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];
@Injectable()
export class Lexer {
@ -74,6 +73,8 @@ export class Token {
isKeywordFalse(): boolean { return this.type == TokenType.Keyword && this.strValue == 'false'; }
isKeywordThis(): boolean { return this.type == TokenType.Keyword && this.strValue == 'this'; }
isError(): boolean { return this.type == TokenType.Error; }
toNumber(): number { return this.type == TokenType.Number ? this.numValue : -1; }