|From:||Mihai Calin Ghete|
|Subject:||Attribute Grammars in Bison|
|Date:||Fri, 23 Feb 2018 16:38:12 +0100|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0|
Hello,For mymaster's thesis project at the Vienna University of Technology I am adding attribute grammar support to Flex and Bison. Bison already supports semantic actions which are executed during a shift / reduce; the thesisadds the ability to define multipleattributes per symbol and rules to calculate each attribute in part, including dependencies onattributes of the parent or of child nodes. Attributes are calculated as early as possible, but if an attribute depends on another that has not been calculated yet, it is enqueued until calculation becomes possible.
These changes are inspired by Ox, a pre-processor for lex/yacc with largely the same feature set and similar syntax( https://compilers.iecc.com/comparch/article/93-11-100). Ox is currently used together with Flex/Bison to teach the concept of attribute grammars in the compiler construction course at Vienna UT. Work on Ox does not appear to have continued since the 1.04 release in 1994 and Ox itself is not Free software, although the source is available and the program is free to use, see https://www.complang.tuwien.ac.at/ubvl/ox/.
The chosen approach is to build a dependency graph at runtime (during each reduce operation) and evaluate each attribute as soon as all of its dependencies are resolved. This procedure is relatively simple but effective. The evaluator targets the LALR ("yacc.c") and GLR C skeletons.
Would it be of interest to have such functionality as part of mainline Bison?
Kind regards, Mihai
|[Prev in Thread]||Current Thread||[Next in Thread]|