mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Update parser comment with es7 grammar (#10459)
* Use ES7 term of ExponentiationExpression * Update timeout for mac OS * Address PR: add space
This commit is contained in:
parent
a0137597f9
commit
4a58e68d00
@ -551,7 +551,7 @@ function restoreSavedNodeEnv() {
|
||||
process.env.NODE_ENV = savedNodeEnv;
|
||||
}
|
||||
|
||||
let testTimeout = 20000;
|
||||
let testTimeout = 40000;
|
||||
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
|
||||
const lintFlag = cmdLineOptions["lint"];
|
||||
cleanTestDirs((err) => {
|
||||
|
||||
@ -912,7 +912,7 @@ namespace ts {
|
||||
// Note: it is not actually necessary to save/restore the context flags here. That's
|
||||
// because the saving/restoring of these flags happens naturally through the recursive
|
||||
// descent nature of our parser. However, we still store this here just so we can
|
||||
// assert that that invariant holds.
|
||||
// assert that invariant holds.
|
||||
const saveContextFlags = contextFlags;
|
||||
|
||||
// If we're only looking ahead, then tell the scanner to only lookahead as well.
|
||||
@ -2765,7 +2765,7 @@ namespace ts {
|
||||
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
|
||||
// (i.e. they're both BinaryExpressions with an assignment operator in it).
|
||||
|
||||
// First, do the simple check if we have a YieldExpression (production '5').
|
||||
// First, do the simple check if we have a YieldExpression (production '6').
|
||||
if (isYieldExpression()) {
|
||||
return parseYieldExpression();
|
||||
}
|
||||
@ -3373,24 +3373,44 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ES7 unary expression and await expression
|
||||
* Parse ES7 exponential expression and await expression
|
||||
*
|
||||
* ES7 ExponentiationExpression:
|
||||
* 1) UnaryExpression[?Yield]
|
||||
* 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
|
||||
*
|
||||
* ES7 UnaryExpression:
|
||||
* 1) SimpleUnaryExpression[?yield]
|
||||
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
|
||||
*/
|
||||
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
|
||||
if (isAwaitExpression()) {
|
||||
return parseAwaitExpression();
|
||||
}
|
||||
|
||||
if (isIncrementExpression()) {
|
||||
/**
|
||||
* ES7 UpdateExpression:
|
||||
* 1) LeftHandSideExpression[?Yield]
|
||||
* 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
|
||||
* 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
|
||||
* 4) ++UnaryExpression[?Yield]
|
||||
* 5) --UnaryExpression[?Yield]
|
||||
*/
|
||||
if (isUpdateExpression()) {
|
||||
const incrementExpression = parseIncrementExpression();
|
||||
return token() === SyntaxKind.AsteriskAsteriskToken ?
|
||||
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
|
||||
incrementExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* ES7 UnaryExpression:
|
||||
* 1) UpdateExpression[?yield]
|
||||
* 2) delete UpdateExpression[?yield]
|
||||
* 3) void UpdateExpression[?yield]
|
||||
* 4) typeof UpdateExpression[?yield]
|
||||
* 5) + UpdateExpression[?yield]
|
||||
* 6) - UpdateExpression[?yield]
|
||||
* 7) ~ UpdateExpression[?yield]
|
||||
* 8) ! UpdateExpression[?yield]
|
||||
*/
|
||||
const unaryOperator = token();
|
||||
const simpleUnaryExpression = parseSimpleUnaryExpression();
|
||||
if (token() === SyntaxKind.AsteriskAsteriskToken) {
|
||||
@ -3408,8 +3428,8 @@ namespace ts {
|
||||
/**
|
||||
* Parse ES7 simple-unary expression or higher:
|
||||
*
|
||||
* ES7 SimpleUnaryExpression:
|
||||
* 1) IncrementExpression[?yield]
|
||||
* ES7 UnaryExpression:
|
||||
* 1) UpdateExpression[?yield]
|
||||
* 2) delete UnaryExpression[?yield]
|
||||
* 3) void UnaryExpression[?yield]
|
||||
* 4) typeof UnaryExpression[?yield]
|
||||
@ -3447,14 +3467,14 @@ namespace ts {
|
||||
/**
|
||||
* Check if the current token can possibly be an ES7 increment expression.
|
||||
*
|
||||
* ES7 IncrementExpression:
|
||||
* ES7 UpdateExpression:
|
||||
* LeftHandSideExpression[?Yield]
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]++
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]--
|
||||
* ++LeftHandSideExpression[?Yield]
|
||||
* --LeftHandSideExpression[?Yield]
|
||||
*/
|
||||
function isIncrementExpression(): boolean {
|
||||
function isUpdateExpression(): boolean {
|
||||
// This function is called inside parseUnaryExpression to decide
|
||||
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
|
||||
switch (token()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user