mckeeman@wivax.UUCP (05/22/84)
> Anyone who is a serious student of programming linguistics, > should realize that a delimiter is neccessary to separate the > expression from the statement in all conditional language-constucts > -- if you want to keep your grammer LALR(1) (almost a given). Curiously enough, LALR(1) does not require a delimiter for most reasonable languages. PLZ/SYS (Snook et al, Springer, 1978) happens to have THEN but allows ' ' ';' ',' TAB CR interchangeably. That is, blank is delimiter enough. What happens is that either the keyword starting the statement, or the pair <expr> <ident> where an <assignment> is following is enough to make decisions possible. (I don't know if PLZ/SYS is in fact LALR(1), but I am pretty sure it could be with the usual fiddling around.) Even more interesting, reserved words are not necessary for LALR(1). One can put in a rule <ident> ::= IF | THEN | DO ... which will turn the reserved word back into <ident> into a grammar and still get the LALR(1) tables in most cases. Now, none of this should be construed as an argument for or against any style of language design or programming. It is just a fact that LALR does not force these decisions on us. /s/ Bill McKeeman.Wang-Inst at CSNet-Relay ...decvax!wivax!mckeeman Wang Institute of Graduate Studies, Tyngsboro, MA 01879
thomson@uthub.UUCP (Brian Thomson) (05/23/84)
wivax!mckeeman states: Even more interesting, reserved words are not necessary for LALR(1). One can put in a rule <ident> ::= IF | THEN | DO ... which will turn the reserved word back into <ident> into a grammar and still get the LALR(1) tables in most cases. Actually, I believe this would fail in most cases, at least for the IF keyword. If your grammar contains <statement> ::= IF <expression> THEN .... <ident> ::= IF and an <expression> may begin with a left parenthesis it will fail to be LALR(1) because of the resulting shift-reduce conflict. 'IF (' is a prefix of a valid procedure call. I don't know of any way to resolve the conflict, do you? -- Brian Thomson, CSRG Univ. of Toronto {linus,ihnp4,uw-beaver,floyd,utzoo}!utcsrgv!uthub!thomson