[antlr-interest] Problems getting ANTLR lexer to distinguish ML comments from JavaDoc comments

lfastrup lfastrup at yahoo.com
Mon Jul 1 09:23:34 PDT 2002


I writing a small Java parser using ANTLR 2.7.1. I have based it on
the java.g for the Java 1.3 grammer. But I also need to parse all
JavaDoc comments. But I hit a wall when trying to get the JavaLexer to
skip normal multiline (/* ... */) comments but not JavaDoc comments 
(/** .... */). Here is an excerpt from my java.g file where I have 
tried to implement this separation:

    "/*" ~'*'
    ( // see comments on NEWLINE
      options {
      { LA(2)!='/' }? '*'
    | ~('*'|'\n'|'\r')
    { $setType(Token.SKIP); }

  : "/**" { Main.selector.push("doclexer"); }

It compiles ok, but when I run it I get the following error message:

Exception in thread "main" java.lang.ClassFormatError: JavaLexer (Code
of a method longer than 65535 bytes)

Do you know this bug or just a smarter way to solve my problem in the

Lars Fastrup


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list