Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Same optional Modifiers at multiple alternatives(non-LL(*) Decision)
Same optional Modifiers at multiple alternatives [message #987230] Sat, 24 November 2012 19:41
Daniel Missing name is currently offline Daniel Missing nameFriend
Messages: 101
Registered: July 2011
Senior Member
Hi community.

It's been a long time I was here but I just started to play around with Xtext again. In my language I can declare fields and method signatures. Both elements start with some optional modifiers, continue with a type and a name. Then the two elements have different parts. The field has an assignment and the method declares parameters. In short, this grammar rule:

Member returns PhaseMember:
        // field
            visibility=PhaseVisibility? &
            static?='static'? &
        ('=' initializer=XExpression)? ';'
        // field end
        // method
            visibility=PhaseVisibility? &
            static?='static'? &
            abstract?='abstract'? &
            final?='final'? &
        ('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?
        (parameters+=Parameter (',' parameters+=Parameter)*)?
        ('throws' exceptions+=JvmTypeReference (',' exceptions+=JvmTypeReference)* )?
        // method end

Experienced grammar writers will see immediatly: Without backtracking this leads to a non-LL(*) decision because of the modifiers.

I want to keep my grammar free of unneeded keywords and therefore I don't want to place a mandatory keyword (e.g. 'fun', 'def', 'var') in front of any element.

Does anybody of you know how I can get this grammar working without enabling (the evil) backtracking? I tried several combinations with predicates (=>) but nothing worked.

Looking forward to your suggestions.


[Updated on: Sat, 24 November 2012 19:44]

Report message to a moderator

Previous Topic:Refer the value of one feature inside the rule
Next Topic:should Xtext builder lock the entire workspace?
Goto Forum:

Current Time: Wed Dec 02 00:04:31 GMT 2015

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

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