SmaCC: Shift/Reduce Conflict

J J azreal1977 at hotmail.com
Mon Apr 23 15:55:24 UTC 2007


So is SmaCC a parser combinator?  Or is it some other style?


>From: Mathieu Suen <mathk.sue at gmail.com>
>Reply-To: The general-purpose Squeak developers 
>list<squeak-dev at lists.squeakfoundation.org>
>To: The general-purpose Squeak developers 
>list<squeak-dev at lists.squeakfoundation.org>
>Subject: Re: SmaCC: Shift/Reduce Conflict
>Date: Mon, 23 Apr 2007 13:50:59 +0200
>
>Hi,
>
>On Apr 23, 2007, at 11:51 AM, Alexandre Bergel wrote:
>
>>FunctionDefinition :
>>	Id Arguments "{"
>>	ExpressionList
>>	"}" {SPFunction new name: '1'; arguments: ('2' select: [:o| (o  isKindOf: 
>>SmaCCToken) not]); expressions: '4'};
>>
>>Arguments : "(" ArgumentList ")" {'2'};
>>
>>ArgumentList : ArgumentList "," Id
>>		| Id
>>		| ;
>>
>>ExpressionList:
>>	Expression ExpressionList
>>	| ;
>>
>>Expression :
>>		FunctionCall
>>	   | VariableDefinition
>>	   | Id "=" ExpressionWithValue {SPAssignment new name: '1';  expression: 
>>'3'}
>>         | Expression "+" Number 	{SPAddition new left: '1'; right:  '3'}
>>         | Expression "-" Number 	{SPMinus new left: '1'; right: '3'}
>>         | Number {'1'};
>>
>
>I suggest you to create a rule for the assignment.
>You can write something like
>
>Assignment :
>	Id "=" Expression;
>
>
>>FunctionCall :
>>	Id ArgumentsInCall 	{SPFunctionCall new name: '1'; arguments: '2'};
>>
>>ArgumentsInCall :
>>	"(" ArgumentsListInCall ")" {'2' select: [:o| (o isKindOf:  SmaCCToken) 
>>not]};
>>
>>ArgumentsListInCall :
>>	ArgumentsListInCall "," Expression
>>	| Expression
>>	| ;
>>
>>VariableDefinition :
>>	"var" Id {SPVariableDefinition new name: '2'};
>>
>>ExpressionWithValue :
>>         ExpressionWithValue "+" Number 	{SPAddition new left: '1';  
>>right: '3'}
>>         | ExpressionWithValue "-" Number 	{SPMinus new left: '1';  right: 
>>'3'}
>>         | Number {'1'};
>
>
>
>ExpressionWithValue always end up with a Number which is not what  your 
>example saw.
>Shift/Reduce dose not matter
>You can still parse the expression and you have some rule to say if  you 
>want to follow the longer rule or not (ie. Shift or reduce).
>By default you SmaCC do a shift. Look at the tutorial pane in the UI  of 
>SmaCC.
>
>
>HTH
>
>	Math
>
>
>

_________________________________________________________________
Download Messenger. Join the i’m Initiative. Help make a difference today. 
http://im.live.com/messenger/im/home/?source=TAGHM_APR07




More information about the Squeak-dev mailing list