[squeak-dev] Re: Parser question
Paolo Bonzini
bonzini at gnu.org
Mon Oct 27 08:36:31 UTC 2008
Randal L. Schwartz wrote:
>>>>>> "Igor" == Igor Stasenko <siguctua at gmail.com> writes:
>
> Igor> Just wonder, if following is correct expression:
> Igor> | t |
> Igor> 1 + t := 5
>
> It seems to me that that should be wrong, because to me the assignment
> operation is very low precedence. And the binary message send would therefore
> be out of place. If it wasn't illegal already, I'd argue to make it illegal,
> as it would lead to misleading code.
Yes, it should be wrong. The grammar is:
expression: keyword_expression cascaded_sends
| variable ':=' expression
keyword_expression: binary_expression
| binary_expression keyword_send
binary_expression: unary_expression
| binary_expression binary_send
unary_expression: primary_expression
| unary_expression unary_send
primary_expression: literal
| variable
| '(' expression ')'
cascaded_sends: cascaded_sends ';' message_send
| /* empty */
message_send: keyword_send
| binary_send
| unary_send
variable: IDENTIFIER
unary_send: IDENTIFIER
binary_send: BINOP unary_expression
keyword_send: KEYWORD binary_expression
| keyword_send KEYWORD binary_expression
So ':=' can only appear at toplevel or inside parentheses, and the above
is not valid.
Paolo
More information about the Squeak-dev
mailing list
|