ACM Home Page
Please provide us with feedback. Feedback
A final solution to the Dangling else of ALGOL 60 and related languages
Full text PdfPdf (453 KB)
Source
Communications of the ACM archive
Volume 9 ,  Issue 9  (September 1966) table of contents
Pages: 679 - 682  
Year of Publication: 1966
ISSN:0001-0782
Author
Paul W. Abrahams  Information International, Inc., New York, NY
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 11,   Downloads (12 Months): 46,   Citation Count: 2
Additional Information:

abstract   references   cited by   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/365813.365821
What is a DOI?

ABSTRACT

The dangling else problem consists of a class of potential ambiguities in ALGOL-like conditional statements whose basic form is “if B1 then if B2 then S1 else S2” where B1 and B2 are Boolean expressions and S1 and S2 are basic statements. The difficulty lies in whether to attach the else to the first if or to the second one. Existing solutions to the problem are either ambiguous or unnecessarily restrictive. Let S and S1 be statements. We define S to be closed if “S else S1” is not a statement, and to be open if “S else S1” is a statement. Thus an unconditional statement is a closed statement. Open and closed conditional statements are defined by syntax equations in such a way as to preserve openness and closure. In each case, an else must always be preceded by a closed statement. It is shown that the syntax equations are unambiguous, and that any change in the statement types required within the syntax equations would lead to either ambiguity or unnecessary restriction.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
ARDEN, B., GALLER, B., AND GRAHAM, R. The MAD Manual. U. of Michigan Press, Ann Arbor, Mich., 1965.
2
 
3
COBOL-1961: revised specifications for a common business oriented language. Publ. 0-598941, U.S. Government Printing Office, Washington, D.C., 1961.
4
 
5
PL/I: Language specifications. Form C26-6571-2, IBM Programming Systems Publications, Poughkeepsie, N.Y., Jan. 1966.
6
7
8
9
10