Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 200 forks source link

copy StringLiteral from benchmark parser #1790

Closed NaridaL closed 2 years ago

NaridaL commented 2 years ago

See https://github.com/Chevrotain/chevrotain/blob/master/packages/chevrotain/benchmark_web/parsers/json/json_parser.js

":?" is an optional :, not a non-capturing group. Additionally, nested + and * lead to terrible performance when not matching.

Fixes #1788

mattbishop commented 2 years ago

Json.org has a bnf describing valid chars. Just use that?

bd82 commented 2 years ago

@mattbishop is correct, we should re-evaluate the regexp from scratch, It is possible I copy pasted it in the past and that it is not fully aligned with the JSON spec.

It may not be a direct 1 to 1 translation as the BNF may not translate to JavaScript regexp directly and JS string quirks.