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,
Zak
-----Original Message-----
From:
[hidden email]
[mailto:
[hidden email]] On Behalf Of
Andrew Tween
Sent: Sunday, 9 March 2008 10:31 PM
To:
[hidden email]
Subject: [squeak-dev] Re: Precedence in SmaCC
Hi,
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} |
Expression
'exp1' "-" Expression 'exp2' {exp1 - exp2} | Expression 'exp1' "*"
Expression 'exp2' {exp1 * exp2} | Expression 'exp1' "/" Expression
'exp2'
{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
only
difference in the generated code is in TestParser>>#transitionTable
Cheers,
Andy