Does ASTParser process goto statements? [message #1707980] |
Fri, 11 September 2015 03:55  |
Eclipse User |
|
|
|
Hi,
I see that ASTParser processes not corrent gotos. Here is example, I just set breakpoint in debugger when parsing MethodDeclaration.
Real body:
Object attributeset;
if(attributeset == null)
goto _L2;
else
goto _L1
_L1:
System.out.println();
_L2:
int i = 0, j = 5;
if(i >= j)
System.out.println();
Here is parsed code:
Object attributeset;
if (attributeset == null) throw _L2;
else {
_L1 _L1;
System.out.println();
_L2: {
int i=0, j=5;
if (i >= j) System.out.println();
else ;
}
}
I see that it complitely doesn't understand gotos, and generate incorrect AST. Maybe I'm doing something wrong? If that so, please advise a solution, else please help me to edit AST parser core
[Updated on: Fri, 11 September 2015 04:15] by Moderator
|
|
|
|
|
|
|
Re: Does ASTParser process goto statements? [message #1708320 is a reply to message #1708302] |
Tue, 15 September 2015 09:25  |
Eclipse User |
|
|
|
Ivan Ivan wrote on Tue, 15 September 2015 12:28Is there a way to ignore unused keywords in this case? In the shown example invalid code isn't ignored, but replaced by wrong operations (throw and declaration of a variable)
That's called error recovery, and works by "guessing" a minimal change that results in syntactically legal code. In some situations error recovery indeed just ignores one or more tokens, but the parser would have to first understand the goto syntax (with its label argument) in order to know how much text should be ignored. This could be filed as an RFE (bugzilla), but I wouldn't give high priority to this.
Stephan
|
|
|
Powered by
FUDForum. Page generated in 0.03090 seconds