Switch parsePrimaryExpression to if-else style
This commit is contained in:
parent
004cea8293
commit
b552613fb5
1 changed files with 34 additions and 28 deletions
|
@ -2669,35 +2669,41 @@ module ts {
|
|||
}
|
||||
|
||||
function parsePrimaryExpression(): PrimaryExpression {
|
||||
switch (token) {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
return parseTokenNode<PrimaryExpression>();
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
if (token === SyntaxKind.ThisKeyword ||
|
||||
token === SyntaxKind.SuperKeyword ||
|
||||
token === SyntaxKind.NullKeyword ||
|
||||
token === SyntaxKind.TrueKeyword ||
|
||||
token === SyntaxKind.FalseKeyword) {
|
||||
return parseTokenNode<PrimaryExpression>();
|
||||
}
|
||||
else if (token === SyntaxKind.NumericLiteral ||
|
||||
token === SyntaxKind.StringLiteral ||
|
||||
token === SyntaxKind.NoSubstitutionTemplateLiteral) {
|
||||
return parseLiteralNode();
|
||||
}
|
||||
else if (token === SyntaxKind.OpenParenToken) {
|
||||
return parseParenthesizedExpression();
|
||||
}
|
||||
else if (token === SyntaxKind.OpenBracketToken) {
|
||||
return parseArrayLiteralExpression();
|
||||
}
|
||||
else if (token === SyntaxKind.OpenBraceToken) {
|
||||
return parseObjectLiteralExpression();
|
||||
}
|
||||
else if (token === SyntaxKind.FunctionKeyword) {
|
||||
return parseFunctionExpression();
|
||||
}
|
||||
else if (token === SyntaxKind.NewKeyword) {
|
||||
return parseNewExpression();
|
||||
}
|
||||
else if (token === SyntaxKind.SlashToken ||
|
||||
token === SyntaxKind.SlashEqualsToken) {
|
||||
if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) {
|
||||
return parseLiteralNode();
|
||||
case SyntaxKind.OpenParenToken:
|
||||
return parseParenthesizedExpression();
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
return parseArrayLiteralExpression();
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseObjectLiteralExpression();
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
return parseFunctionExpression();
|
||||
case SyntaxKind.NewKeyword:
|
||||
return parseNewExpression();
|
||||
case SyntaxKind.SlashToken:
|
||||
case SyntaxKind.SlashEqualsToken:
|
||||
if (reScanSlashToken() === SyntaxKind.RegularExpressionLiteral) {
|
||||
return parseLiteralNode();
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.TemplateHead:
|
||||
return parseTemplateExpression();
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.TemplateHead) {
|
||||
return parseTemplateExpression();
|
||||
}
|
||||
|
||||
return parseIdentifier(Diagnostics.Expression_expected);
|
||||
|
|
Loading…
Reference in a new issue