|
Re: Xtext definition and instance in same grammar [message #1303630 is a reply to message #1303442] |
Sat, 19 April 2014 11:05 |
|
Hi,
i cant follow the "domain specific" part of your DSL (what is a macro, what can it do, and where are the attributes and values)
so let us simplify
Model:
entities+=Entity
instances+=Instance
;
Entity:
"entity" name=ID "{"
attributes+=Attribute*
"}"
;
Attribute:
name=ID ":" type=Type
;
enum Type :
string | int | Boolean
;
Instance:
"instance" name=ID ":" type=[Entity] "{"
attributeInstances+=AttributeInstance*
"}"
;
AttributeInstance:
attribute=[Attribute] "=" value=Literal //or expression
;
Literal:
IntLiteral | StringLiteral | BooleanLiteral
;
IntLiteral:
value=INT
;
StringLiteral:
value=STRING
;
BooleanLiteral:
{BooleanLiteral}"false" |(value?="true")
;
with scoping, a type system and a bunch of checks this should work with your case too (if i understood it correct)
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.01450 seconds