|
|
Re: Possible to convert part of STRING to an object's ID using a value converter? [message #1830816 is a reply to message #1830813] |
Tue, 04 August 2020 17:43 |
Tomas Öberg Messages: 14 Registered: February 2020 |
Junior Member |
|
|
Alright, thanks for the link! a more complete example would be this, with the use case below. The substring thing I was talking about is a wildcard token for the template that I want to remove so I can preserve the cross reference.
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
directives+=Directive*
;
Directive:
TemplateDeclaration|ClassDeclaration
;
TemplateDeclaration:
'template' name=STRING parameters+=Parameters
'{'
//... properties here
'}'
;
Parameters:
'(' ID? (',' ID)* ')'
;
ClassDeclaration:
'class' name=ID '{'
templates+=Template*
'}'
;
Template:
name=[TemplateDeclaration|ID] parameters+=Parameters '{'
//...properties
'}'
;
Usage with wildcard that should be ignored:
template "test*" (arg1, arg2) {
//...properties here
}
class TestClass {
test(parameter1, parameter2) {
//...properties here
}
}
[Updated on: Tue, 04 August 2020 18:13] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03196 seconds