Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a meta-language for formal definitions (#69)
## Summary Implement a meta-language for describing languages' abstract syntax and semantics, using a macro DSL. The source language's textual definition is replaced with a definition using the new meta-language. ## Details The current formal definition has a few problems: * it's not accessible to the computer, preventing mechanization and thus testing/validation * the lack of any form of testing makes it very easy to introduce mistakes (both syntactic and semantic) * the lack of typesetting makes it hard to read for a human reader Using a dedicated meta-language is meant to address the problems listed above. A macro DSL is used instead of a fully-custom language, which has the following benefits: * interop with NimSkull is easy, if needed * the syntax can be built on that of NimSkull without needing a dedicated parser * the output of the macro is readily available at compile-time, making macro-based code generation possible * the build process stays simple The `language` macro only constructs a `Language` instance, which is meant to be passed to further processing (e.g., queries, code generation, rendering, etc.). The textual definition is replaced with a meta-language equivalent. Some small adjustments/clarification are made where needed: * the `l` and `ch` non-terminals; they need a concrete definition * the `E-builtin-readFile` rule uses a placeholder definition, as indeterminate values cannot be described with the meta-language at the moment Substituting identifiers with values (previously denoted by `e[x/v]`) is now fully defined, via the `substitute` meta-function. --------- Co-authored-by: Saem Ghani <[email protected]>
- Loading branch information