Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » can we have two different xtext grammar files from single xtext project?(can we have two different xtext grammar files from single xtext project?)
can we have two different xtext grammar files from single xtext project? [message #1736938] Mon, 04 July 2016 13:24 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
HI,

can we have two different xtext grammar files from single xtext project?
Re: can we have two different xtext grammar files from single xtext project? [message #1736942 is a reply to message #1736938] Mon, 04 July 2016 13:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
yes you can have multiple language sections inside the workflow

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1736954 is a reply to message #1736942] Mon, 04 July 2016 15:00 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
can you please give an example for xtext 2.9+
Re: can we have two different xtext grammar files from single xtext project? [message #1736955 is a reply to message #1736954] Mon, 04 July 2016 15:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
????????

language = StandardLanguage {
name = "org.xtext.example.mydsl.MyDsl"
fileExtensions = "mydsl"

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}

parserGenerator = {
combinedGrammar = false
}
}
language = StandardLanguage {
name = "org.xtext.example.mydsl.MyDsl2"
fileExtensions = "mydsl2"

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}

parserGenerator = {
combinedGrammar = false
}
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737356 is a reply to message #1736955] Thu, 07 July 2016 14:18 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

I have created one more xtext file inside the existing project and added above code but I am not getting option as "generate artifacts" when right click on the new grammar file.
Re: can we have two different xtext grammar files from single xtext project? [message #1737364 is a reply to message #1737356] Thu, 07 July 2016 15:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
this is cause the option is tied based on naming convention with the grammar file
=> rightclick on workflow run as -> mwe 2 workflow


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737368 is a reply to message #1737364] Thu, 07 July 2016 15:12 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes it is running. Do I need to do any mapping between two grammar files?
Re: can we have two different xtext grammar files from single xtext project? [message #1737370 is a reply to message #1737368] Thu, 07 July 2016 15:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
why mapping? the grammar have nothing todo with each other.
what is your goal?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737373 is a reply to message #1737370] Thu, 07 July 2016 15:36 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes no need todo with each other. But when I am running working the parser rules in first grammar file in project showing error.
Re: can we have two different xtext grammar files from single xtext project? [message #1737374 is a reply to message #1737373] Thu, 07 July 2016 15:48 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
First Xtext File:

grammar com.prolifics.jpl.JPLEditor with org.eclipse.xtext.common.Terminals hidden(WS, SL_COMMENT, ML_COMMENT)
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate jPLEditor "http://www.prolifics.com/jpl/JPLEditor"

Model: statements+=Statement*;

Statement: MyRule;

)
;

Second xtext file:

grammar com.prolifics.jpl.JPLAsc with org.eclipse.xtext.common.Terminals
generate jPLEditor "http://www.prolifics.com/jpl/JPLAsc"

Model: statements+=Statement*;

Statement: STag;

STag:
'S:'
;
Re: can we have two different xtext grammar files from single xtext project? [message #1737375 is a reply to message #1737373] Thu, 07 July 2016 15:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
Sachin Samaram <forums-noreply@xxxxxxxx> wrote:
> Yes no need todo with each other. But when I am running working the
> parser rules in first grammar file in project showing error.
>

Can you Share Details


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737376 is a reply to message #1737374] Thu, 07 July 2016 16:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
First is incomplete where is my rule

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737377 is a reply to message #1737374] Thu, 07 July 2016 16:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
First is incomplete where is my rule

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737382 is a reply to message #1737376] Thu, 07 July 2016 16:43 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
module com.prolifics.jpl.GenerateJPLEditor

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {

component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "com.prolifics.jpl.JPLEditor"
rootPath = rootPath
runtimeTest = {
enabled = true
}
eclipsePlugin = {
enabled = true
}
eclipsePluginTest = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "windows-1252"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "com.prolifics.jpl.JPLEditor"
fileExtensions = "jpl"

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
parserGenerator = {
options = {
ignoreCase = true
backtrack=true
}
}
}
language = StandardLanguage {
name = "com.prolifics.jpl.JPLEditor"
fileExtensions = "asc"

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
parserGenerator = {
options = {
ignoreCase = true
backtrack=true
}
}
}
}
}
Re: can we have two different xtext grammar files from single xtext project? [message #1737383 is a reply to message #1737382] Thu, 07 July 2016 16:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
Looks ok. What's the error

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737384 is a reply to message #1737383] Thu, 07 July 2016 16:50 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
index.php/fa/26418/0/
  • Attachment: Jpl_err.png
    (Size: 284.94KB, Downloaded 1025 times)
Re: can we have two different xtext grammar files from single xtext project? [message #1737385 is a reply to message #1737384] Thu, 07 July 2016 16:51 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Annotation is parser rule in first grammar file
Re: can we have two different xtext grammar files from single xtext project? [message #1737386 is a reply to message #1737384] Thu, 07 July 2016 16:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
Sachin Samaram <forums-noreply@xxxxxxxx> wrote:
>
>
>

Please share complete example I can import and run


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737388 is a reply to message #1737386] Thu, 07 July 2016 16:58 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
No Message Body
Re: can we have two different xtext grammar files from single xtext project? [message #1737397 is a reply to message #1737388] Thu, 07 July 2016 18:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
we you cannot use the same package name in both grammars

generate jplAsc "http://www.prolifics.com/jpl/JPLAsc"


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737431 is a reply to message #1737397] Fri, 08 July 2016 07:58 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes, I did it now. But this time I am getting error like java.lang.IllegalStateException: Unresolved proxy http://www...... Make sure the EPackage has been registered

[Updated on: Fri, 08 July 2016 08:01]

Report message to a moderator

Re: can we have two different xtext grammar files from single xtext project? [message #1737433 is a reply to message #1737431] Fri, 08 July 2016 08:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
please give a complete error message ?!?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737435 is a reply to message #1737433] Fri, 08 July 2016 09:02 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
java.lang.IllegalStateException: Unresolved proxy "http://www.prolifics.com/jpl/JPLAsc"#STag. Make sure the EPackage has been registered

Then I added


<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.prolifics.com/jpl/JPLEditor"
class = "com.prolifics.jpl.jPLEditor.JPLEditorPackage"
genModel = "model/generated/JPLEditor.genmodel" />
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.prolifics.com/jpl/JPLAsc"
class = "com.prolifics.jpl.jPLEditor.JPLEditorPackage"
genModel = "model/generated/JPLAsc.genmodel" />
</extension>
</plugin>

It is resolved but new error came as : java.lang.ClassCastException: com.prolifics.jpl.jPLEditor.impl.JPLEditorFactoryImpl cannot be cast to com.prolifics.jpl.jPLAsc.JPLAscFactory
Re: can we have two different xtext grammar files from single xtext project? [message #1737436 is a reply to message #1737435] Fri, 08 July 2016 09:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
did you compare plugin.xml_gen with plugin.xml?

<package
uri = "http://www.prolifics.com/jpl/JPLAsc"
class = "com.prolifics.jpl.jPLEditor.JPLEditorPackage"
is false for sure


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737437 is a reply to message #1737436] Fri, 08 July 2016 09:11 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
I didn't get

<package
uri = "http://www.prolifics.com/jpl/JPLAsc"
class = "com.prolifics.jpl.jPLEditor.JPLEditorPackage"

in plugin.xml or plugin_gen.xml
Re: can we have two different xtext grammar files from single xtext project? [message #1737438 is a reply to message #1737437] Fri, 08 July 2016 09:13 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
index.php/fa/26425/0/
  • Attachment: test.png
    (Size: 172.17KB, Downloaded 990 times)
Re: can we have two different xtext grammar files from single xtext project? [message #1737439 is a reply to message #1737437] Fri, 08 July 2016 09:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member
i get <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.prolifics.com/jpl/JPLEditor"
class = "com.prolifics.jpl.jPLEditor.JPLEditorPackage"
genModel = "model/generated/JPLEditor.genmodel" />
</extension>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.prolifics.com/jpl/JPLAsc"
class = "com.prolifics.jpl.jplAsc.JplAscPackage"
genModel = "model/generated/JPLAsc.genmodel" />
</extension>
</plugin>

in plugin.xml gen after changing aplasc to

generate jplAsc "http://www.prolifics.com/jpl/JPLAsc"


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can we have two different xtext grammar files from single xtext project? [message #1737440 is a reply to message #1737439] Fri, 08 July 2016 09:22 Go to previous message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes it is working now. Some how I copied wrong before. Thanks
Previous Topic:Xtext Project From Existing Ecore Models Problems
Next Topic:Cyclic linking detected when building in maven
Goto Forum:
  


Current Time: Tue Jan 19 19:54:15 GMT 2021

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

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

Back to the top