dcsimg
Understanding error: Label 'XX' has already been defined
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dmitriy_Neyman
Posted On:   Friday, September 20, 2002 03:07 PM

Error: Label 'X' has already been defined. Hi, I am trying to upgrade existing grammar file (lets say My.g). Originally it was compiled with Antlr 2.6.1. Prior to upgrade I decided to recompile My.g with the latest version of Antlr 2.7.2A2 in order to take advantage of all improvements. But I am receiving an error: "My.g:###:##: Label 'a' has already been defined. Exiting due to errors." in all rules of the following nature: (simplified down to the point): CaseNodes returns [CMyNode *pNode] { pNode = NULL ; } : "null" { pNode = new CMyNode (CMyNode::Null) ; } | a:CASE1 { pNode = new CMyNode (CMyNode::case1); }    More>>
Error: Label 'X' has already been defined.




Hi,


I am trying to upgrade existing grammar file (lets say My.g). Originally it was compiled with Antlr 2.6.1.


Prior to upgrade I decided to recompile My.g with the latest version of Antlr 2.7.2A2 in order to take advantage of all improvements.


But I am receiving an error:



"My.g:###:##: Label 'a' has already been defined. Exiting due to errors."
in all rules of the following nature: (simplified down to the point):

			
CaseNodes returns [CMyNode *pNode]
{ pNode = NULL ; }
:
"null" { pNode = new CMyNode (CMyNode::Null) ; }
| a:CASE1 { pNode = new CMyNode (CMyNode::case1); }
| a:CASE2 { pNode = new CMyNode (CMyNode::case2); }
| a:CASE3 { pNode = new CMyNode (CMyNode::case3); }
| a:DEFAULT { pNode = new CMyNode (CMyNode::dflt ); }
. . .
{
pNode->t_ = a;
}
;


I figured that if I modify this rule to be:



			
CaseNodes returns [CMyNode *pNode]
{ pExpr = NULL ; }
:
"null" { pNode = new CMyNode (CMyNode::Null) ; }
| a:CASE1 { pNode = new CMyNode (CMyNode::case1); pNode->t_ = a; }
| a1:CASE2 { pNode = new CMyNode (CMyNode::case2); pNode->t_ = a1;}
| a2:CASE3 { pNode = new CMyNode (CMyNode::case3); . . .}
| a3:DEFAULT { pNode = new CMyNode (CMyNode::dflt ); . . .}
. . .
;



errors are gone , but this will require huge amount of changes in the existing grammar file,
and some of them are very messy.



How come this was not a problem before ? Is there are more ellegant way to solve it ?
Please, help . . .




Thank you,
Dmitriy (Dmitriy.Neyman@Embarcadero.com)



   <<Less

Re: Understanding error: Label 'XX' has already been defined

Posted By:   Monty_Zukowski  
Posted On:   Monday, September 23, 2002 08:03 AM

I don't think there is an easy work around for this. Your best bet would be to dig into the code generator to see how this works. I think the label handling is naive and wants to declare it every time it sees it.
About | Sitemap | Contact