This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Grammar: Support strict UTF-8 strings and be strict regarding numbers #18
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We avoid using `\d` instead of `[0-9]` because `\d` _might_ match other characters.
Please @Jir4 or @jubianchi, can you review it? |
UTF-8 is an issue with JSON, because we must handle surrogate pairs ([1], [2]). This patch implements UTF-8 not only for validating a datum but also for generating a datum. It means that we only generate valid UTF-8 strings and we only validate/recognize valid UTF-8 strings. UTF-16 strings will follow in another patch. Unfortunately, we decided to implement the whole string as a token, not as rules. This is unfortunate because grammar coverage algorithms in `Hoa\Compiler` applies only on rules, not on tokens. This is a potential optimisation. [1]: http://tools.ietf.org/html/rfc7159#section-7 [2]: http://tools.ietf.org/html/rfc7159#section-8
Inspiration from https://github.com/php/php-src/blob/71c19800258ee3a9548af9a5e64ab0a62d1b1d8e/ext/json/json_scanner.re (and fixing a bug there, need to report it). |
Umh ok, i'll review the first part and @jubianchi the second 😅 |
Hywan
changed the title
Grammar: Suport UTF-8 strings and be strict regarding numbers
Grammar: Suport strict UTF-8 strings and be strict regarding numbers
Feb 8, 2016
Hywan
changed the title
Grammar: Suport strict UTF-8 strings and be strict regarding numbers
Grammar: Support strict UTF-8 strings and be strict regarding numbers
Feb 8, 2016
Patches updated to support |
JSON grammar is $LL(k=0)$. This is good for performance to fix $k$ to $0$, it avoids potential useless lookahead and it will fail early.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix partially #17.
Regarding numbers:
Regarding strings:
Now we have 159876 assertions!