Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cross references and the next rule without keyword
cross references and the next rule without keyword [message #1012999] Fri, 22 February 2013 15:37 Go to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Dear All,
In My grammar,
I have these rules
Transition:
	('from' initial+=InitialState)* 
         action=StatementSequence	
;

InitialState:
	origin=[StateDeclaration] (read ?= '?')?
;
StatementSequence returns Statement:
	Statement ({StatementSequence.statements+=current} ';' statements+=Statement)*
;

Statement:
        
	NullStatement //start with 'null'
	| ToStatement //start with 'to'
	| PatternStatement 

So, I have a problem when the First statement is a PatternStatement because it doesn't start with a keywork
for example:
Example 1
from a b c 
to x

No problem

Example 2
from a b c 
null

No problem

but
Example 3
from a b c 
x := y 

here, there is a problem. the x variable is considered as a [StateDeclaration]
the error is Couldn't resolve reference to StateDeclaration 'x'.


Re: cross references and the next rule without keyword [message #1013007 is a reply to message #1012999] Fri, 22 February 2013 15:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
How does PatternStatement look like?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross references and the next rule without keyword [message #1013010 is a reply to message #1013007] Fri, 22 February 2013 15:50 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
It looks to
var=[Variable] ':=' exp=Expression
Re: cross references and the next rule without keyword [message #1013016 is a reply to message #1013010] Fri, 22 February 2013 16:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hmmm,

i do not really get your problem
(besides this little typo???)

Transition:
	'from'( initial+=InitialState)* 
         action=StatementSequence	
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross references and the next rule without keyword [message #1013019 is a reply to message #1013016] Fri, 22 February 2013 16:09 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Ohhh
I am Sorry.
This is the transition rule
Transition:
	'from'( initial+=InitialState)* 
         action=StatementSequence	
;

but with this also, I have the same problem
Re: cross references and the next rule without keyword [message #1013024 is a reply to message #1013019] Fri, 22 February 2013 16:13 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
then there must be something else in your grammar here is my test


Model:
	states+=StateDeclaration*
	vars+=Variable*
	trans+=Transition
;

StateDeclaration:
	"state" name=ID
;

Variable:
	"var" name=ID
;

Transition:
	'from'( initial+=InitialState)* 
         action=StatementSequence	
;

InitialState:
	origin=[StateDeclaration] (read ?= '?')?
;
StatementSequence returns Statement:
	Statement ({StatementSequence.statements+=current} ';' statements+=Statement)*
;

Statement:
        
	NullStatement //start with 'null'
	| ToStatement //start with 'to'
	| PatternStatement ;
	
	NullStatement:
		{NullStatement}'null'
	;
	
	ToStatement:
	{ToStatement}	'to'
	;
	PatternStatement:
		var=[Variable] ':=' exp=ID
	;



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:name feature not assigned with string.
Next Topic:Use one grammar within another grammar
Goto Forum:
  


Current Time: Thu Apr 18 23:19:00 GMT 2024

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

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

Back to the top