Confused how to support array with xbase

112 Views Asked by At

I want can use array normally like: a[1]. The xbase seems not support array grammar, so i defined this myself. But this task overcome my head. Thanks.

error(211): ../org.eclipse.xtext.example.domainmodel/src-gen/org/eclipse/xtext/example/domainmodel/parser/antlr/internal/InternalDomainmodel.g:576:2: [fatal] rule ruleXExpressionOrVarDeclaration 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.

generate domainmodel "http://www.xtext.org/example/Domainmodel"
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase

DomainModel:
    importSection=XImportSection?
    elements+=AbstractElement*;

AbstractElement:
    PackageDeclaration | Entity;

PackageDeclaration:
    'package' name=QualifiedName '{'
        elements+=AbstractElement*
    '}';

Entity:
    'script' name=ValidID ('extends' superType=JvmParameterizedTypeReference)? '{'
        features+=Feature*
    '}';

Feature:
    Property | Operation;

Property:
    name=ValidID ':' type=JvmTypeReference;

Operation:
    'def' name=ValidID '(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')' (':' type=JvmTypeReference)?
        body=XBlockExpression;

@Override 
XExpressionOrVarDeclaration returns xbase::XExpression:
    XVariableDeclaration | NpExpression | XExpression;

NpExpression returns xbase::XExpression:
     XExpression '[' INT ']'
;

NpSlice:
    {IntConstant} value=INT
;
0

There are 0 best solutions below