SmaCC: Shift/Reduce Conflict
Mathieu Suen
mathk.sue at gmail.com
Tue Apr 24 08:43:56 UTC 2007
Cool I am interested how?
Mth
On Apr 24, 2007, at 9:31 AM, Bergel, Alexandre wrote:
> I solved my problem.
>
> Thanks to all of you.
>
> Alexandre
>
>
> On 23 Apr 2007, at 18:40, sig wrote:
>
>>> > Assignment :
>>> > Id "=" Expression;
>>>
>>> If I add
>>> Expression :
>>> FunctionCall
>>> | Assignment
>>> | ...
>>>
>>> Assignment :
>>> Id "=" Expression;
>>>
>>
>> Try this one instead:
>>
>> AssignPart :
>> Id "="
>> | AssignPart Id "="
>> ;
>>
>> Expression:
>> AssignPart ExpressionTail
>> | ExpressionTail
>>
>>
>> ExpressionTail:
>> | Function
>> | BinaryOp
>> | ...
>> | ExpressionTail Function
>> | ExpressionTail BinaryOp
>> ..
>>
>> This will remove shitf/reduce conflicts.
>>
>> The main reason why its occurs is when you write something like this:
>>
>> Expression:
>> FixedPattern
>> | FixedPattern Expression
>>
>> this will force parser to shift and to grow its stack.
>> but if you write :
>>
>> Expression:
>> FixedPattern
>> | Expression FixedPattern
>>
>> parser will reduce faster.
>>
>
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel http://www.software-artist.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
More information about the Squeak-dev
mailing list
|