Move garmmar checking: numericLiteral; there are still error from incomplete migration

This commit is contained in:
Yui T
2014-12-13 14:08:27 -08:00
parent 2cf51e4639
commit 747eb7268d
3 changed files with 17 additions and 4 deletions

View File

@@ -7009,6 +7009,19 @@ module ts {
return type;
}
function checkNumericLiteral(node: LiteralExpression): Type {
// Grammar checking
if (node.flags & NodeFlags.OctalLiteral) {
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
}
else if (compilerOptions.target >= ScriptTarget.ES5) {
grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
}
}
return numberType;
}
function checkExpressionWorker(node: Expression, contextualMapper: TypeMapper): Type {
switch (node.kind) {
case SyntaxKind.Identifier:
@@ -7023,7 +7036,7 @@ module ts {
case SyntaxKind.FalseKeyword:
return booleanType;
case SyntaxKind.NumericLiteral:
return numberType;
return checkNumericLiteral(<LiteralExpression>node);
case SyntaxKind.TemplateExpression:
return checkTemplateExpression(<TemplateExpression>node);
case SyntaxKind.StringLiteral:

View File

@@ -4658,7 +4658,7 @@ module ts {
return checkMethod(<MethodDeclaration>node);
case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(<ModuleDeclaration>node);
//case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(<ObjectLiteralExpression>node);
case SyntaxKind.NumericLiteral: return checkNumericLiteral(<LiteralExpression>node);
//case SyntaxKind.NumericLiteral: return checkNumericLiteral(<LiteralExpression>node);
case SyntaxKind.Parameter: return checkParameter(<ParameterDeclaration>node);
case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(<PostfixUnaryExpression>node);
case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(<PrefixUnaryExpression>node);