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

Dev/refactor v0.2 #22

Merged
merged 15 commits into from
Apr 20, 2021
Merged

Dev/refactor v0.2 #22

merged 15 commits into from
Apr 20, 2021

Conversation

chifflier
Copy link
Collaborator

This PR is a recap of all pending changes, and a central point to track all issues that will be closed.

Refactor crate:

  • split crate in two (nom-derive and nom-derive-impl) so it can export public items, in particular the Parse trait. This item definition is not yet definitive, but the introduction of different methods parse_be and parse_le may become essential for next versions. For ex, instead of generating parse for a struct, we could generate an implementation of the Parse trait (See Generate implementation of Parse trait, instead of parse method #21)
  • Provide implementation of Parse for primitive types, including primitive arrays (closes Support for primitive arrays #4). Also provide example of newtype pattern to specify different implementations (closes Document how to implement parsers for existing types #16)
  • Refactor argument parsing and code generation. The AST now include all items, and does not handle most attributes as special, and generate code from top to bottom. This means that
    • attributes are now all handled the same way for deriving struct and enum
    • order of attributes is now important
    • it is possible to specify that a field should be first parse then ignored (closes Allow () for Tag #18), or the parse function that will be used with Count (closes Count with Parse #9)
    • endianness is now determined by first looking a field attribute, then object endianness. The code for specifying globally the endianness is present, though the way to configure it (env var?) is not determined. The NomBE and NomLE custom derive attributes have been added, and should make this fairly easy anyway (for ex use nom_derive::NomLE as Nom) (closes Overriding the default endianness #14)
  • Add support for generic type parameters and better support for lifetimes and where clauses
  • Add GenericErrors attribute, to generate a function signature with generic error type (closes Context attribute #19)

Except for the order of attributes, there should be no breaking change.

@chifflier chifflier added this to the 0.8.0 milestone Apr 19, 2021
@chifflier chifflier merged commit ac130f3 into master Apr 20, 2021
@chifflier chifflier deleted the dev/refactor-v0.2 branch May 7, 2021 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants