From dc6886c1ca7b08ee7ef6c2bee8713d7d5c33e9fa Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 25 Nov 2014 01:12:21 -0800 Subject: [PATCH] Add clarifying comments. --- src/services/syntax/parser.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/services/syntax/parser.ts b/src/services/syntax/parser.ts index 924726649e1..b02233544be 100644 --- a/src/services/syntax/parser.ts +++ b/src/services/syntax/parser.ts @@ -1371,6 +1371,7 @@ module TypeScript.Parser { } function parseFunctionDeclarationWorker(modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, asteriskToken: ISyntaxToken): FunctionDeclarationSyntax { + // FunctionDeclaration[Yield, Default] : // function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } // GeneratorDeclaration[Yield, Default] : // function * BindingIdentifier[?Yield](FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } @@ -3136,17 +3137,14 @@ module TypeScript.Parser { var _currentToken = currentToken(); // Debug.assert(currentToken.kind === SyntaxKind.OpenParenToken || currentToken.kind === SyntaxKind.LessThanToken); - // Note: ES6 specifies the formal parametes of an arrow function like this: - // - // ArrowFormalParameters[Yield, GeneratorParameter] : - // (StrictFormalParameters[?Yield, ?GeneratorParameter]) - // - // However, the 'GeneratorParameter' portion appears to be a spec bug. There does not - // appear to be any way for that value to be passed in through any grammar constructs. - // - // [Yield], on the other hand, is available, and is passed through. - - var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ true, /*yield:*/ inYieldContext(), /*generatorParameter:*/ false); + // From the static semantic section: + // 1.If the [Yield] grammar parameter is present for CoverParenthesizedExpressionAndArrowParameterList[Yield] + // return the result of parsing the lexical token stream matched by CoverParenthesizedExpressionAndArrowParameterList[Yield] + // using ArrowFormalParameters[Yield, GeneratorParameter] as the goal symbol. + // 2.If the [Yield] grammar parameter is not present for CoverParenthesizedExpressionAndArrowParameterList[Yield] + // return the result of parsing the lexical token stream matched by CoverParenthesizedExpressionAndArrowParameterList + // using ArrowFormalParameters as the goal symbol. + var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ true, /*yield:*/ inYieldContext(), /*generatorParameter:*/ inYieldContext()); if (requireArrow && currentToken().kind !== SyntaxKind.EqualsGreaterThanToken) { return undefined;