Skip to content

Commit 0cb1856

Browse files
committed
update ast.md
1 parent ba4dd3e commit 0cb1856

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Diff for: docs/AST.md

+23
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface JSONLiteralBase extends BaseJSONNode {
5353
| JSONProperty
5454
| JSONExpressionStatement
5555
| JSONUnaryExpression
56+
| JSONBinaryExpression
5657
}
5758
```
5859

@@ -101,6 +102,7 @@ export type JSONExpression =
101102
| JSONUnaryExpression
102103
| ( JSONIdentifier & { name: "Infinity" | "NaN" | "undefined" } )
103104
| JSONTemplateLiteral
105+
| JSONBinaryExpression
104106
```
105107
106108
This parser can parse `"Infinity"`, `"NaN"` and `"undefined"` as values. But you can't use these values in actual JSON, JSONC and JSON5.
@@ -162,6 +164,27 @@ This node is [UnaryExpression](https://github.com/estree/estree/blob/master/es5.
162164

163165
Only `"-"` can be used by `operator` in JSON and JSONC.
164166

167+
### JSONBinaryExpression
168+
169+
```ts
170+
export interface JSONUnaryExpression extends BaseJSONNode {
171+
type: "JSONBinaryExpression"
172+
operator: "-" | "+" | "*" | "/" | "%" | "**"
173+
left: JSONNumberLiteral | JSONUnaryExpression | JSONBinaryExpression
174+
right: JSONNumberLiteral | JSONUnaryExpression | JSONBinaryExpression
175+
parent:
176+
| JSONArrayExpression
177+
| JSONProperty
178+
| JSONExpressionStatement
179+
| JSONUnaryExpression
180+
| JSONBinaryExpression
181+
}
182+
```
183+
184+
This node is [BinaryExpression](https://github.com/estree/estree/blob/master/es5.md#binaryexpression) for JSON.
185+
186+
This parser can only parse binary expressions of static numbers. You cannot use binary expressions in actual JSON, JSONC and JSON5.
187+
165188
## Statements
166189

167190
### JSONExpressionStatement

0 commit comments

Comments
 (0)