Help with non-LL(*) grammar [message #674298] |
Thu, 26 May 2011 08:58  |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.04746 seconds