Skip to content

Commit 4a58e68

Browse files
authored
Update parser comment with es7 grammar (microsoft#10459)
* Use ES7 term of ExponentiationExpression * Update timeout for mac OS * Address PR: add space
1 parent a013759 commit 4a58e68

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

Gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ function restoreSavedNodeEnv() {
551551
process.env.NODE_ENV = savedNodeEnv;
552552
}
553553

554-
let testTimeout = 20000;
554+
let testTimeout = 40000;
555555
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
556556
const lintFlag = cmdLineOptions["lint"];
557557
cleanTestDirs((err) => {

src/compiler/parser.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ namespace ts {
912912
// Note: it is not actually necessary to save/restore the context flags here. That's
913913
// because the saving/restoring of these flags happens naturally through the recursive
914914
// descent nature of our parser. However, we still store this here just so we can
915-
// assert that that invariant holds.
915+
// assert that invariant holds.
916916
const saveContextFlags = contextFlags;
917917

918918
// If we're only looking ahead, then tell the scanner to only lookahead as well.
@@ -2765,7 +2765,7 @@ namespace ts {
27652765
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
27662766
// (i.e. they're both BinaryExpressions with an assignment operator in it).
27672767

2768-
// First, do the simple check if we have a YieldExpression (production '5').
2768+
// First, do the simple check if we have a YieldExpression (production '6').
27692769
if (isYieldExpression()) {
27702770
return parseYieldExpression();
27712771
}
@@ -3373,24 +3373,44 @@ namespace ts {
33733373
}
33743374

33753375
/**
3376-
* Parse ES7 unary expression and await expression
3376+
* Parse ES7 exponential expression and await expression
3377+
*
3378+
* ES7 ExponentiationExpression:
3379+
* 1) UnaryExpression[?Yield]
3380+
* 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
33773381
*
3378-
* ES7 UnaryExpression:
3379-
* 1) SimpleUnaryExpression[?yield]
3380-
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
33813382
*/
33823383
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
33833384
if (isAwaitExpression()) {
33843385
return parseAwaitExpression();
33853386
}
33863387

3387-
if (isIncrementExpression()) {
3388+
/**
3389+
* ES7 UpdateExpression:
3390+
* 1) LeftHandSideExpression[?Yield]
3391+
* 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
3392+
* 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
3393+
* 4) ++UnaryExpression[?Yield]
3394+
* 5) --UnaryExpression[?Yield]
3395+
*/
3396+
if (isUpdateExpression()) {
33883397
const incrementExpression = parseIncrementExpression();
33893398
return token() === SyntaxKind.AsteriskAsteriskToken ?
33903399
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
33913400
incrementExpression;
33923401
}
33933402

3403+
/**
3404+
* ES7 UnaryExpression:
3405+
* 1) UpdateExpression[?yield]
3406+
* 2) delete UpdateExpression[?yield]
3407+
* 3) void UpdateExpression[?yield]
3408+
* 4) typeof UpdateExpression[?yield]
3409+
* 5) + UpdateExpression[?yield]
3410+
* 6) - UpdateExpression[?yield]
3411+
* 7) ~ UpdateExpression[?yield]
3412+
* 8) ! UpdateExpression[?yield]
3413+
*/
33943414
const unaryOperator = token();
33953415
const simpleUnaryExpression = parseSimpleUnaryExpression();
33963416
if (token() === SyntaxKind.AsteriskAsteriskToken) {
@@ -3408,8 +3428,8 @@ namespace ts {
34083428
/**
34093429
* Parse ES7 simple-unary expression or higher:
34103430
*
3411-
* ES7 SimpleUnaryExpression:
3412-
* 1) IncrementExpression[?yield]
3431+
* ES7 UnaryExpression:
3432+
* 1) UpdateExpression[?yield]
34133433
* 2) delete UnaryExpression[?yield]
34143434
* 3) void UnaryExpression[?yield]
34153435
* 4) typeof UnaryExpression[?yield]
@@ -3447,14 +3467,14 @@ namespace ts {
34473467
/**
34483468
* Check if the current token can possibly be an ES7 increment expression.
34493469
*
3450-
* ES7 IncrementExpression:
3470+
* ES7 UpdateExpression:
34513471
* LeftHandSideExpression[?Yield]
34523472
* LeftHandSideExpression[?Yield][no LineTerminator here]++
34533473
* LeftHandSideExpression[?Yield][no LineTerminator here]--
34543474
* ++LeftHandSideExpression[?Yield]
34553475
* --LeftHandSideExpression[?Yield]
34563476
*/
3457-
function isIncrementExpression(): boolean {
3477+
function isUpdateExpression(): boolean {
34583478
// This function is called inside parseUnaryExpression to decide
34593479
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
34603480
switch (token()) {

0 commit comments

Comments
 (0)