Skip to main content



      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 05:02 Go to next message
Eclipse UserFriend
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 06:05] by Moderator

Re: Xtext fails to parse my text file [message #1124224 is a reply to message #1124175] Thu, 03 October 2013 06:02 Go to previous message
Eclipse UserFriend
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 Jul 08 00:34:17 EDT 2025

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

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

Back to the top