Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Correctly capture a number negation prefix #45

Merged
merged 1 commit into from
Sep 26, 2023
Merged
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
13 changes: 11 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,23 @@ <h1>
<emu-alg>
1. Let _F_ be the active function object.
1. Assert: _F_ is a `JSON.parse` built-in function object (see <emu-xref href="#sec-json.parse">JSON.parse</emu-xref>).
1. Let _types_ be &laquo; |NullLiteral|, |BooleanLiteral|, |NumericLiteral|, |StringLiteral|, |ArrayLiteral|, |ObjectLiteral| &raquo;.
1. Let _types_ be &laquo; |NullLiteral|, |BooleanLiteral|, |NumericLiteral|, |StringLiteral|, |ArrayLiteral|, |ObjectLiteral|, |UnaryExpression| &raquo;.
1. Let _unaryExpression_ be ~empty~.
1. Let _queue_ be &laquo; this Parse Node &raquo;.
1. Repeat, while _queue_ is not empty,
1. Let _candidate_ be the first element of _queue_.
1. Remove the first element from _queue_.
1. Let _queuedChildren_ be *false*.
1. For each nonterminal _type_ of _types_, do
1. If _candidate_ is an instance of _type_, return _candidate_.
1. If _candidate_ is an instance of _type_, then
1. NOTE: In the JSON grammar, a <code>number</code> token may represent a negative value. In ECMAScript, negation is represented as a unary operation.
1. If _type_ is |UnaryExpression|, then
1. Set _unaryExpression_ to _candidate_.
1. Else if _type_ is |NumericLiteral|, then
1. Assert: _unaryExpression_ Contains _candidate_ is *true*.
1. Return _unaryExpression_.
1. Else,
1. Return _candidate_.
1. If _queuedChildren_ is *false* and _candidate_ is an instance of a nonterminal and _candidate_ Contains _type_ is *true*, then
1. Let _children_ be a List containing each child node of _candidate_, in order.
1. Set _queue_ to the list-concatenation of _queue_ and _children_.
Expand Down
Loading