But in most cases of preprocessing the user is given

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ing it, optimizing its performance, documenting it, and otherwise perfecting it. Thus subprograms often are very well written and documented parts of a program. Preprocessor A standard programming language is often extended to support features needed by a specific user group. For example, a user group frequently dealing with a special type of input data or a special type of input device may like to have statements to directly accept this input. In this case, a standard language, which is most suitable for the user group applications, can be extended to have statements to support this. With this extension, the users can program their applications more easily. However, since the extended features (additional statements) are not supported in the original standard language, a language processor is needed that translates the additional statements (extensions to the standard language) into a sequence of statements of the standard language before the program can be successfully compiled by the standard language compiler. Such a language processor is known as a preprocessor. As shown in Figure 12.26, a preprocessor accepts as input a source program written in an extended language (with the added features) and produces an output source program that is acceptable to the compiler of the standard language (without the added features). The preprocessor reads each statement in the input source program and parses it to see if its syntax pertains to the added statements (extended features). If not, the preprocessor leaves the statement unchanged. If so, the preprocessor generates a sequence of statements in the standard language for the current statement 4o produce the same effect. Note that the output source program generated by the preprocessor will be longer than the input source program because the preprocessor generates a sequence of statements for each statement in the extended language. As shown in the figure, preprocessing inevitably requires two translation passes the first pass transla...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online