|
Re: Xtext-Error: rule ruleReference has non-LL(*) decision due to recursive rule invocations... [message #892473 is a reply to message #891882] |
Thu, 28 June 2012 11:27 |
|
Hi,
the problem is here:
ManyToManyAnnotation:
{ManyToManyAnnotation}
'@' name='ManyToMany' ('(' (('targetEntity='
targetEntity=JvmParameterizedTypeReference) ', '
'mappedBy='
mappedBy=ValidID)?
')')?;
And the fact that you have three differnent rules like this one here:
RefRefers:
(annotations+=JpaReferenceAnnotation)*
Because of that and the Structure of the Rule JvmParameterizedTypeReference:
JvmParameterizedTypeReference:
type=[JvmType|QualifiedName] (=>'<'
arguments+=JvmArgumentTypeReference (','
arguments+=JvmArgumentTypeReference)* '>')?;
The AST can grow to both sides. LEFT_RECURSION.
The easiest fix is to introduce a keyword in from of the list. ;-) But
that is really ugly.
RefRefers:
'annotations1' (annotations+=JpaReferenceAnnotation)*
'ref' type=JvmTypeReference name=ValidID ('['
lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']')
';';
RefContains:
'annotations2'(annotations+=JpaReferenceAnnotation)*
'contains ref' type=JvmTypeReference name=ValidID ('['
lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']')
';';
RefEmbedds:
'annotations3'(annotations+=JpaReferenceAnnotation)*
'embedded ref' type=JvmTypeReference name=ValidID
';';
If you do not really need a ParameterizedTypeReference you can use a
JvmType directly.
ManyToManyAnnotation:
{ManyToManyAnnotation}
'@' name='ManyToMany' ('(' (('targetEntity='
targetEntity=[types::JvmType|QualifiedName]) ', '
'mappedBy='
mappedBy=ValidID)?
')')?;
Do the whole grammar would look like this:
grammar org.lunifera.metamodel.dsl.jpa.Jpa with
org.lunifera.metamodel.dsl.entity.Entity
generate jpa "http://www.lunifera.org/metamodel/dsl/jpa/Jpa"
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/xbase/Xtype" as xtype
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
import "http://www.eclipse.org/Xtext/Xbase/XAnnotations"
JModel:
jmodel=EntityModel;
Entity:
(annotations+=JpaEntityAnnotation)*
'entity' name=ValidID ('extends' superType=JvmTypeReference)? '{'
features+=AbstractFeature* '}';
Property:
(annotations+=JpaPropertyAnnotation)*
varType='var' type=JvmTypeReference name=ValidID ';';
RefRefers:
(annotations+=JpaReferenceAnnotation)*
'ref' type=JvmTypeReference name=ValidID ('['
lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']')
';';
RefContains:
(annotations+=JpaReferenceAnnotation)*
'contains ref' type=JvmTypeReference name=ValidID ('['
lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']')
';';
RefEmbedds:
(annotations+=JpaReferenceAnnotation)*
'embedded ref' type=JvmTypeReference name=ValidID
';';
JpaAnnotation:
JpaEntityAnnotation | JpaPropertyAnnotation | JpaReferenceAnnotation;
JpaEntityAnnotation:
EmbeddableAnnotation | CachableAnnotation;
JpaPropertyAnnotation:
IdAnnotation | NullableAnnotation;
JpaReferenceAnnotation:
ManyToManyAnnotation;
EmbeddableAnnotation:
{EmbeddableAnnotation}
'@' name='Embeddable';
CachableAnnotation:
{CachableAnnotation}
'@' name='Cachable';
IdAnnotation:
{IdAnnotation}
'@' name='ID';
NullableAnnotation:
{NullableAnnotation}
'@' name='Nullable';
ManyToManyAnnotation:
{ManyToManyAnnotation}
'@' name='ManyToMany' ('(' (('targetEntity='
targetEntity=[types::JvmType|QualifiedName]) ', '
'mappedBy='
mappedBy=ValidID)?
')')?;
Cheers,
Holger
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
Powered by
FUDForum. Page generated in 0.02842 seconds