Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Help with non-LL(*) grammar
Help with non-LL(*) grammar [message #674298] Thu, 26 May 2011 12:58 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello guys,

This time I need your help to solve a non-LL(*) grammar. This is my simplified grammar:

Statement:
	  assignment=Assignment
;

VariableMethod:
	((method='toLower()') |
	(method='toString()')|
	(method='fromString('string=ProgramParameter')') |
	(method='WriteElement('element=ProgramParameters')') 
	)
;

MethodCall:
	o=[ecore::EObject]'.'m=VariableMethod	
;

ProgramParameters:
	programParameters+=ProgramParameter (',' programParameters+=ProgramParameter)*
	;

ProgramParameter :
	expresion=Expression
	;
		
AssignmentOperator:
	'='
;

Assignment:
	field=FieldReference ((oper=AssignmentOperator expression=Expression)) 
	|
	  	methodCall=MethodCall
;

FieldReference:
	  	
	  	featureCall=FieldReferenceCall
	  	
;

FieldReferenceCall:
    fieldReference=[ecore::EObject] ({FieldReferenceCall.target=current} '.' (fieldReferenceMember=[ecore::EObject]|method=VariableMethod))*
;


Condition: 
	 AndExpression ({OrExpression.left = current} 'or' right=AndExpression)*	
;

AndExpression returns Condition: 
	RelationalExpression ({AndExpression.left = current} 'and' right = RelationalExpression)* 
;

RelationalExpression returns Condition:
	Expression (
		(		{Gre.left=current}	'>' 
			|	{Les.left=current}	'<'
			|	{Eq.left=current}	'='
		)  
	right=Expression)*;

Expression returns Condition:
	Multiplication (({Plus.left=current} '+' | {Minus.left=current} '-') right=Multiplication)*
;

Multiplication returns Condition:
	PrimaryExpression2 (({Multi.left=current} '*' | {Div.left=current} '/') right=PrimaryExpression2)*
;

PrimaryExpression2  returns Condition:
	PrimaryExpression | ({UnaryNegation} 'not' right=PrimaryExpression)
;

PrimaryExpression returns Condition:
	  FieldReference			
	| FunctionReference
	| ('(' Condition ')')
;

FunctionReference:
	function=Function
;

Function:
	(
		 (funcName = 'getsoaperr(' 	 )
		| (funcName = 'getsoaperrmsg(')
		| (funcName = 'int(' int = ProgramParameter)
		| (funcName = 'len(' length = ProgramParameter)
		| (funcName = 'trim(' trim=ProgramParameter )
		| (funcName = 'rtrim(' trim=ProgramParameter )
		| (funcName = 'ltrim(' trim=ProgramParameter )
		| (funcName = 'substr(' substr=ProgramParameter ',' p2=ProgramParameter (',' p3=ProgramParameter)? )	
		| (funcName = 'concat(' concat=ProgramParameter ',' p2=ProgramParameter (',' p3=ProgramParameter)? )
		| (funcName = 'format(' format=STRING (',' programParameters=ProgramParameters)?)
	)
	')'
;


The problem appears in the rule Assignment when I add "methodCall=MethodCall".

What I want is to allow method calls over objects without writting expressions on the right. I have learnt to left factor grammars and the backtrack options is true, but this time It's getting very difficult to solve the problem.

I hope I explained it well.

Thank very much for your help!


Re: Help with non-LL(*) grammar [message #674373 is a reply to message #674298] Thu, 26 May 2011 16:54 Go to previous message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Sorry, I know the answer to this problem.

My real problem occurs with the full grammar, not this one simplified.

Thank you.
Previous Topic:Internationalization of DSL ?
Next Topic:Grammar documentation
Goto Forum:
  


Current Time: Fri Apr 26 20:52:20 GMT 2024

Powered by FUDForum. Page generated in 0.02649 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top