Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Antlr4 to xtext(Convert antlr4 grammar to xtext grammar.)
icon7.gif  Antlr4 to xtext [message #1755183] Tue, 28 February 2017 17:52 Go to next message
Vihanga Liyanage is currently offline Vihanga LiyanageFriend
Messages: 3
Registered: February 2017
Junior Member
Hi all,
My objective is to create an eclipse plugin for a DSL which maintains an antlr4 grammar file. I know that xtext is the easiest way to create such language plugin, but the owners of the DSL doesn't want to maintain a separate xtext grammar file as well for that language.
Is there a way to get the relevant xtext grammar from antlr4 grammar?
If not, what is the best approach I should use?

  • Write some kind of a converter between two grammars?
  • Write a plugin from scratch without using xtext at all?
  • Something else?


Thanks in advance...
Re: Antlr4 to xtext [message #1755200 is a reply to message #1755183] Wed, 01 March 2017 04:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10585
Registered: July 2009
Senior Member
Since Xtext uses antlr 3 and a subset only this might be not as easy as you think.
I'd write an external tool
Re: Antlr4 to xtext [message #1755202 is a reply to message #1755200] Wed, 01 March 2017 04:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10585
Registered: July 2009
Senior Member
Ps what about deriving the antlr grammar from the Xtext grammar (there is already a flag in the workflow that gives you a pure antlr v3 grammar

[Updated on: Wed, 01 March 2017 05:15]

Report message to a moderator

Re: Antlr4 to xtext [message #1755203 is a reply to message #1755183] Wed, 01 March 2017 07:01 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 502
Registered: July 2009
Location: Dortmund, Germany
Senior Member

hint for the flag:
		language = StandardLanguage {
...
			parserGenerator = {
				debugGrammar = true
			}
...
		}



But I also think this is not what you want. What you actually want is not really possible with Xtext.

Writing such a plugin your own is the right way to do, but this is really huge effort. That's why it isoften a good idea to use Xtext, this is already done for you by the framework.

Good luck.
Re: Antlr4 to xtext [message #1755214 is a reply to message #1755183] Wed, 01 March 2017 08:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5214
Registered: July 2009
Senior Member
Hi

If you want to write an Xtext2Antlr transformation, you might find my initial work on an Xtext2LPG transformation helpful.

'initial'. It was developed to use conventional LALR analysis to detect hidden shift-reduce hazards in the Xtext LL-ish grammars for OCL. I think that the grammar conversion works, The action code to make the generated LPG execute (incrementally) is one of many jobs on my stack.

Regards

Ed Willink
Re: Antlr4 to xtext [message #1755216 is a reply to message #1755214] Wed, 01 March 2017 08:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5214
Registered: July 2009
Senior Member
Hi

Oops. Forgot the reference:

GIT\org.eclipse.ocl\examples\org.eclipse.ocl.examples.xtext2lpg in http://git.eclipse.org/c/ocl/org.eclipse.ocl.git

Regards

Ed Willink
Re: Antlr4 to xtext [message #1755408 is a reply to message #1755216] Fri, 03 March 2017 06:10 Go to previous messageGo to next message
Vihanga Liyanage is currently offline Vihanga LiyanageFriend
Messages: 3
Registered: February 2017
Junior Member
Hi all,

Thank you for you replies. As I understand it, it's better to write a separate plugin from scratch. Well in that case, do any one of you know any easy methods you found to do that. I haven't developed a plugin before, so any help would be much appreciated.
Thanks again.

Vihanga.
Re: Antlr4 to xtext [message #1755549 is a reply to message #1755183] Sun, 05 March 2017 15:29 Go to previous message
Vihanga Liyanage is currently offline Vihanga LiyanageFriend
Messages: 3
Registered: February 2017
Junior Member
Hi all,

Thank you for you replies. As I understand it, it's better to write a separate plugin from scratch. Well in that case, do any one of you know any easy methods you found to do that. I haven't developed a plugin before, so any help would be much appreciated.
Thanks again.

Vihanga.
Previous Topic:XtextGradlePlugin configuration problem
Next Topic:Two DSL, single project, Activator&injector issues
Goto Forum:
  


Current Time: Sun May 28 20:41:52 GMT 2017

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

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