-
Notifications
You must be signed in to change notification settings - Fork 165
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
Interfaces: More flexible abstract syntax binding instead of define
?
#267
Comments
I love when one solution addresses many needs! Would this be an alternative to the GADT and functor implementations? Or would those become alternative default implementations under this design? I presume this design will allow for position information, is that correct? In terms of ease of use (edit: and/or error handling, printing, etc.) how do you think it compares with, say, using the current design and splitting the interpreter/compiler up into two parts:
|
This is an issue to contemplate a more flexible handling of LBNF rules in the backend. Currently there is a
define
pragma that allows rule names to be first-order functions over other rule names. However, this could be obsolete if we produced only an interface for abstract syntax (with a standard implementation) that could be implemented in different ways.The interface would defined methods to construct abstract syntax and a view on abstract syntax for the pretty printer.
For example, consider the (ambiguous) LBNF grammar:
In Haskell, this could be represented by the following abstract syntax:
One could also make an instance that directly evaluates programs:
Basically, this is generating a standard interface to what are semantic actions of conventional parser generators.
Advantages:
define
(see also Some backends do not implement thedefine
pragma #266)Issue:
This can be an issue, but also an advantage, since the grammar can be studied by itself without being interleaved with the semantic actions. This is in the spirit of BNFC.
Disadvantage:
define
.The text was updated successfully, but these errors were encountered: