Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsMaking it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839432/#msg_1839432
https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/Xtext.xtext
I want to define new rules in my DSL, but also want to use existing terminal rules I've defined in my grammar, like STRING, so I don't have to recreate those terminal rules in my DSL.
This, however, gives me an error at "rule = PREDEFINED_TERMINALS" saying: "Cannot find comptaible type for the feature 'rule'.
Is is this the right approach, and why do I get this error?
Thanks.]]>M D2021-03-21T11:05:39-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839445/#msg_1839445
Have you understood how "with org.eclipse.xtext.common.Terminals" in the standard examples enables the contents of Terminals.xtext to be re-used?
As with Terminal.xtext you can just use a few terminals, or as with EssentialOCL.xtext you can re-use a whole language.
Regards
Ed Willink]]>Ed Willink2021-03-21T18:12:52-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839451/#msg_1839451
My DSL is used to create the grammar for another DSL among other things. Thus, I want it to do stuff and also write new Xtext grammar in it. I know STRING and such is defined in org.eclipse.xtext.common.Terminals, but those applies to the grammar of my DSL and not my DSL itself. I want to able to write name = STRING in my DSL without having to define STRING in my DSL.]]>M D2021-03-21T22:41:08-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839520/#msg_1839520
M D2021-03-23T08:46:31-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839524/#msg_1839524
Christian Dietrich2021-03-23T11:16:08-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839531/#msg_1839531
Rephrasing what you ask, it would appear that you are developing a new DSL that has many similarities to Xtext, so you have an Xtext ++ --.
In so far as what you are trying to do doesn't work for you, I suggest that you proceed in smaller and smaller steps until you identify the step where you have a misunderstanding.
First step: clone the Xtext grammar unchanged other than to rename to avoid conflicts with the original Xtext. Next steps; remove an Xtext facility you do not require./ add: add a new facility that you do.
Once you have a specific small change that fails to work and you cannot comprehend, you can post that change for comment by those that may be able to help.
Regards
Ed Willink]]>Ed Willink2021-03-23T12:40:14-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839544/#msg_1839544
Christian Dietrich wrote on Tue, 23 March 2021 11:16
If in the metamodel there's a cross reference so it has to be in your grammar
So it can either be a cross-reference to a newly defined tule in my DSL or a predefined rule in my grammar, which is what I use the terminal rule PREDEFINED_TERMINALS to.
Ed Willink wrote on Tue, 23 March 2021 12:40
Hi
Rephrasing what you ask, it would appear that you are developing a new DSL that has many similarities to Xtext, so you have an Xtext ++ --.
In so far as what you are trying to do doesn't work for you, I suggest that you proceed in smaller and smaller steps until you identify the step where you have a misunderstanding.
First step: clone the Xtext grammar unchanged other than to rename to avoid conflicts with the original Xtext. Next steps; remove an Xtext facility you do not require./ add: add a new facility that you do.
Once you have a specific small change that fails to work and you cannot comprehend, you can post that change for comment by those that may be able to help.
Regards
Ed Willink
I've already cloned the grammar and made small changes. The small changes are the ones I wrote in the original post.]]>M D2021-03-23T15:33:20-00:00Re: Making it possible to write Xtext grammar in DSL
https://www.eclipse.org/forums/index.php/mv/msg/1107390/1839549/#msg_1839549
If you presented your problem as a MyDSL.xtext rather than a snippet it would be much easier for others to help you.