Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!amgraf!cpsolv!rhg From: rhg@cpsolv.UUCP (Richard H. Gumpertz) Newsgroups: comp.lang.misc Subject: Re: PL/I Grammar Summary: PL/I is not LALR Keywords: PL/I, C, grammar, parser Message-ID: <422@cpsolv.UUCP> Date: 21 Oct 89 02:06:16 GMT References: <2956@usceast.UUCP> Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz) Organization: Computer Problem Solving, Leawood, Kansas Lines: 28 In article <2956@usceast.UUCP> sharp@usceast.UUCP (Harry Sharp) writes: >... I have been told that PL/I cannot be parsed LALR. >Is this true? (I hope not.) That is indeed true. Many constructs cannot be recognized until after you read past arbitrarily nested parentheses, thus killing any limited-lookahead parser. Another amusing problem is that there are NO reserved keywords. One can even declare variables with the same names as the builtin keywords! Hence, with the appropriate declarations preceding, the PL/I loop DO DO = TO TO BY BY WHILE (BEGIN = END) WHILE (BEGIN = END); BEGIN; ... END; END; is legal. For those not familiar with PL/I, it is roughly equivalent to the C loop for (increment = WHILE(BEGIN == END), limit = BY, *(index = &DO) = TO; (increment >= 0 ? *index <= limit : *index >= limit) & (BEGIN == END); *index += increment) { ... } where index, increment, and limit are automatically declared with appropriate type. The order of evaluation of the four assignments on the first line is not defined by the PL/I language. No, the & in the second line shouldn't be an &&. -- ========================================================================== | Richard H. Gumpertz rhg@cpsolv.UUCP -or- ...!uunet!amgraf!cpsolv!rhg | | Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 | ==========================================================================