Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext (Xbase) QualifiedName not parsed completely
Xtext (Xbase) QualifiedName not parsed completely [message #1230577] Sun, 12 January 2014 12:29 Go to next message
Peter Moran is currently offline Peter MoranFriend
Messages: 1
Registered: January 2014
Junior Member
Hello guys,

I need little help with understanding and fixing a problem, why Xtext parser stops parsing after finding a keyword from a language, even tough the syntax says something else.

I am using the xtext wizard from eclipse to create the Hello language, and then I just change the grammar section to be based on Xbase.
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase

generate myDsl ...

	'Hello' name=QualifiedName '!';

and add this to the model inferrer
for (greeting : model.greetings) 
	acceptor.accept(greeting.toClass( QualifiedName.create( )).initializeLater
		members += greeting.toMethod("hello" +, greeting.newTypeRef(typeof(String))) 
			body = [ append('''return "Hello Ā«greeting.nameĀ»";''') ]

then generate the code and run eclipse afterwards everything seems to work as expected, but when I write
Hello test.Hello!

the '.' and '!' get underlined and Hello is highlighted. The outline shows two elements which is wrong and
model inferrer is called twice. First time for 'test' Qualified name and second an empty string.
I expected that the inferrer would be called once with 'name' set to test.Hello
  ValidID (=>'.' ValidID)*;
Re: Xtext (Xbase) QualifiedName not parsed completely [message #1230705 is a reply to message #1230577] Sun, 12 January 2014 21:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13655
Registered: July 2009
Senior Member

you have to escape keywords using ^Hello
use a special rule instead of validid

MyValidID (=>'.' MyValidID)*;

MyValidID: ValidID | 'Hello';

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:Xtext Parser - Enhance parsed model
Next Topic:[XBase] XBaseScopeProvider and declarative scoping
Goto Forum:

Current Time: Tue Nov 24 03:44:29 GMT 2020

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

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

Back to the top