Ox generalizes the function of Yacc in the way that attribute grammars generalize context-free grammars. Ordinary Yacc and Lex specifications may be augmented with definitions of synthesized and inherited attributes written in C syntax. From these specifications, Ox generates a program that builds and decorates attributed parse trees. Ox accepts a most general class of attribute grammars. The user may specify postdecoration traversals for easy ordering of side effects such as code generation. Ox handles the tedious and error-prone details of writing code for parse-tree management, so its use eases problems of security and maintainability associated with that aspect of translator development. The translators generated by Ox use internal memory management that is often much faster than the common technique of calling malloc once for each parse-tree node. Ox is a Yacc/Lex/C preprocessor, and is designed to bring attribute grammars closer to the mainstream of Unix-based language development. Ox inherits all of the familiar syntax and semantics of Yacc, Lex, and C. It is relatively easy to convert programs between Ox code and "pure Yacc/Lex/C" code. Ox has been used to build a compiler for a small (eighty grammar rules) block-structured imperative programming language. This paper considers Ox's design, implementation, and use, evaluates the performance of Ox-generated evaluators, and makes recommendations for improvements in Ox. Disciplines Programming Languages and Compilers This article is available at Iowa State University Digital Repository: http://lib.dr.iastate.edu/cs_techreports/23 Design, Implementation, Use, and Evaluation of Ox: An Attribute-Grammar Compiling System based on Yacc, Lex, and C by Kurt M. Bischo TR#92-31 December, 1992 Department of Computer Science 226 Atanaso Hall Iowa State University Ames, Iowa 50011 c 1992 Kurt M. Bischo
[1]
JazayeriMehdi,et al.
The intrinsically exponential complexity of the circularity problem for attribute grammars
,
1975
.
[2]
Donald E. Knuth.
The art of computer programming: fundamental algorithms
,
1969
.
[3]
Pierre Deransart,et al.
Attribute Grammars: Definitions, Systems and Bibliography
,
1988
.
[4]
Bjarne Stroustrup,et al.
C++ Programming Language
,
1986,
IEEE Softw..
[5]
Alfred V. Aho,et al.
Compilers: Principles, Techniques, and Tools
,
1986,
Addison-Wesley series in computer science / World student series edition.
[6]
E. Schmidt,et al.
Lex—a lexical analyzer generator
,
1990
.
[7]
Jan van Katwijk.
A preprocessor for YACC or a poor man's approach to parsing attributed grammars
,
1983,
SIGP.