Skip to content

Commit

Permalink
Normative: Correctly capture a number negation prefix
Browse files Browse the repository at this point in the history
Fixes #44
  • Loading branch information
gibson042 committed Sep 26, 2023
1 parent f2305b8 commit c448ee1
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit c448ee1

Please sign in to comment.