SmaCC: Shift/Reduce Conflict

Bergel, Alexandre bergel at iam.unibe.ch
Tue Apr 24 07:31:02 UTC 2007


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