Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » learning xtext(learning xtext)
learning xtext [message #677273] Wed, 08 June 2011 00:44 Go to next message
spcmdr is currently offline spcmdrFriend
Messages: 15
Registered: January 2011
Junior Member
Hi

I am starting to learn xtext.
I just found an interesting video on YouTube about that:4/5 XText DSL further grammar constructs

The problem is that I am not able to reproduce the simple grammar teach in the video.

I am not able to have cross references work in my generated editor.
I am using xtext version 1.0.2, I don't know comes from an api change.

Here is my grammar:
grammar org.eclipse.xtext.example.Domainmodel with org.eclipse.xtext.common.Terminals

generate domainmodel "http://www.eclipse.org/xtext/example/Domainmodel"

DomainModel:
	(book+=Book)*;

Book:
	'Book' isbn=ID title=STRING (subtitle=STRING)? pages=INT ('sequelof' sequelof=[Book])? ('hardbook'|'paperbook');


Here is my editot content
Book J1234 "Title" 1 hardbook
Book book1 "Title" 2 paperbook
Book book2 "Title" "Subtitle" 2 hardbook
Book book3 "Title" "Subtitle" 2 hardbook
Book id "ss" "Subtitle" 1
Book book4 "Title" "Subtitle" 1 sequelof [b]book3 [/b]paperbook


whatever I insert after "sequelof" I got an error message

Couldn't resolve reference to Book 'book3'
no viable alternative at input 'Book'

Re: learning xtext [message #677286 is a reply to message #677273] Wed, 08 June 2011 03:05 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
By default, the linker links an ID reference to a feature called "name".
Your Book does not have a "name". If you change "isbn" to "name" it will
probably work.

It is possible to use the feature "isbn" as the "name", but it requires
more work on your part.

- henrik

On 6/8/11 2:44 AM, forums-noreply@eclipse.org wrote:
> Hi
>
> I am starting to learn xtext.
> I just found an interesting video on YouTube about
> that:http://www.youtube.com/watch?v=luisbMd00DM&feature=related
>
> The problem is that I am not able to reproduce the simple grammar teach
> in the video.
>
> I am not able to have cross references work in my generated editor.
> I am using xtext version 1.0.2, I don't know comes from an api change.
>
> Here is my grammar:
>
> grammar org.eclipse.xtext.example.Domainmodel with
> org.eclipse.xtext.common.Terminals
>
> generate domainmodel "http://www.eclipse.org/xtext/example/Domainmodel"
>
> DomainModel:
> (book+=Book)*;
>
> Book:
> 'Book' isbn=ID title=STRING (subtitle=STRING)? pages=INT ('sequelof'
> sequelof=[Book])? ('hardbook'|'paperbook');
>
>
> Here is my editot content
>
> Book J1234 "Title" 1 hardbook
> Book book1 "Title" 2 paperbook
> Book book2 "Title" "Subtitle" 2 hardbook
> Book book3 "Title" "Subtitle" 2 hardbook
> Book id "ss" "Subtitle" 1
> Book book4 "Title" "Subtitle" 1 sequelof book3 paperbook
>
>
> whatever I insert after "sequelof" I got an error message
>
> Couldn't resolve reference to Book 'book3'
> no viable alternative at input 'Book'
>
>
Previous Topic:Problem generating in Xtext 2.0
Next Topic:Replacing Scopes.allInResource method in xtext2.0.0
Goto Forum:
  


Current Time: Wed Apr 24 19:34:07 GMT 2024

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

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

Back to the top