Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext: Cannot resolve reference(Issue with a basic Xtext grammar)
Xtext: Cannot resolve reference [message #1791041] Thu, 21 June 2018 16:56 Go to next message
Eclipse UserFriend
Hi!

This is my first attempt at Xtext.
Here is the grammar I built:

    grammar com.x.x.x.XxxDsl with org.eclipse.xtext.common.Terminals
    generate xxxDsl "...www.x.x.x.com/xxx/xtext/XxxDsl"

    Root:
        catalogs+=Catalog*
        instances+=Instance*
        ;

    Catalog returns Catalog:
        'Catalog' name=ID
        '{'
        models+=Model*
        '}'
        ;
    
    Model returns Model:
        'Model' name=ID
        ;
    
    Instance returns Instance:
        'Instance'
        name=ID
        'of'
        model=[Model]
    ;


And here is my text:

    Catalog myCatalog
    {
        Model meteo
    	Model storm
    }

    Instance wintermeteo of meteo
    Instance strongstorm of storm


The 2 last lines are in error, `meteo` and `storm` being marked with:

    Couldn't resolve reference to Model 'meteo'/'storm'


If I change my grammar so that the Models are directly in Root (and not inside Catalogs anymore) and update the text accordingly, then the models are correctly recognized.

What did I do wrong? Thanks

Re: Xtext: Cannot resolve reference [message #1791568 is a reply to message #1791041] Mon, 02 July 2018 10:55 Go to previous message
Eclipse UserFriend
Xtext builds hierarchical names

myCatalog.meteo
and
myCatalog.storm

either change grammar to model=[Model|FQN] with FQN: ID ("." ID)*;
and reference by fqn Instance

strongstorm of myCatalog.storm

or bind SimpleNameProvider as IQualifedNameProvider or customize
DefaultDeclarativeQualifiedNameProvider to provide simple instead of a qualifed name
Previous Topic:References doesn't work in my grammar
Next Topic:Codepage problem
Goto Forum:
  


Current Time: Thu Jun 19 22:03:04 EDT 2025

Powered by FUDForum. Page generated in 0.05779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top