2014-12-27 72 views
3

我有以下的Xtext語法:的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 
     }  
} 

我收到以下錯誤:

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

這是我在xtext上的第一次嘗試,我無法弄清楚我在做什麼錯誤

在此先感謝您的幫助!

回答

2

嗨,你應該命名你的元素的name屬性name和NOT Name ,你必須確保在你使用它匹配所使用的終端或數據類型規則(在你的情況下發生的範圍(實際)限定的名字EntityName)或者你可以改變IQualifiedNameProvider

+0

你先生,是一個救星。非常感謝!! – Jonny 2014-12-28 10:39:40