Skip to content
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
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Overhaul parsing from the presentation format #388

wants to merge 8 commits into from

Conversation

bal-e
Copy link
Contributor

@bal-e bal-e commented Sep 12, 2024

No description provided.

arya dradjica added 6 commits September 12, 2024 13:36
- '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'.
@bal-e bal-e self-assigned this Sep 12, 2024
arya dradjica added 2 commits September 13, 2024 11:07
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.
@bal-e bal-e mentioned this pull request Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant