Problems parsing Java with a single line comment on last line of a file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lance_Walton
Posted On:   Friday, November 1, 2002 01:25 PM

Hi all. I'm having trouble parsing Java using v1.18 of java.g supplied with the Antlr distribution. When the Java contains a single line comment on the last line of the file ( i.e. there is no return at the end of the line) the parser doesn't return and I eventually get an OutOfMemoryError. If I put a newline at the end of the comment, it parses with no problems. I believe the problem is in SL_COMMENT: // Single-line comments SL_COMMENT : "//" (~(' '|' '))* (' '|' '(' ')?) {$setType(Token.SKIP); newline();} ; but I don't know how to fix it. Can anyone help? Regards,    More>>

Hi all.

I'm having trouble parsing Java using v1.18 of java.g supplied with the Antlr distribution. When the Java contains a single line comment on the last line of the file ( i.e. there is no return at the end of the line) the parser doesn't return and I eventually get an OutOfMemoryError. If I put a newline at the end of the comment, it parses with no problems.

I believe the problem is in SL_COMMENT:

			
// Single-line comments
SL_COMMENT
: "//"
(~('
'|'
'))* ('
'|'
'('
')?)
{$setType(Token.SKIP); newline();}
;


but I don't know how to fix it. Can anyone help?

Regards,

Lance

   <<Less

Re: Problems parsing Java with a single line comment on last line of a file

Posted By:   Lance_Walton  
Posted On:   Friday, November 1, 2002 01:30 PM

Hi again.

I found this straight after I posted the above. Looks like it answers my question.

Regards,

Lance

About | Sitemap | Contact