Open stevefan1999-personal opened 11 months ago
At this time, there is no specific support for this in Hime. You can manually walk the AST/SPPF to reconstruct domain objects. That is what is done in the Hime SDK to load the grammar AST into domain objects for variables, rules, etc. I have other private examples like this.
What could be done for the Rust-specific runtime, is to expose a bunch of traits to mark structures that could be reconstructed from AST/SPPF and use that to produce the domain objects from the AST. Maybe we could hijack serde for this.
The ultimate solution would be to not produce the AST/SPPF at all and use user-configurable logic to build the domain objects, but that is way more complicated.
Ultimately, there is a difference in language theory between the concrete syntax tree, what we call AST/SPPF in Hime, i.e. the tree of tokens in the input ; and the real abstract syntax tree, which is what you mentions, domain objects. Those are separate things and the term AST in a bit of a misnomer in the parser generator ecosystem.
I want to produce my own AST like this:
What is the best way to let us handle the AST forming part?