From 9aa4feb7442042866dc113956f3e4fd58468d559 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Fri, 22 Jun 2018 16:17:45 -0400 Subject: [PATCH] Make FunctionBody/Expression variants of arrow expressions. Closes #43. --- spec.html | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/spec.html b/spec.html index 60b6b85..e8e78bc 100644 --- a/spec.html +++ b/spec.html @@ -247,8 +247,10 @@

Tree Grammar

typedef (EagerSetter or LazySetter) Setter; -typedef (EagerArrowExpression or - LazyArrowExpression) ArrowExpression; +typedef (EagerArrowExpressionWithFunctionBody or + LazyArrowExpressionWithFunctionBody or + EagerArrowExpressionWithExpression or + LazyArrowExpressionWithExpression) ArrowExpression; // bindings @@ -587,26 +589,41 @@

Tree Grammar

// `ArrowFunction`, // `AsyncArrowFunction` -interface EagerArrowExpression : Node { +interface EagerArrowExpressionWithFunctionBody : Node { // True for `AsyncArrowFunction`, false otherwise. attribute boolean isAsync; - // Null if and only if the body is an Expression. - attribute FrozenArray<Directive>? directives; - attribute ArrowExpressionContents contents; + attribute FrozenArray<Directive> directives; + attribute ArrowExpressionContentsWithFunctionBody contents; +}; +interface LazyArrowExpressionWithFunctionBody : Node { + // True for `AsyncArrowFunction`, false otherwise. + attribute boolean isAsync; + attribute FrozenArray<Directive> directives; + [Lazy] attribute ArrowExpressionContentsWithFunctionBody contents; +}; +interface EagerArrowExpressionWithExpression : Node { + // True for `AsyncArrowFunction`, false otherwise. + attribute boolean isAsync; + attribute ArrowExpressionContentsWithExpression contents; }; -interface LazyArrowExpression : Node { +interface LazyArrowExpressionWithExpression : Node { // True for `AsyncArrowFunction`, false otherwise. attribute boolean isAsync; - // Null if and only if the body is an Expression. - attribute FrozenArray<Directive>? directives; - [Lazy] attribute ArrowExpressionContents contents; + [Lazy] attribute ArrowExpressionContentsWithExpression contents; +}; + +interface ArrowExpressionContentsWithFunctionBody : Node { + attribute AssertedParameterScope parameterScope; + attribute FormalParameters params; + attribute AssertedVarScope bodyScope; + attribute FunctionBody body; }; -interface ArrowExpressionContents : Node { +interface ArrowExpressionContentsWithExpression : Node { attribute AssertedParameterScope parameterScope; attribute FormalParameters params; attribute AssertedVarScope bodyScope; - attribute (FunctionBody or Expression) body; + attribute Expression body; }; // `AssignmentExpression :: LeftHandSideExpression = AssignmentExpression`