Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Solved] Xtext fails to parse my text file(Resulting EObject has a null value)
[Solved] Xtext fails to parse my text file [message #1124175] Thu, 03 October 2013 09:02 Go to next message
Charles Bonneau is currently offline Charles BonneauFriend
Messages: 32
Registered: February 2010
Location: Belgium
Member
Hello,
I have to "fix" a grammar developed by someone else.
This grammar contains these rules:
 
VarAccess:
	varName=SingleVar (('[' {VarAccess.ArrayAccess=current} index=SignedInt ']') | ('.'{VarAccess.MemberAccess=current}attributeName=NAME))*;

SingleVar:
	'$'name=NAME;

SignedInt:
	('+' | '-')? UNSIGNED_INT;

terminal UNSIGNED_INT:
	('1'..'9') ('0'..'9')* | '0';

terminal NAME:
	('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9')*;


But when I load a file containing this text :
$as[0]

I end up with a model where <VarAccessEObject>.getVarName().getName() is null (it should be "as").

I can't figure out what is wrong with this grammar and why the attribute 'name' of the 'SingleVar' object is null.
Do you see something that is not right in the code snippet ?

Thank you in advance for you help.

Charles

[Updated on: Thu, 03 October 2013 10:05]

Report message to a moderator

Re: Xtext fails to parse my text file [message #1124224 is a reply to message #1124175] Thu, 03 October 2013 10:02 Go to previous message
Charles Bonneau is currently offline Charles BonneauFriend
Messages: 32
Registered: February 2010
Location: Belgium
Member
Ok after some digging I finally found why the value was null.
It's because of this Action
{VarAccess.ArrayAccess=current}

The value of the parsed rule SingleVar is not assigned to the attribute 'varName' but to the attribute 'arrayAccess' of VarAccess.
The value I'm looking for can be accessed this way : <VarAccessEObject>.getArrayAccess().getName()
and not that way:
<VarAccessEObject>.getVarName().getName()

Sorry about that. Embarrassed

Best regards,

Charles
Previous Topic:Code generation error messages
Next Topic:Change IResourceClusteringPolicy
Goto Forum:
  


Current Time: Tue Apr 16 05:39:51 GMT 2024

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

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

Back to the top