[squeak-dev] Re: Precedence in SmaCC

Andrew Wakeling andrew.wakeling at objective.com
Sun Mar 9 11:42:04 UTC 2008

Argh... Thank you! This was driving me nuts.

I guess this is considered a bug? If not, perhaps the documentation in
Tutorial should be edited to include these necessary carriage returns.

We may also want to consider updating the test cases to reflect this
potential bug too.

Many thanks,

-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of
Andrew Tween
Sent: Sunday, 9 March 2008 10:31 PM
To: squeak-dev at lists.squeakfoundation.org
Subject: [squeak-dev] Re: Precedence in SmaCC

I get the same problem.
But if I change the parser def slightly (simply insert a cr after %left
"/"; ) to give...

%left "+" "-";
%left "*" "/";
Expression :
          Expression 'exp1' "+" Expression 'exp2' {exp1 + exp2} |
'exp1' "-" Expression 'exp2' {exp1 - exp2} | Expression 'exp1' "*" 
Expression 'exp2' {exp1 * exp2} | Expression 'exp1' "/" Expression
{exp1 / exp2} | Number 'number' {number};
Number : <number> 'numberToken' {numberToken value asNumber};

and recompile, then it works as expected, giving 2+3*4 = 14.
Comparing the generated classes for the two parser defs  shows that the
difference  in the generated code is in TestParser>>#transitionTable


More information about the Squeak-dev mailing list