-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul parsing from the presentation format #388
Draft
bal-e
wants to merge
8
commits into
main
Choose a base branch
from
reparse
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
- 'Tokenizer' works on UTF-8 strings rather than byte slices, so it does not have to perform any UTF-8 decoding itself. - 'Tokenizer' always provides entire tokens rather than individual symbols. Most of the time, symbols will be regular characters, so users shouldn't have to individually branch on each character. - Because the interpretation of escapes can vary depending on the semantic element (e.g. escaped vs. unescaped dots in domain names), tokens just provide the raw underlying string by default. Semantic element parsers are expected to validate tokens themselves, and will be able to use helper methods on 'Token' to process escapes.
This hopefully comprehensive algorithm deals with quoted strings and escaped characters therein as well as it can. Of particular note is the way it tries to insert newline tokens so that entries on different lines can be distinguished. It's difficult to do this for the last line of the file, so we don't try.
'Tokenizer::next()' is now an inherent method. It correctly increments the position counter after a token is output. It also ensures that no token contains invalid (non-printable) ASCII text. 'Token' now provides 'process()' which will handle escape sequences. For some elements (e.g. domain names), 'process()' is called _after_ some analysis of the raw text is performed. 'Scan' has now been rewritten in terms of 'Tokenizer'. The existing impls have been migrated over as well, and are much simpler. The next step is to update all the uses of the 'Scan' trait in other 'base' modules. After that, we can address 'zonefile'.
Given that the consumer function often just appends slices to a buffer, this version should be significantly more efficient. It re-uses slices of the original input in all cases except a '\DDD' escaped octet.
The major work here is implementing 'Scan' for absolute domain names. This integrates work from 'Name::from_symbols' and 'NameBuilder' into a single unified package, making it significantly easier to work with.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.