我已经成功地使用'with'关键字在xtext中组合了两个语法,但是我在语言验证和生成中遇到了问题。
当有两个语法组合时,任何验证/代码生成都必须放在原始语法中或扩展它的那个语法中? 假设我有语法A和B,并且B位于A之上。任何与语法A中的规则相关的验证必须在A中,或者它们必须在B中? 谢谢 :)
I have successfully managed to combine two grammars in xtext using the 'with' keyword, however I am having an issue in the language validation and generation.
When there are two grammars combined, any validation / code generation has to be placed in the original grammar or the one extending it? Say I have grammars A and B, and B sits on top of A. Any validation related to the rules in grammar A must be in A, or they have to be in B? Thanks :)
最满意答案
我遇到了同样的问题,我找到了一个查看此链接的解决方案。
诀窍是覆盖该方法
protected List<EPackage> getEPackages() { List<EPackage> result = super.getEPackages(); result.add(OdlDataPackage.eINSTANCE); return result; }为了将超语法的包添加到父包的列表中。
I'm experiencing the same problem and I found a solution looking at this link.
The trick is to override the method
protected List<EPackage> getEPackages() { List<EPackage> result = super.getEPackages(); result.add(OdlDataPackage.eINSTANCE); return result; }In order add the package of the super grammar to the list of the parent package.
更多推荐
发布评论