Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext (Xbase) QualifiedName not parsed completely
Xtext (Xbase) QualifiedName not parsed completely [message #1230577] Sun, 12 January 2014 07:29 Go to next message
Eclipse UserFriend
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 16:40 Go to previous message
Eclipse UserFriend
Hi,

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

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

MyValidID: ValidID | 'Hello';
Previous Topic:Xtext Parser - Enhance parsed model
Next Topic:[XBase] XBaseScopeProvider and declarative scoping
Goto Forum:
  


Current Time: Fri Jul 04 14:17:41 EDT 2025

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

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

Back to the top