Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Possible to extend Google'S Go using Xtext?
Possible to extend Google'S Go using Xtext? [message #1391838] Tue, 01 July 2014 13:38 Go to next message
Michael Hartmann is currently offline Michael HartmannFriend
Messages: 3
Registered: October 2013
Junior Member
Hello,

the programming language Go made by Google has some shortcomings I'm not so happy with. My question is now whether it would be possible to extend Go's syntax with the use of Xtext. For example I would like to add templates to Go. You have Go input files that support some superset of Go as defined by Xtext. When translating them Xtext creates Go output files were the template parameter is substituted by some concrete type.

Thank you, Michael
Re: Possible to extend Google'S Go using Xtext? [message #1391895 is a reply to message #1391838] Tue, 01 July 2014 15:13 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Michael,

do you want a full support of the Go programming language PLUS the use of templates?
This would mean that you have to create a go.xtext grammar file as a base.

Or do you want to create some code generator which creates go code?
There you can start with a very simple grammar because all you have to specify is the template you want to use
and the values for the placeholders.

Greetings from Frankfurt/Germany, Uli
Re: Possible to extend Google'S Go using Xtext? [message #1395766 is a reply to message #1391895] Mon, 07 July 2014 11:17 Go to previous messageGo to next message
Michael Hartmann is currently offline Michael HartmannFriend
Messages: 3
Registered: October 2013
Junior Member
Hi Uli,

to start with it would be sufficient to create some code generator only. Let's say you have some templated Go class named foo with template parameter T: foo<T>. Now you change the implementation of foo. This means that for all parameter types of T used in the code (such as foo<int>, foo<string>, foo<bar>, etc.) Xtext would have to re-generate the respective Go code. To be able to do that full support of the Go programming language would be required. But I'm not into that. I don't have the time for something like this and won't have for quite a while ...

Quote:
Or do you want to create some code generator which creates go code?
There you can start with a very simple grammar because all you have to specify is the template you want to use
and the values for the placeholders.

If you could provide me with some link that ideally points me to some Xtext documentation that explains how to do this, that would be great.

Thanks, Michael

P.S.: I'm also from Frankfurt. The world is small ...
Re: Possible to extend Google'S Go using Xtext? [message #1395790 is a reply to message #1395766] Mon, 07 July 2014 12:00 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Michael,

we just start with a simple grammar which allows you to specify modules and their "arguments"

Model:
mudules+=Module*;
Module: (ModuleA | ModuleB );
Module1: 'module1' name=ID 'arg1='arg1=ID 'arg2='arg2=id
Module2: 'module2' name=ID

All the rest will be done in the generator
where you have multi-line templates, the one with the triple quotes

«FOR Module modul : sm.modules»
«switch modul {
Module1:{genCodeModule1(modul)}
Module2:{genCodeModule2(modul)}

«ENDFOR»
def genCodeModule1(Module1 modul)
'''
entry «modul.name»
params
string «modul.arg1» :IN
string «modul.arg2» : IN
endparams
end ; «modul.name»
'''

Just as a start. Some more you can find in my aricle in "Eclipse Magazin" 2.14.
If you are in Frankfurt, perhaps we can meet to discuss it in more detail.
I will attend the Eclipse Demo Camp on Thursday see:
https://wiki.eclipse.org/Eclipse_DemoCamps_Luna_2014/Frankfurt

[Updated on: Mon, 07 July 2014 16:05]

Report message to a moderator

Previous Topic:The method ruleeState() is undefined for the type InternalRpcIDLParser4
Next Topic:Serializing partial model
Goto Forum:
  


Current Time: Fri Apr 19 03:46:01 GMT 2024

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

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

Back to the top