현재 help op Xtext로 새 DSL을 만드는 중입니다. 문법에서 규칙을 정의 할 수 있기를 원합니다. 특정 값을 조작 할 수 있고 this
을 사용하여 현재 객체를 참조 할 수 있습니다. 그러나, 나는 그것이 작동하도록 문법 권리를 얻을 수 없습니다.이 키워드를 사용하는 Xtext 상호 참조
나는 Xtext Expressions example에서 약간의 코드를 가져 와서 카드 값에 대한 상호 참조를 넣을 수 있도록 수정했습니다. 이 키워드를 어떻게 사용할 수 있습니까? 나는 다른 스코어 질문에서이 점에 대해 나 자신의 스코핑 제공자를 사용할 수 있다는 것을 알았지 만 어디서부터 시작해야할지 모른다.
일부 코드를 참조하십시오
// MyDSL.xtext
Game returns Game:
'Game'
name=STRING
...
('Cardpropertytypes' '{' cardpropertytypes+=CardPropertyType ("," cardpropertytypes+=CardPropertyType)* '}')?
cards += Card*
;
Card returns Card:
'Card'
name=ID
'{'
'type' type=[CardType]
('cost' '{' cost+=Cost ("," cost+=Cost)* '}')?
('properties' '{' properties+=CardProperty ("," properties+=CardProperty)* '}')?
('rules' '{' rules+=CardRule ("," rules+=CardRule)* '}')?
('actions' '{' actions+=CardAction ("," actions+=CardAction)* '}')?
'}';
CardRule returns CardRule:
{CardRule}
'{'
('description' description=STRING)?
('requirements' requirements=Addition)?
('action' action=Addition)?
('duration' duration=Duration)?
'}';
CardProperty returns CardProperty:
type=[CardPropertyType] (':' value=INT)?;
Addition returns Expression:
Multiplication ({Addition.left=current} '+' right=Multiplication)*;
Multiplication returns Expression:
Primary ({Multiplication.left=current} '*' right=Primary)*;
Primary returns Expression:
Literal |
'(' Addition ')';
Literal returns Expression:
{Expression}
QualifiedName |
NumberLiteral;
QualifiedName:
ID ('.' ID)*;
NumberLiteral:
value=INT;
// Card.mydsl
Cardpropertytypes {
Toughness,
Power,
Flying,
Indestructible
}
Card AdantoVanguard {
...
properties {
Toughness: 1,
Power: 1,
Flying
}
rules {
{
//action this.properties.Toughness + 2
action ????
}
}
}
명확한 설명 : 나는 같은 속성을 가진 카드 모델이있는 경우 위의 코드 샘플에서 규칙 섹션에서 말할 수 있기를 바랍니다.
this.properties.propertyName + 2
어떻게하면됩니까? xtext 상호 참조에
어떤 상호 참조입니까? 귀하의 문법은 그 점에서 불완전한 것 같습니다 –