Skip to content

Conversation

@bal-e
Copy link
Contributor

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

No description provided.

- '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
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
@bal-e
Copy link
Contributor Author

bal-e commented Mar 4, 2025

Closing in favor of #491.

@bal-e bal-e closed this Mar 4, 2025
@partim partim deleted the reparse branch March 20, 2025 12:34
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