【发布时间】:2018-04-15 17:49:17
【问题描述】:
我正在尝试在 Xtext 中为类似 YAML 的 DSL 建模。在这个 DSL 中,我需要一些 YAML 中的多行字符串。
description: |
Line 1
line 2
...
我的第一次尝试是这样的:
terminal BEGIN:
'synthetic:BEGIN'; // increase indentation
terminal END:
'synthetic:END'; // decrease indentation
terminal MULTI_LINE_STRING:
"|"
BEGIN ANY_OTHER END;
我的第二次尝试是
terminal MULTI_LINE_STRING:
"|"
BEGIN
((!('\n'))+ '\n')+
END;
但他们俩都没有成功。在 Xtext 中有没有办法做到这一点?
更新 1:
我也尝试过这种替代方法。
terminal MULTI_LINE_STRING:
"|"
BEGIN ->END
当我触发“Generate Xtext Artifacts”过程时,我得到了这个错误:
3492 [main] INFO nerator.ecore.EMFGeneratorFragment2 - Generating EMF model code
3523 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel 'http://...' from 'platform:/resource/.../model/generated/....genmodel'
error(201): ../.../src-gen/.../parser/antlr/lexer/Internal..Lexer.g:236:71: The following alternatives can never be matched: 1
error(3): cannot find tokens file ../.../src-gen/.../parser/antlr/internal/Internal...Lexer.tokens
error(201): ../....idea/src-gen/.../idea/parser/antlr/internal/PsiInternal....g:4521:71: The following alternatives can never be matched: 1
【问题讨论】:
-
你试过
| BEGIN -> END;吗?