| Forcing two values to be equal or force a certain reference? [message #655403] | 
Sun, 20 February 2011 11:26   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hello, 
 
I started converting an existing VHDL grammar to XText. I am completely new to the subject and don't know much about grammars and parsers and lexers apart from what I learned at university. 
 
Here's what I have so far: 
 
entity_name :
	name=ID;
entity_declaration returns entity: 
"entity" entityId=entity_name "is" ED=entity_declarative_part ( "begin" ESP=entity_statement_part )? "end" ( "entity" )? ( ends=entity_reference )? ";"  ;
entity_reference:
	reference=[entity_name];  
 
For example: 
entity myName is ... 
begin 
... 
end entity myName; 
 
The requisition is that the value after "end entity" is the name of the entity. How would I do that? Is that some part of linking? Or scoping? Can this be done directly in the grammar? 
 
I got it that the "end entity [reference]" worked, but it only checks for a reference to *any* entity, not to the one just declared. So I either want to make this refer to one particular entity or just force the two values to be equal. 
 
Thanks a lot in advance. I try to find as much information as I can in the documentation and this forum, but haven't found out how to solve this problem. 
 
Simon
[Updated on: Sun, 20 February 2011 11:36] by Moderator  
 |  
 |  
  | 
 | 
 | 
 | 
 | 
| Re: Forcing two values to be equal or force a certain reference? [message #655423 is a reply to message #655421] | 
Sun, 20 February 2011 14:03   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
the error message would be a bit mysterious "could not resolve reference to ..." (in a sense an automatic validation, whether a referrable element exists) 
Quick fix is not that much of a problem here (in my opinion), as content assist would immediately yield the only valid element (content assist for references is fed by scoping). So this is indeed a thing to consider. 
 
In a sense, in this use case scoping gives you validation and content assist for free (with the slight drawback of the generic error message). 
 
Alex
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.05119 seconds