[antlr-interest] Bug in antlr4

Terence Parr parrt at cs.usfca.edu
Sun Sep 30 15:11:39 PDT 2012


ah! Java.g4 used -> skip not -> channel(HIDDEN) in last iteration by mistake. try:

// START: COMMENT
COMMENT
    :   '/*' .* '*/'     -> channel(HIDDEN) // match anything between /* and */
    ;
WS  :   [ \r\t\u000C\n]+ -> channel(HIDDEN)
    ;
// END: COMMENT

LINE_COMMENT
    : '//' ~[\r\n]* '\r'? '\n' -> channel(HIDDEN)
    ;

in Java.g4

Ter
On Sep 30, 2012, at 4:57 AM, Tero Koskinen wrote:

> Hi,
> 
> On Sun, Sep 30, 2012 at 2:47 AM, Chris Moller <moller at mollerware.com> wrote:
>>    interface IDemo {
>>             void f(intx,Stringy);
>>             int[] g();
>>             List<Map<String,Integer>>[] h();
>>    }
> 
> I can repeat the problem on Windows 7 with JDK 1.7:
> 
> [C:\work\antlr-examples]java -cp
> output;g:\java\antlr\antlr-4.0b1-complete.jar ExtractInterfaceTool
> Demo.java
> interface IDemo {
>        void f(intx,Stringy);
>        int[] g();
>        List<Map<String,Integer>>[] h();
> }
> 
> [C:\work\antlr-examples]java -version
> java version "1.7.0_03"
> Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
> Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
> 
> [C:\work\antlr-examples]type Demo.java
> /***
> * Excerpted from "The Definitive ANTLR 4 Reference",
> * published by The Pragmatic Bookshelf.
> * Copyrights apply to this code. It may not be used to create
> training material,
> * courses, books, articles, and the like. Contact us if you are in doubt.
> * We make no guarantees that this code is fit for any purpose.
> * Visit http://www.pragmaticprogrammer.com/titles/tpantlr2 for more
> book information.
> ***/
> import java.util.List;
> import java.util.Map;
> public class Demo {
>        void f(int x, String y) { }
>        int[ ] g(/*no args*/) { return null; }
>        List<Map<String, Integer>>[] h() { return null; }
> }
> 
> [C:\work\antlr-examples]which md5sum
> md5sum is an external : C:\WinAVR-20100110\utils\bin\md5sum.exe
> 
> [C:\work\antlr-examples]md5sum g:\java\antlr\antlr-4.0b1-complete.jar
> \8216a2944a8c64fe819b450b99dd65c5 *g:\\java\\antlr\\antlr-4.0b1-complete.jar
> 
> [C:\work\antlr-examples]java -version
> java version "1.7.0_03"
> Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
> Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
> 
> Yours,
> Tero Koskinen
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list