Comments (2)
Here's my review. I just have a couple editorial comments.
The ShallowestContained algorithm doesn't work in general. It may happen to work for the JSON subset, but it forms an attractive nuisance that hides land mines for others who might call it in the future. For example,
ShallowestContained called on the parse of "class C {x=4; [true]=8}" with types «NumericLiteral» doesn't find any numeric literals. But if we add searching for an unrelated nonterminal, it suddenly starts to find them:
ShallowestContained called on the parse of "class C {x=4; [true]=8}" with types «NumericLiteral, BooleanLiteral» finds the numeric literal 4.
ArrayElementList is a bit broken in general too. If elisions are present, the length of the list generated by ArrayElementList is not necessarily equal to the array's length because a single Elision can contain multiple commas but ArrayElementList treats it as a single element. However, the JSON syntax doesn't allow elisions, so it happens to work on JSON arrays.
Possible solutions are to either fix these so they work in general or rename them so it's clear they are only usable on JSON objects.
from proposal-json-parse-with-source.
The ShallowestContained algorithm doesn't work in general. It may happen to work for the JSON subset, but it forms an attractive nuisance that hides land mines for others who might call it in the future. For example,
ShallowestContained called on the parse of "class C {x=4; [true]=8}" with types «NumericLiteral» doesn't find any numeric literals. But if we add searching for an unrelated nonterminal, it suddenly starts to find them: ShallowestContained called on the parse of "class C {x=4; [true]=8}" with types «NumericLiteral, BooleanLiteral» finds the numeric literal 4.
Thank you, this is an excellent point. Please review #30, which renames the operation to ShallowestContainedJSONValue and narrows its use to JSON.parse
.
ArrayElementList is a bit broken in general too. If elisions are present, the length of the list generated by ArrayElementList is not necessarily equal to the array's length because a single Elision can contain multiple commas but ArrayElementList treats it as a single element. However, the JSON syntax doesn't allow elisions, so it happens to work on JSON arrays.
This behavior is intentional, although the length assertion is indeed specific to JSON.parse
. For clarity, I have renamed the operation to ArrayLiteralContentNodes in #31.
from proposal-json-parse-with-source.
Related Issues (20)
- Expose position and/or input of source text? HOT 12
- Supply an array of keys for understanding value context? HOT 3
- Extend this proposal to include serialization? HOT 10
- Advance to stage 3 HOT 3
- Advance to stage 4 HOT 3
- performance impact with 1-million json.parse calls HOT 1
- bigint ergonomics of user-function vs options-object HOT 1
- bikeshedding the mechanism for serialization HOT 7
- Reusability of raw serialization mechanism HOT 2
- Should reviver functions still get a context argument for non-primitive values? HOT 1
- Naming of raw text placeholder
- Stage 3 Specification Review: Michael Ficarra HOT 1
- How to parse bigints when using Response.json() function? HOT 2
- Assert failed for typedValNode is an ObjectLiteral Parse Node
- Are there any implementations yet? HOT 2
- Bug in `intToBigInt`? HOT 2
- Reviver can modify holder object, like inserting new object / array, which breaks invariant of parsing information HOT 6
- A polyfill/ponyfill implementation HOT 11
- How to reference JSON parse nodes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-json-parse-with-source.