[net.lang.st80] st80 grammar ambiguous

budd@arizona.UUCP (tim budd) (01/15/84)

        Has anybody else noticed that the grammar for smalltalk given
in the Goldberg book is ambiguous?  The problem is that a message
pattern of the keyword type ( (keyword variable)* ) can look an awful lot
like the continuation of a previous message.  ie, one could write


        receiver kw1: arg1 kw2: arg2

     NextMessage: arg

Where NextMessage is the start of the next message description.  However,
it could also be considered part of the command being given to ``receiver''.
This makes writing a parser for ST-80, say using YACC (which is how I
discovered this problem) rather difficult.

Does anybody know how this problem is avoided in actual systems?

--tim budd - university of arizona - {kpno, ucbvax} ! arizona ! budd

shprentz@proper.UUCP (Joel Shprentz) (01/18/84)

The Smalltalk grammar does not seem ambiguous. Your example

	receiver kw1: arg1 kw2: arg2
	nextmessage: arg

would send a message with selector kw1:kw2:nextmessage: to receiver.
If you wanted nextmessage: to be sent to the result of kw1:kw2: you
could use parentheses:

	(receiver kw1: arg1 kw2: arg2)
	nextmessage: arg

Alternatively, both messages may be cascaded to the same receiver
using a semicolon:

	receiver kw1: arg1 kw2: arg2;
	nextmessage: arg

Despite all the discussion about indenting code, compilers ignore
information contained in the format of a program.