Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Simple Xtext editor for a part of a complex grammar(I need an editor for a part of a grammar, which only checks for errors of the given grammar part and it should support the simple auto-completion)
Simple Xtext editor for a part of a complex grammar [message #923380] Tue, 25 September 2012 21:46
Michael T. is currently offline Michael T.
Messages: 1
Registered: September 2012
Junior Member
I have a complex Xtext grammar, lets say a simplified version looks like this:

    grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
    // in my file the next two lines do not contain spaces inbetween the links 
    // I just had to do this because of the forum rules 
    generate myDsl "http:// www. xtext.org/example/mydsl/MyDsl"
    import "http:// www. eclipse.org/emf/2002/Ecore" as ecore 
    
    ComplexGrammar:
        'Define Complex Grammar'
        (
            'Define Some Value {' someValues+=SomeValue+ '}'
            & 'Define Parts {' requiredParts+=RequiredPart+ '}'
            & 'Define FeatureX {' xfeatures+=FeatureX+ '}'
            & 'Define FeatureY {' yfeatures+=FeatureY+ '}'
        )
        'End'
    ;
    
    RequiredPart:
        'Part' name=ID ';'
    ;
    
    FeatureX:
        // I need this part of the grammar in a single editor.
        // It should support the Xtext validation to show errors.
        // The editor should only use FeatureX instead of the whole grammar.
        // But it also needs RequiredPart which is necessary for the complex grammar, too.
        'Here it requires' requiredPart = [RequiredPart]
    ;
    
    FeatureY:
        // The same like FeatureX, but for FeatureY
        'Requires' requires = [RequiredPart] 'for FeatureY, too!'
    ;
    
    SomeValue:
        // This part is not required by FeatureX or FeatureY
        // But it is required for the ComplexGrammar
        'Unimportant' name=ID 'Value' value=Double ';'
    ;
    
    Double returns ecore::EDouble:
        '-'? INT? '.' INT
    ;


Now I like to integrate an editor into an eclipse FormPage.
I don't need an editor to edit the whole grammar, because it would be to complex for the user.

What I need is kind of a focused editor for a part of my complex grammar, e.g.an editor for "FeatureX" and another editor for "FeatureY". Both should be separated editors and the Xtext validation in the editor for "FeatureX" should just check for errors of the grammar part "FeatureX".
In other words: I need an editor for a part of a grammar, which only checks for errors of the given grammar part and it should support the simple auto-completion.

I have the idea to use something like a dummy of my "ComplexGrammar" to ensure the rest of the grammar is not violated, but currently I have no idea how I could open my editor using the dummy-resource and just show the editor for "FeatureX".

Maybe it helps to show a full example of the "ComplexGrammar" grammar:

    Define Complex Grammar
        Define Parts {
            Part GlobalPartA ;
            Part GlobalPartB ;
        }
        
        Define FeatureX {
            Here it requires GlobalPartA  
        }
        
        Define FeatureY {
            Requires GlobalPartA for FeatureY, too!
            
            Requires GlobalPartB for FeatureY, too!
        }
        
        Define Some Value {
            Unimportant ObjName Value 1.0 ;
        }
        
    End


But my editor should just work for a part of this grammar, e.g. "FeatureY":

    Define FeatureY {
        Requires GlobalPartA for FeatureY, too!
        
        Requires GlobalPartB for FeatureY, too!
    }


Another idea I got by the author Bananeweizen from stackoverflow is separating the grammar. If I think about separating the grammar in multiple grammars, I see one problem: My "ComplexGrammar" defines "RequiredPart" which is also required by "FeatureX" and "FeatureY". If I have a grammar for "FeatureX", how could I access the "RequiredPart" which is already defined in my dummy-resource?

Hope you can give me some ideas or examples.
Thanks in advance.

Michael
Previous Topic:Context sensitive implicit namespace imports
Next Topic:How to refer to elements declared afterwards
Goto Forum:
  


Current Time: Thu Oct 23 21:18:09 GMT 2014

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

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