3

我有以下 Xtext 语法:

grammar dsl.miniproject.Question2.EclipsePluginLanguage with org.eclipse.xtext.common.Terminals

import "platform:/resource/Question2/model/EclipsePluginModel.ecore" 
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Plugin:
    {Plugin}
    'Plugin' Name = EntityName
    '{'             
        (documentation = Documentation)?
        (functions += Functionality)*
        manifest = Manifest
    '}'
;

Documentation:
    {Documentation}
    'description =' documentation = STRING
;

Manifest:
    {Manifest}
    'manifest'
    '{'
        (dependencies += Dependency)*
        (extensionPoints += ExtensionPoint)*    
        (extensions += Extension)*
    '}'
;

Functionality:
    {Functionality}
    'function' Name = EntityName ';'
;

Dependency:
    {Dependency}
    Name = EntityName '=>' depends = [Plugin|EntityName]
;

Extension:
    {Extension}
    Name = EntityName '->' extends = [ExtensionPoint|EntityName]
;

ExtensionPoint:
    {ExtensionPoint}
    'ExtensionPoint' Name = EntityName 
    '{'
        'ref' functions += [Functionality|EntityName] ';'       
    '}'
;

EntityName:
    ID ('.' ID)*
;

但是,在编写示例脚本时:

    Plugin x{
        description = "test"

        function f;
        function f2;

        manifest{

            dep1 => x

            ExtensionPoint ep.ep1{
                ref f;
            }

            ext1 -> ep.ep1
        }    
}

我收到以下错误:

无法解析对插件“x”的引用。无法解析对功能“f”的引用。... ETC

这是我第一次尝试 xtext,我不知道我做错了什么

提前感谢您的帮助!!

4

1 回答 1

2

嗨,您应该将元素名称属性命名为name而不是Name ,并且您必须确保在您使用它的地方的范围内的(实际)限定名称与您使用的终端或数据类型规则(在您的情况下EntityName)匹配,或者您可以更改IQualifiedNameProvider

于 2014-12-28T09:50:23.683 回答