Update parser with new grammar

This commit is contained in:
Yui T
2015-10-05 10:34:48 -07:00
parent 1326ba9820
commit ce7a054407
3 changed files with 33 additions and 26 deletions
@@ -618,5 +618,6 @@ namespace ts {
JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." },
Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." },
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" },
Left_hand_side_of_Asterisk_Asterisk_cannot_be_a_simple_unary_expression_Consider_parenthesize_the_expression: { code: 17006, category: DiagnosticCategory.Error, key: "Left hand side of '**' cannot be a simple unary expression. Consider parenthesize the expression." },
};
}
+8 -4
View File
@@ -1700,11 +1700,11 @@
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
},
},
"Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": {
"category": "Error",
"code": 2653
},
},
"Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2654
@@ -1712,11 +1712,11 @@
"Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2655
},
},
"Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.": {
"category": "Error",
"code": 2656
},
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@@ -2466,5 +2466,9 @@
"A constructor cannot contain a 'super' call when its class extends 'null'": {
"category": "Error",
"code": 17005
},
"Left hand side of '**' cannot be a simple unary expression. Consider parenthesize the expression.": {
"category": "Error",
"code": 17006
}
}
+24 -22
View File
@@ -3191,34 +3191,36 @@ namespace ts {
* Comment
* @param node
*/
function isIncrementExpression(node: UnaryExpression): node is IncrementExpression {
if (node.kind === SyntaxKind.DeleteExpression || node.kind === SyntaxKind.TypeOfExpression ||
node.kind === SyntaxKind.VoidExpression || node.kind === SyntaxKind.TypeAssertionExpression ||
node.kind === SyntaxKind.JsxExpression) {
return false;
function isIncrementExpression(): boolean{
// TODO(yuisu): Comment why we have to do what are we doing here
switch (token) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.DeleteKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.LessThanToken:
return false;
default:
return true;
}
else if (node.kind === SyntaxKind.PrefixUnaryExpression && ((<PrefixUnaryExpression>node).operator === SyntaxKind.PlusToken ||
(<PrefixUnaryExpression>node).operator === SyntaxKind.MinusToken || (<PrefixUnaryExpression>node).operator === SyntaxKind.TildeToken ||
(<PrefixUnaryExpression>node).operator === SyntaxKind.ExclamationToken)) {
return false;
}
return true;
}
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
let tryParseIncrementExpression = parseSimpleUnaryExpression();
if (isIncrementExpression()) {
let incrementExpression = parseIncrementExpression();
return token === SyntaxKind.AsteriskAsteriskToken ?
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
incrementExpression;
}
let simpleUnaryExpression = parseSimpleUnaryExpression();
if (token === SyntaxKind.AsteriskAsteriskToken) {
if (isIncrementExpression(tryParseIncrementExpression)) {
return <BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), tryParseIncrementExpression);
}
else {
parseErrorAtCurrentToken(Diagnostics.Only_incrementExpression_is_allowed_as_left_operand_of_Asterisk_Asterisk);
return tryParseIncrementExpression;
}
}
else {
return tryParseIncrementExpression;
parseErrorAtCurrentToken(Diagnostics.Left_hand_side_of_Asterisk_Asterisk_cannot_be_a_simple_unary_expression_Consider_parenthesize_the_expression)
}
return simpleUnaryExpression;
}
/**