J-F-Liu / pom

PEG parser combinators using operator overloading without macros.
MIT License
496 stars 30 forks source link

Additional context for Parser #21

Closed MageSlayer closed 5 years ago

MageSlayer commented 5 years ago

Hi

Currently, I am trying to choose some parser library. pom looks nice due to lack of "macros hell" compared to nom. I guess you feel the same :)

However, I have one requirement which spoils all nice code - I must create parsed values inside special allocator/arena object. Thus I need to be able to access it within each and every function returning Parser struct. I guess it's something Serde calls "stateful serialization".

The easiest way to do that is to embed another generic struct field within Parser which would be accessible everywhere somehow - provide additional Parser reference in all combinators or stuff like that. Currently I see no other way to do that but to fork/branch "pom" and thread additional parameter through each combinator.

Could you suggest any other way to avoid forking? BR

J-F-Liu commented 5 years ago

You may send a PR or create a parser like this.

MageSlayer commented 5 years ago

Yeap, looks like the idea of wrapping is quite close to what I need. Thanks a lot.