Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions AST.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ 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 whether it is an expression. Any expression used as attribute value or inside JSX text should be wrapped by expression container:

```js
interface JSXEmptyExpression <: Node {
type: "JSXEmptyExpression";
interface JSXExpressionContainer <: Node {
type: "JSXExpressionContainer";
expression: Expression | JSXEmptyExpression | JSXStatementList;
isExpression: boolean;
}
```

Any expression used as attribute value or inside JSX text should is wrapped into expression container:

```js
interface JSXExpressionContainer <: Node {
type: "JSXExpressionContainer";
expression: Expression | JSXEmptyExpression;
interface JSXStatementList <: Node {
type: "JSXStatementList";
body: [ Statement ];
generator: boolean;
}
```

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ PrimaryExpression :

- JSXElement
- JSXFragment
- JSXGeneratorExpression

__Elements__

Expand Down Expand Up @@ -114,10 +115,19 @@ JSXAttributeValue :


- `"` JSXDoubleStringCharacters<sub>opt</sub> `"`
- `'` JSXSingleStringCharacters<sub>opt</sub> `'`
- `{` AssignmentExpression `}`
- `{` JSXGeneratorExpression `}`
- JSXElement
- JSXFragment

JSXGeneratorExpression :

- ObjectLiteral
- FunctionExpression
- ClassExpression
- GeneratorExpression
- AsyncFunctionExpression
- [lookahead &#8713; { `{` }] StatementList<sub>[+Yield]</sub>

JSXDoubleStringCharacters :


- JSXDoubleStringCharacter JSXDoubleStringCharacters<sub>opt</sub>
Expand Down Expand Up @@ -157,7 +167,7 @@ JSXTextCharacter :

JSXChildExpression :

- AssignmentExpression
- JSXGeneratorExpression
- `...` AssignmentExpression

__Whitespace and Comments__
Expand Down