Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Split Grammar into two files
Split Grammar into two files [message #869839] Fri, 04 May 2012 13:31 Go to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey,

I would like to split my grammar into two separate file - the current grammar file is getting to long. So I just want to have a physical separation of the grammar file, the behaviour should remain the same.

I had a look into the source of Xbase. There are two grammar files (Xtype.xtext and Xbase.xtext).

The header of Xtype starts:

grammar org.eclipse.xtext.xbase.Xtype with org.eclipse.xtext.common.Terminals


and the header for Xbase references Xtype:

grammar org.eclipse.xtext.xbase.Xbase with org.eclipse.xtext.xbase.Xtype

also the mwe2 file contains an additional language property for Xtype.

I performed this steps as well as for my grammar files, but I get an exception while the mwe2 file is executed.

7792 [main] ERROR org.eclipse.xtext.generator.CompositeGeneratorFragment  - Could not find a GenModel for EPackage 'h_t_t_p://_w_w_w_mydsl.org/base' from h_t_t_p://_w_w_w_mydsl.org/base
If the missing GenModel has been generated via EcoreGeneratorFragment make sure to run it first in the workflow.
If you have a *.genmodel-file, make sure to register it via StandaloneSetup.registerGenModelFile(String)
java.lang.RuntimeException: Could not find a GenModel for EPackage 'h_t_t_p://_w_w_w_mydsl.org/base' from h_t_t_p://_w_w_w_mydsl.org/base
If the missing GenModel has been generated via EcoreGeneratorFragment make sure to run it first in the workflow.
If you have a *.genmodel-file, make sure to register it via StandaloneSetup.registerGenModelFile(String)


Apparently, my mwe2 file is not correct, since I can use all types that are defined in the Base.xtext with my inheriting grammar. Here is the part that I added to my mwe2 file(as well as the missing import):

language = {
    uri = "classpath:/org/mydsl/Base.xtext" 
    fileExtensions="___xtype"
    fragment = grammarAccess.GrammarAccessFragment {}
    fragment = serializer.SerializerFragment {
        // generateDebugData = true
    }
    fragment = formatting.FormatterFragment {}
    fragment = contentAssist.JavaBasedContentAssistFragment {}
    fragment = XtextAntlrGeneratorFragment {
        options = auto-inject {}
    }
}


I don't know what I'm doing wrong. Are there any further adjustments to make, that mwe2 can wire up both grammar files (Base.xtext and MyDSL.xtext).

Any help is appreciated!

Thank you!

Kon

Edit:

I had to adjust the links being able to post my question. I need to reach the 25 post limit Smile

[Updated on: Fri, 04 May 2012 13:32]

Report message to a moderator

Re: Split Grammar into two files [message #869923 is a reply to message #869839] Fri, 04 May 2012 20:08 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

if you have a look at the workflow xtext generates for you you might get an idea what todo
(simply replace xbase with your base language)

    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
        // The following two lines can be removed, if Xbase is not used.
        registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
        registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    }


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:is xTend to generate no-java code? code to download?
Next Topic:How to test custom ResourceDescriptionStrategy?
Goto Forum:
  


Current Time: Fri Mar 29 09:48:41 GMT 2024

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

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

Back to the top