The Parser

Rather than write my own parser for this project, which would obviously be a huge undertaking, I decided that it would be far more sensible to make use of an existing parsing system. My program requires only a small subset of the information that a full parser extracts from a program, and so the criticism could perhaps be made that making use of a full parsing system is a gross inefficiency. However, using an existing parsing system, and minimising the changes that need to be made to it, makes my program more flexible. If the language is changed or spawns new dialects in the future, or the parser requires bug fixes, it should be relatively simple to use my program with the new version. Also, the use of an established parser means that there are unlikely to be bugs present, and the fewer changes made to it, the less chance that new bugs will be introduced.

The system I chose was the GNU C compiler [14]. The gcc has established itself as the standard C compiler for Unix systems, and so its behaviour will be familiar to the vast majority of programs, and it should work with the vast majority of programs. The variant of gcc for the C++ language is called g++ . The disadvantage of g++ is that it is such a large and complicated system, and hence extracting just the components that are required for my program to work is that much more difficult. Rather than adopt that strategy, I decided simply to modify g++ to send data to my program via a Unix pipe, while maintaining its role of providing full compilation of the program all the way to an executable program. This would mean that the user would not need two versions of g++--they could simply replace the existing version of g++ with the modified version. The navigator relies on the program using the standard Unix make utility, by having a makefile which controls how the program is compiled. When the navigator needs to read in a program, it can make small modifications to the makefile, so that any invocations of g++ are given options that signal to it that it should output data, and specify a pathname for the pipe that should be used for the output. It then invokes the makefile, which compiles the program to the final executable while simultaneously sending data to the navigator.

Matthew Exon 2004-05-28