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

Add a wrapper around AST that exposes fields #9

Merged
merged 29 commits into from
Jun 21, 2023
Merged

Conversation

asimpletune
Copy link
Owner

The process for exposing the data that's parsed is a little strange and convoluted. There's an additional "rewriting" step, where the original rfc5322 grammar is rewritten with the help of a metagrammar, and variable names A-Z are assigned to each atom, before being saved. In the same file that coordinates the rewriting, there's the opportunity to rewrite some of those automatically assigned field names to ones that are more easily read.

After this, the resulting rewritten grammar can then be used to generate a new parser, while the original rfc5322 grammar remains untouched.

The reason for doing this is the grammar is too big to easily add computed fields without at the same time making it illegible and basically turning the grammar into a program. It's very important for the original grammar to easily be understandable, but also for there to be an easy way for changes made to it to automatically cause changes downstream.

As a final thought, there are at least big remaining issues left in the project:

  1. There needs to be a lot more tests written, especially around things like obsolete fields
  2. The project needs to reach a baseline acceptable level of tooling, like linters, a tsconfig file, etc...
  3. Nothing special is being done for the body parsing. Some other projects I've seen are able to split the body into several parts, each corresponding to a different content-type. This is more inline with how email works in the real world, although it's probably out of scope for 5322 spec.

…existing grammar and then to automatically generate fields for that
…ssociating which fields to skip for which rules
…ctor to make room for remaining fields yet to be implemented
@asimpletune asimpletune merged commit 6ae31f2 into main Jun 21, 2023
@asimpletune asimpletune deleted the compute-fields branch June 21, 2023 23:50
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