-
Notifications
You must be signed in to change notification settings - Fork 653
Conversation
@@ -691,14 +692,7 @@ impl<'src> Lexer<'src> { | |||
KeywordMatcher::Null => NULL_KW, | |||
KeywordMatcher::True => TRUE_KW, | |||
KeywordMatcher::False => FALSE_KW, | |||
_ => { | |||
self.diagnostics.push(ParseDiagnostic::new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parser emits diagnostics for identifiers.
d596ea1
to
df1d539
Compare
ed401b2
to
eca6a40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular concerns, I went through some snapshots to see the errors.
crates/rome_json_parser/tests/json_test_suite/err/array_1_true_without_comma.json.snap
Show resolved
Hide resolved
json_member_list: JsonMemberList [ | ||
missing element, | ||
COMMA@1..2 "," [] [], | ||
missing element, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to have a missing element here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because JSON doesn't allow trailing commas.
crates/rome_json_parser/tests/json_test_suite/err/string_single_quote.json.snap
Outdated
Show resolved
Hide resolved
eca6a40
to
629dfc8
Compare
✅ Deploy Preview for docs-rometools canceled.
|
Comparing feat(rome_json_parser): JSON Parser Snapshot #2 to median since last deploy of rome.tools.
1 page tested
|
Chrome Desktop | iPhone, 4G LTE | Motorola Moto G Power, 3G connection |
---|---|---|
Most significant changes
27 other significant changes: JS Parse & Compile on Chrome Desktop, Total Blocking Time on Chrome Desktop, Largest Contentful Paint on Motorola Moto G Power, 3G connection, First Contentful Paint on Motorola Moto G Power, 3G connection, Total CSS Size in Bytes on Chrome Desktop, Total CSS Size in Bytes on iPhone, 4G LTE, Total CSS Size in Bytes on Motorola Moto G Power, 3G connection, Time to Interactive on Motorola Moto G Power, 3G connection, Total Page Size in Bytes on Chrome Desktop, Total Page Size in Bytes on iPhone, 4G LTE, Total Page Size in Bytes on Motorola Moto G Power, 3G connection, Largest Contentful Paint on Chrome Desktop, First Contentful Paint on Chrome Desktop, Time to Interactive on Chrome Desktop, Number of Requests on Motorola Moto G Power, 3G connection, Number of Requests on Chrome Desktop, Number of Requests on iPhone, 4G LTE, Speed Index on Motorola Moto G Power, 3G connection, Time to Interactive on iPhone, 4G LTE, First Contentful Paint on iPhone, 4G LTE, Largest Contentful Paint on iPhone, 4G LTE, Speed Index on Chrome Desktop, Total HTML Size in Bytes on Chrome Desktop, Total HTML Size in Bytes on iPhone, 4G LTE, Total HTML Size in Bytes on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Chrome Desktop
Calibre: Site dashboard | View this PR | Edit settings | View documentation
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
629dfc8
to
bc15476
Compare
Summary
This PR implements a JSON parser. Closes #2351
Comments
The parser handles comments as regular tokens to make use of the syntax factories's automatic conversion to unknown if a node contains any comments. We may change comments to trivia at a later time for all json dialects or only for those supporting comments.
Test Plan
I updated the snapshot tests and reviewed them manually.
I added an assertion to the snapshot tests to flag if:
I had to delete two tests that tested very deep object and array structures with missing closing parentheses (1 million open
[
without any closing]
). The parser can handle this, but our diagnostics printer runs into a stack overflow 😆