15

Dave Prosser's C Preprocessing Algorithm

 4 years ago
source link: https://www.spinellis.gr/blog/20060626/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

For about five years I've been trying to implement a fully conforming C preprocessor for the front end of theCScout refactoring browser. I've found this to be a fiendishly difficult task. Although what I have written can correctly process million-line real-life projects, every once in a while I come across a construct that confuses my implementation. While searching the web for explanations of some of the finer points of the C standard I came across a reference to an algorithm by Dave Prosser that the X3J11 (ANSI C standard) committee used as a basis for the standard's wording.

I could not find the algorithm published or online, but following an email Dave kindly dug in his files, and sent me the original troff source and an ASCII document with some explanations and two bug fixes. I used the ASCII document to create an updated version of the original document. Dave also gave me permission to put the algorithm online, so here are the two versions typeset into PDF.

Read and post comments , or share through   

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK