2 b lalr(1)

Brian Thomson thomson at uthub.UUCP
Thu May 24 04:05:55 AEST 1984


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



More information about the Comp.lang.c mailing list