Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Predicate or Left-factoring with Ecore objects(How to resolve the recursive problem in my grammar?)
Predicate or Left-factoring with Ecore objects [message #885187] Tue, 12 June 2012 15:15
Jean-Michel Syrotas is currently offline Jean-Michel SyrotasFriend
Messages: 4
Registered: June 2012
Junior Member
Hello!

I am trying to resolve a problem with my grammar for days now, but I still cannot find the solution until now Sad

Here is a part of the grammar I wrote:
ExprComponentRefOrCall returns Exp::uExp:
	{Exp::CALL_INITIAL} 'initial' '(' ')'
	| ExprFunctionCall 
	| ExprComponentRef
	;
	
ExprComponentRef returns Exp::uExp:
	{Exp::CREF} componentRef=ComponentRef
	;

ExprFunctionCall returns Exp::uExp:
	{Exp::CALL} function=ComponentRef '(' functionArgs=FunctionArguments? ')'
	;

ComponentRef returns ComponentRef::uComponentRef:
	ComponentReferenceQualified	
	| {ComponentRef::CREF_IDENT} ref=IDENT 
	;

ComponentReferenceQualified returns ComponentRef::uComponentRef:	
	{ComponentRef::CREF_QUAL}
	ref=IDENT '.' componentRef=ComponentRef
	;

FunctionArgumentsNormal returns FunctionArgs::uFunctionArguments :
	{FunctionArgs::FUNCTIONARGS} argNames+=NamedArguments (',' argNames+=NamedArguments)*
	;

NamedArguments returns NamedArg::uNamedArg :
	{NamedArg::NAMEDARG} argName=ComponentRef '=' argValue=INTEGER
	;


So, the problem is ExprFunctionCall and ExprComponentRef begins both with a ComponentRef. When I try to generate the files with XText I got an error:
[fatal] rule ruleExprComponentRefOrCall has non-LL(*) decision due to recursive rule invocations reachable from alts 2,3. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
...normal Razz

Basically, I would be able to write something like:
myVariable
myPackage.myVariable
myFunction()
myFunction(a=1, b=4, c=10)
myFunction(a.b.c=1, b.d=4)
myPackage.myFunction(a.b=1)
etc.


It could be possible (I think) to write something like
ExprComponentRefOrCall:
    ComponentRef ( '(' FunctionArguments? ')' )?
    ;


But since the variables and the functions are represented by differents ECore models (respectively {Exp::CREF} and {Exp::CALL} with different feature names.

Is there any way to resolve this problem or do I need to change my ECore models? Embarrassed

Thank you for your help...
Previous Topic:Scoping across multiple resources
Next Topic:Problem with whitespace and terminals
Goto Forum:
  


Current Time: Sun Oct 25 17:58:56 GMT 2020

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

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

Back to the top