Completely remove check strict mode from parser

This commit is contained in:
Yui T 2015-04-08 17:51:51 -07:00
parent 958f7b8202
commit fb9009f741

View file

@ -1350,13 +1350,8 @@ module ts {
return speculationHelper(callback, /*isLookAhead:*/ false);
}
// The function takes a flag "considerStrictModeContext" because in the case of parsing
// an identifier, we don't want to consider whether we are in strict mode. This is because
// if the identifier violates strict-mode reserved word, we want to report more explicit error
// in the checker.
// However, in some cases such as isLetDeclaration, we want to know at the parse time whether
// next token is really an identifier in strict mode and report an error.
function isIdentifier(considerStrictModeContext = true): boolean {
// Ignore strict mode flag because we will be report an error in type checker instead.
function isIdentifier(): boolean {
if (token === SyntaxKind.Identifier) {
return true;
}
@ -1367,12 +1362,7 @@ module ts {
return false;
}
if (considerStrictModeContext) {
return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord;
}
else {
return token > SyntaxKind.LastReservedWord;
}
return token > SyntaxKind.LastReservedWord;
}
function parseExpected(kind: SyntaxKind, diagnosticMessage?: DiagnosticMessage): boolean {
@ -1510,7 +1500,7 @@ module ts {
}
function parseIdentifier(diagnosticMessage?: DiagnosticMessage): Identifier {
return createIdentifier(isIdentifier(/*considerStrictModeContext*/ false), diagnosticMessage);
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName(): Identifier {