Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 20:56 Go to next message
Rémi Bernard is currently offline Rémi BernardFriend
Messages: 2
Registered: June 2018
Junior Member
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 14:55 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:References doesn't work in my grammar
Next Topic:Codepage problem
Goto Forum:
  


Current Time: Fri Nov 16 13:29:34 GMT 2018

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

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

Back to the top