Skip to content

Commit 88e8835

Browse files
committed
Update README.md
1 parent eedd2be commit 88e8835

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

README.md

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ Node [x]
8686
│ ├─ImportNamespaceSpecifier [v,s]
8787
│ └─ImportSpecifier [v,s]
8888
├─Program : IHoistingScope [v]
89-
│ ├─Module : IHoistingScope [s]
90-
│ └─Script : IHoistingScope [s]
91-
├─Property : IProperty [v]
92-
│ ├─AssignmentProperty : IProperty [s]
93-
│ └─ObjectProperty : IProperty [s]
89+
│ ├─Module : IHoistingScope [s,t=Program]
90+
│ └─Script : IHoistingScope [s,t=Program]
91+
├─Property : IProperty
92+
│ ├─AssignmentProperty : IProperty [v,s,t=Property]
93+
│ └─ObjectProperty : IProperty [v,s,t=Property]
9494
├─RestElement : IDestructuringPatternElement [v,s]
9595
├─StatementOrExpression
9696
│ ├─Expression [x]
@@ -100,7 +100,7 @@ Node [x]
100100
│ │ ├─AwaitExpression [v,s]
101101
│ │ ├─BinaryExpression [v]
102102
│ │ │ ├─LogicalExpression [s]
103-
│ │ │ └─NonLogicalBinaryExpression [s]
103+
│ │ │ └─NonLogicalBinaryExpression [s,t=BinaryExpression]
104104
│ │ ├─CallExpression : IChainElement [v,s]
105105
│ │ ├─ChainExpression [v,s]
106106
│ │ ├─ClassExpression : IClass [v,s]
@@ -109,12 +109,12 @@ Node [x]
109109
│ │ ├─Identifier : IDestructuringPatternElement [v,s]
110110
│ │ ├─ImportExpression [v,s]
111111
│ │ ├─Literal [v]
112-
│ │ │ ├─BigIntLiteral [s]
113-
│ │ │ ├─BooleanLiteral [s]
114-
│ │ │ ├─NullLiteral [s]
115-
│ │ │ ├─NumericLiteral [s]
116-
│ │ │ ├─RegExpLiteral [s]
117-
│ │ │ └─StringLiteral [s]
112+
│ │ │ ├─BigIntLiteral [s,t=Literal]
113+
│ │ │ ├─BooleanLiteral [s,t=Literal]
114+
│ │ │ ├─NullLiteral [s,t=Literal]
115+
│ │ │ ├─NumericLiteral [s,t=Literal]
116+
│ │ │ ├─RegExpLiteral [s,t=Literal]
117+
│ │ │ └─StringLiteral [s,t=Literal]
118118
│ │ ├─MemberExpression : IChainElement, IDestructuringPatternElement [v,s]
119119
│ │ ├─MetaProperty [v,s]
120120
│ │ ├─NewExpression [v,s]
@@ -128,13 +128,13 @@ Node [x]
128128
│ │ ├─TemplateLiteral [v,s]
129129
│ │ ├─ThisExpression [v,s]
130130
│ │ ├─UnaryExpression [v]
131-
│ │ │ ├─NonUpdateUnaryExpression [s]
131+
│ │ │ ├─NonUpdateUnaryExpression [s,t=UnaryExpression]
132132
│ │ │ └─UpdateExpression [s]
133133
│ │ └─YieldExpression [v,s]
134134
│ └─Statement [x]
135135
│ ├─BlockStatement [v]
136-
│ │ ├─FunctionBody : IHoistingScope [s]
137-
│ │ ├─NestedBlockStatement [s]
136+
│ │ ├─FunctionBody : IHoistingScope [v,s,t=BlockStatement]
137+
│ │ ├─NestedBlockStatement [s,t=BlockStatement]
138138
│ │ └─StaticBlock : IClassElement, IHoistingScope [v,s]
139139
│ ├─BreakStatement [v,s]
140140
│ ├─ContinueStatement [v,s]
@@ -152,8 +152,8 @@ Node [x]
152152
│ ├─DoWhileStatement [v,s]
153153
│ ├─EmptyStatement [v,s]
154154
│ ├─ExpressionStatement [v]
155-
│ │ ├─Directive [s]
156-
│ │ └─NonSpecialExpressionStatement [s]
155+
│ │ ├─Directive [s,t=ExpressionStatement]
156+
│ │ └─NonSpecialExpressionStatement [s,t=ExpressionStatement]
157157
│ ├─ForInStatement [v,s]
158158
│ ├─ForOfStatement [v,s]
159159
│ ├─ForStatement [v,s]
@@ -173,8 +173,54 @@ Node [x]
173173
Legend:
174174
* `v` - A visitation method is generated in the visitors for the node type.
175175
* `s` - The node class is sealed. (It's [beneficial to check for sealed types](https://www.meziantou.net/performance-benefits-of-sealed-class.htm#casting-objects-is-a) when possible.)
176+
* `t` - The node type (the value of the `Node.Type` property) as specified by ESTree (shown only if it differs from the name of the node class).
176177
* `x` - The node class can be subclassed. (The AST provides some limited extensibility for special use cases.)
177178

179+
### JSX
180+
181+
The library also supports the syntax extensions [JSX](https://facebook.github.io/jsx/).
182+
However, mostly for performance reasons, the related functionality is separated from the core parser: it is available in the `Acornima.Extras` package, in the `Acornima.Jsx` namespace.
183+
184+
#### Installation & usage
185+
186+
After installing the `Acornima.Extras` package as described in the [Getting started](#getting-started) section, you can parse JSX code like this:
187+
188+
```csharp
189+
using Acornima.Jsx;
190+
191+
var parser = new JsxParser(new JsxParserOptions { /* ... */ });
192+
193+
var ast = parser.ParseScript("<>Hello world!</>");
194+
```
195+
196+
#### AST
197+
198+
```
199+
Node [x]
200+
└─StatementOrExpression
201+
└─Expression [x]
202+
└─JsxNode [x]
203+
├─JsxAttributeLike
204+
│ ├─JsxAttribute [v,s]
205+
│ └─JsxSpreadAttribute [v,s]
206+
├─JsxClosingTag
207+
│ ├─JsxClosingElement [v,s]
208+
│ └─JsxClosingFragment [v,s]
209+
├─JsxElementOrFragment
210+
│ ├─JsxElement [v,s]
211+
│ └─JsxFragment [v,s]
212+
├─JsxEmptyExpression [v,s]
213+
├─JsxExpressionContainer [v,s]
214+
├─JsxName
215+
│ ├─JsxIdentifier [v,s]
216+
│ ├─JsxMemberExpression [v,s]
217+
│ └─JsxNamespacedName [v,s]
218+
├─JsxOpeningTag
219+
│ ├─JsxOpeningElement [v,s]
220+
│ └─JsxOpeningFragment [v,s]
221+
└─JsxText [v,s]
222+
```
223+
178224
### Benchmarks
179225

180226
| Method | Runtime | FileName | Mean | Allocated |

0 commit comments

Comments
 (0)