Partial processing of compilation files AI-00255/07 1 88-06-15 ra WB | !standard 10.03 (03) 88-06-15 AI-00255/07 !class ramification 84-11-28 !status approved by WG9/Ada Board 87-02-19 !status approved by Ada Board (21-0-0) 87-02-19 !status approved by WG9/ADA Board 85-02-26 !status committee-approved 84-11-28 !status work-item 84-06-11 !status received 84-05-26 !references 83-00349, 83-00369 !topic Partial processing of compilation files !summary 84-08-31 If a file presented for compilation is illegal (i.e., if it is syntactically ill-formed or contains an illegal compilation unit), the entire file may be rejected. For such files, an implementation is allowed (but not required) to successfully compile legal compilation units contained in the file. In no case can an illegal compilation unit be added to the library. (The Standard does not define which compilation units should be compiled successfully when a file is not legally a compilation since recognition of a compilation unit in a file that contains illegal constructs generally depends on a compiler's error recovery strategy. Note: successful compilation means a compilation unit is added to the library, possibly replacing an earlier version that existed in the library [10.4(2)].) !question 85-01-02 (1) If a file presented for compilation does not satisfy the syntax for a compilation (as defined in 10.1(2)), must the whole file be rejected, or, if the initial portion of the file satisfies the syntax for a sequence of compilation units, can (must?) these units be compiled successfully? (2) If a file is syntactically a compilation (according to the syntax of the Standard; see 10.1(2)) but contains an illegal compilation unit, should the whole compilation be rejected? | !response 88-06-15 A file presented for compilation can consist of a sequence of compilation units. Suppose the file does not satisfy the required syntax for a compilation, e.g., procedure P; procedure Q; -- semicolon used in place of IS begin ... end Q; procedure R; What is the required state of the library after this file is processed? Partial processing of compilation files AI-00255/07 2 88-06-15 ra WB One clearly allowed response is that neither P, Q, nor R are in the library because the file (considered as a whole) does not satisfy the syntax for a compilation, and hence can be rejected as an unrecognizable sequence of characters. Although the current wording clearly allows an implementation to reject a file that contains at least one syntax error, the phrasing of 10.3(3) and 10.4(2) suggest that only illegal units are to be rejected -- legal compilation units are to be processed successfully. In particular, the wording suggests that if the beginning of a file is syntactically a sequence of compilation units, these are to be compiled without regard to syntax errors that may occur later in the file. However, what a compiler regards as a syntax error will depend on what the compiler implementation does during its parse phase. In particular, a compiler may reject a compilation unit during its parse phase even though the compilation unit conforms to the Standard's context-free syntax. Even so, as long as a compilation file contains an illegal compilation unit, the Standard does not specify whether any other portion of the file must be recognized as a sequence of compilation units that should be processed. Consequently, given an illegal compilation unit, it is implementation dependent to what extent a given implementation will be able to detect the presence of other compilation units. Not all illegal constructs are syntactically illegal, of course. Suppose the declaration of procedure Q is replaced with: procedure Q is X : INTEGER := 0; Y : FLOAT; begin Y := X; -- illegal end Q; Now Q is syntactically legal, but contains an illegal assignment statement. Clearly procedure Q cannot be added to the library, but there is no reason why procedure R should not be successfully compiled and added to the library. However, the Standard does not distinguish between units that are "syntactically" illegal and units that violate non-syntax rules, so we cannot conclude that every implementation must successfully compile R in this case. In short, if a compilation file contains an illegal construct, it is implementation dependent as to what legal compilation units, if any, are added to the library. In any case, only the successful compilation of (legal) compilation units causes the library to be updated. Partial processing of compilation files AI-00255/07 3 88-06-15 ra WB | !appendix 88-06-15 | | ***************************************************************************** | | !section 10.03 (03) J. Goodenough 88-06-15 | !version 1983 | !topic Editorial modification to AI-00255/05 | | Version /05 of this AI was approved by the Ada Board and WG9 at its February | 1985 meeting. The commentary was reconsidered for official approval at the | February 1987 Ada Board meeting, which I missed because of illness. At that | time, I had intended to request an editorial change, the removal of the | !recommendation section and a change of the "!discussion" section to | "!response". These changes were necessary because the commentary is a | ramification, and so does not have a recommendation or discussion section. | Ron Brender, who took over in my absence, noticed that these changes had not | been considered at the Ada Board meeting, and so he left AI-00255 out of the | motion recommending certain AIs for approval by the Director, AJPO. | | It is now time to recommend approval of this commentary. The current version | incorporates these minor editorial changes.