[antlr-interest] Antlr 2.7.2a2 Report

Christian Ernst Christian.Ernst at poet.de
Wed Feb 6 04:30:22 PST 2002


Robert Colquhoun wrote:

>1) This is a totally trivial thing, but when generating bitsets in the lexer:
>
>   private static final long[] mk_tokenSet_1() {
>         long[] data = new long[8];
>         data[0]=-576460752303432712L;
>         for (int i = 1; i<=3; i++) { data[i]=-1L; }
>         for (int i = 4; i<=7; i++) { data[i]=0L; }
>         return data;
>     }
>
>Initializing the array to 0L is not needed as java does this 
>automatically(only matters for unicode with lots of bitsets, and even then 
>not much).
>
You are right
i checked that

Terence could you add follwing for 2.7.2a3 ?

JavaCodeGenerator.java
Line 1287:
-----------------------------
                   // j-1 is last member of run
                    println("\tfor (int i = "+i+"; i<="+(j-1)+"; i++) { 
data[i]="+
                            elems[i]+"L; }");
------------------------------
to:
-------------------------------
// skip the generation of a loop if member are 0L which is Java default
if ( elems[i] != 0 ) {
                   // j-1 is last member of run
                    println("\tfor (int i = "+i+"; i<="+(j-1)+"; i++) { 
data[i]="+
                            elems[i]+"L; }");
}
-------------------------------

mfg
Christian



More information about the antlr-interest mailing list