我试图为语言编写Xtext语法,如下所示:
on Producer1
then ProducerConsumer1
then ProducerConsumer1_1
then ProducerConsumer1_2
then ProducerConsumer1_2_1
then ProducerConsumer2
then ProducerConsumer2_1
on Producer2
then ProducerConsumer1
使用以下语法,我可以在Eclipse编辑器中看到白色空间块已被确认,但没有嵌套我的意图:
Model:
model+=On+
;
On:
'on' producer=ValidID
BEGIN
(producerConsumers+=Then)*
END
;
Then:
'then' producerConsumer=ValidID
BEGIN
(children+=Then)*
END
;
terminal BEGIN: 'synthetic:BEGIN'; // increase indentation
terminal END: 'synthetic:END'; // decrease indentation
我是Xtext的新手,非常感谢指出我出错的地方。
答案 0 :(得分:2)
Then:
'then' producerConsumer=ID
(BEGIN
(children+=Then)+
END)?