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 ...

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=QualifiedName '!';

and add this to the model inferrer
for (greeting : model.greetings) 
{
	acceptor.accept(greeting.toClass( QualifiedName.create(greeting.name) )).initializeLater
	[
		members += greeting.toMethod("hello" + greeting.name, 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!

index.php/fa/17218/0/
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.
index.php/fa/17219/0/
I expected that the inferrer would be called once with 'name' set to test.Hello
QualifiedName:
  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: 13493
Registered: July 2009
Senior Member
Hi,

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

QualifiedName:
MyValidID (=>'.' MyValidID)*;

MyValidID: ValidID | 'Hello';


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext Parser - Enhance parsed model
Next Topic:[XBase] XBaseScopeProvider and declarative scoping
Goto Forum:
  


Current Time: Fri Jul 10 06:25:53 GMT 2020

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

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

Back to the top