简体   繁体   中英

Xtext: Cannot resolve reference

I have the following Xtext grammar:

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)*
;

However when writing a sample script ex:

    Plugin x{
        description = "test"

        function f;
        function f2;

        manifest{

            dep1 => x

            ExtensionPoint ep.ep1{
                ref f;
            }

            ext1 -> ep.ep1
        }    
}

I get the following error:

Couldn't resolve reference to Plugin 'x'. Couldn't resolve reference to Functionality 'f'. ... etc

This is my first attempt at xtext and I cannot figure out what I'm doing wrong

Thanks in advance for any help!!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM