Declarative specifications for automatically constructed compilers
暂无分享,去创建一个
Current production compilers are written almost entirely by hand in a procedural language such as C, Pascal, or assembly. An alternative method of building compilers, declarative specifications, has not caught on. Although the theoretic advantages are widely known, declarative techniques are rarely contemplated when a practitioner is faced with producing a compiler. I believe that the main barrier to acceptance is an incorrect perception of the performance of generated compilers.
In this work, I demonstrate the building of the major subtasks of a C compiler with a number of specifications, each matched to its particular subtask. For a given subtask, I show that compared to the conventional handwritten method, a small, concise specification solves the problem. From this specification, a tool can generate code to efficiently carry out the solution. Sometimes the tool needs to be tuned to generate acceptable performance code and I show how this is accomplished. After tuning, comparative performance measurements between the generated compiler and handwritten production compilers are given.
In spite of the voluminous research effort, few truly usable compiler writing systems have emerged. Probably the only widely used system to date is a simple parser generator. Many sophisticated systems have not succeeded in breaking through the barrier between academia and the practical world. Because of the innovative specification techniques, performance measurements, and tool tuning, the practitioner will be better able to produce efficient compilers with considerably less effort than required by the traditional method.