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: 14665
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


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: Thu Apr 25 04:23:19 GMT 2024

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

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

Back to the top