[SOLVED, Xtext/Xpand] Code generation [message #1129368] |
Tue, 08 October 2013 15:05 |
Davide G Messages: 36 Registered: October 2013 |
Member |
|
|
Hi, i'm trying to build a very simple code generator. This is the xtext grammar:
grammar org.xtext.example.mydsl.Entity with org.eclipse.xtext.common.Terminals
generate entity "..."
Model:
greetings+=Greeting*;
Greeting:
'Hello' name=ID '!';
and in the generator xtend file i have this code:
class EntityGenerator implements IGenerator
{
override void doGenerate(Resource resource, IFileSystemAccess fsa)
{
(error 1) for(g : resource.allContents.toIterable.filter(Greeting))
{
(error 2) fsa.generateFile("documento.txt",g.compile)
}
}
def compile(Greeting g) '''
<Greeting>
«g.name»
<\Greeting>
'''
}
I get these two errors:
(1) The method or field Greeting is undefined for the type EntityGenerator
(2) Type mismatch: cannot convert from EObject to Greeting
A solution to this problem?
Bye!
[Updated on: Wed, 09 October 2013 07:08] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03744 seconds