|
|
|
|
|
by chubot
2853 days ago
|
|
The process of creating the parser went very smoothly thanks to this. The real work involves creating C# syntax classes that mirror the grammar. These classes form the Abstract Syntax Tree (AST) of the compiler. To address this problem, I use Zephyr ASDL to describe the abstract syntax of a language (which CPython also uses!) It's a little DSL that lets you write an ML-style algebraic data type, and generates a bunch of code for you. In CPython, you go from ~100 lines ASDL schema to ~10,000 lines of C! It underlies the 'ast' module in the stdlib. Why is Zephyr ASDL? http://www.oilshell.org/blog/2016/12/11.html It eliminates the need for a lot of boilerplate he pointed out: https://github.com/praeclarum/CLanguage/tree/master/CLanguag... |
|
[1] http://jastadd.org/web/documentation/concept-overview.php
[2] https://en.wikipedia.org/wiki/Attribute_grammar