Download Language development case study (Pdf, 133 pages)
Transcript
Abstract rdp is a system for implementing language processors. It accepts a specication, written in an extended Backus-Naur Form, of a source language and produces as output a parser for the language, written in C. It is possible for the user to specify, in C, actions which should be taken when fragments of the source language are recognised by the generated parser. rdp produces as output a program written in C, which parses fragments of the specied language and carries out the specied corresponding actions. rdp can produce, for example, compilers (the actions specify the corresponding target code), interpreters (the actions evaluate the input fragments) and pretty printers (the actions reformat the input fragments). This report describes the design and implementation of a family of language translators based around a simple procedural programming language called mini. The tools covered include two dierent interpreters, an assembler, a simulator for an idealised processor, a nave single-pass compiler for that processor, and a multiple-pass compiler. We also include a pretty printer for ANSI-C and a list of sugestions for further project work. For each tool, we look at how the tool is used before covering the design and implementation of the translator. All of the tools are included in the rdp standard distribution pack and have been tested on MS-DOS, Windows-95 and Unix systems. The rdp source code is public domain and has been successfully built using Borland C++ version 3.1 and Microsoft C++ version 7 on MS-DOS, Borland C++ version 5.1 on Windows-95, GNU gcc and g++ running on OSF/1, Ultrix, MS-DOS, Linux and SunOS, and a variety of vendor's own C compilers. Users have also reported straightforward ports to the Amiga, Macintosh and Archimedes systems. This document is c Adrian Johnstone and Elizabeth Scott 1997. Permission is given to freely distribute this document electronically and on paper. You may not change this document or incorporate parts of it in other documents: it must be distributed intact. The rdp system itself is c Adrian Johnstone but may be freely copied and modied on condition that details of the modications are sent to the copyright holder with permission to include such modications in future versions and to discuss them (with acknowledgement) in future publications. The version of rdp described here is version 1.50 dated 20 December 1997. Please send bug reports and copies of modications to the authors at the address on the title page or electronically to [email protected].