From 38b4965897815fa2453c5a9950056d599b023ac3 Mon Sep 17 00:00:00 2001 From: Clement Hoang Date: Tue, 7 Nov 2017 02:50:21 +0000 Subject: [PATCH 1/3] Update spec with jsx generation expressions --- AST.md | 15 ++++----------- README.md | 14 ++++++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/AST.md b/AST.md index 7555620..6d05197 100644 --- a/AST.md +++ b/AST.md @@ -39,20 +39,13 @@ interface JSXNamespacedName <: Expression { JSX Expression Container ------------------------ -JSX adds empty "expression" type in order to allow comments in JSX text: +The expression container node contains statements with the same grammar as a generator body. Also it has a flag to indicate if a yield is present in the body. Any expression used as attribute value or inside JSX text should is wrapped into expression container: ```js -interface JSXEmptyExpression <: Node { - type: "JSXEmptyExpression"; -} -``` - -Any expression used as attribute value or inside JSX text should is wrapped into expression container: - -```js -interface JSXExpressionContainer <: Node { +interface JSXExpressionContainer <: Expression { type: "JSXExpressionContainer"; - expression: Expression | JSXEmptyExpression; + statements: [ Statement | Declaration ]; + hasYield: boolean; } ``` diff --git a/README.md b/README.md index 1a67818..c9eec77 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ PrimaryExpression : - JSXElement - JSXFragment +- JSXGeneratorExpression __Elements__ @@ -95,7 +96,7 @@ JSXAttributes :
 JSXSpreadAttribute : -- `{` `...` AssignmentExpression `}` +- `{` `...` JSXGeneratorExpression `}` JSXAttribute :
 @@ -114,10 +115,15 @@ JSXAttributeValue :
 - `"` JSXDoubleStringCharactersopt `"` - `'` JSXSingleStringCharactersopt `'` -- `{` AssignmentExpression `}` +- `{` JSXGeneratorExpression `}` - JSXElement - JSXFragment +JSXGeneratorExpression : + +- [lookahead ∈ { `{` }] ObjectLiteral +- StatementList[+Yield] + JSXDoubleStringCharacters :
 - JSXDoubleStringCharacter JSXDoubleStringCharactersopt @@ -157,8 +163,8 @@ JSXTextCharacter : JSXChildExpression : -- AssignmentExpression -- `...` AssignmentExpression +- JSXGeneratorExpression +- `...` JSXGeneratorExpression __Whitespace and Comments__ From 8747532c0515c946a2b55483a25531e7515f8948 Mon Sep 17 00:00:00 2001 From: Clement Hoang Date: Thu, 9 Nov 2017 08:21:26 +0000 Subject: [PATCH 2/3] Add suggested changes to spec for JSX Generator Expressions --- AST.md | 16 ++++++++++++---- README.md | 12 ++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/AST.md b/AST.md index 6d05197..3a5e475 100644 --- a/AST.md +++ b/AST.md @@ -39,13 +39,21 @@ interface JSXNamespacedName <: Expression { JSX Expression Container ------------------------ -The expression container node contains statements with the same grammar as a generator body. Also it has a flag to indicate if a yield is present in the body. Any expression used as attribute value or inside JSX text should is wrapped into expression container: +The expression container node contains statements with the same grammar as a generator body. Also it has a flag to indicate whether it is an expression. Any expression used as attribute value or inside JSX text should be wrapped by expression container: ```js -interface JSXExpressionContainer <: Expression { +interface JSXExpressionContainer <: Node { type: "JSXExpressionContainer"; - statements: [ Statement | Declaration ]; - hasYield: boolean; + body: Expression | JSXEmptyExpression | JSXStatementList; + expression: boolean; +} +``` + +```js +interface JSXStatementList <: Node { + type: "JSXStatementList"; + body: [ Statement ]; + generator: boolean; } ``` diff --git a/README.md b/README.md index c9eec77..8df7da9 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ JSXAttributes :
 JSXSpreadAttribute : -- `{` `...` JSXGeneratorExpression `}` +- `{` `...` AssignmentExpression `}` JSXAttribute :
 @@ -121,8 +121,12 @@ JSXAttributeValue :
 JSXGeneratorExpression : -- [lookahead ∈ { `{` }] ObjectLiteral -- StatementList[+Yield] +- ObjectLiteral +- FunctionExpression +- ClassExpression +- GeneratorExpression +- AsyncFunctionExpression +- [lookahead ∉ { `{` }] StatementList[+Yield] JSXDoubleStringCharacters :
 @@ -164,7 +168,7 @@ JSXTextCharacter : JSXChildExpression : - JSXGeneratorExpression -- `...` JSXGeneratorExpression +- `...` AssignmentExpression __Whitespace and Comments__ From eeb2364b1ea488f044d4f17d24baaf00354549de Mon Sep 17 00:00:00 2001 From: Clement Hoang Date: Thu, 9 Nov 2017 08:43:19 +0000 Subject: [PATCH 3/3] Update AST.md --- AST.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AST.md b/AST.md index 3a5e475..6bb14a1 100644 --- a/AST.md +++ b/AST.md @@ -44,8 +44,8 @@ The expression container node contains statements with the same grammar as a gen ```js interface JSXExpressionContainer <: Node { type: "JSXExpressionContainer"; - body: Expression | JSXEmptyExpression | JSXStatementList; - expression: boolean; + expression: Expression | JSXEmptyExpression | JSXStatementList; + isExpression: boolean; } ```