[antlr-interest] changes between 3.2 and 3.3 that brake a 3.2 tutorial

Bart Kiers bkiers at gmail.com
Thu Jul 14 05:10:25 PDT 2011


Hi Sébastien,

Thanks!

Hmm, that is odd. If I change the parse rule into:

parse
  :  (t=. {System.out.printf("text: \%-7s  type: \%s \n", $t.text,
tokenNames[$t.type]);})* EOF
  ;


and the Main class into:

import org.antlr.runtime.*;


public class Main {
  public static void main(String[] args) throws Exception {
    TLLexer lexer = new TLLexer(new ANTLRFileStream(args[0]));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    TLParser parser = new TLParser(tokens);
    parser.parse();
  }
}


the expected output _is_ printed to the console.

Not sure why for(Object o : tokens.getTokens()) doesn't work... Will have a
look later on.

Regards,

Bart.


2011/7/14 Sébastien Kirche <sebastien.kirche at gmail.com>

> Hi,
>
> I am currently playing with the antlr-3.3-complete.jar package.
> While trying to fix a lexer token priority problem in my grammar, I
> tried to test the token listing method described in the (very useful
> !) posts from Bart Kiers about its tutorial with the TL language.
>
> My problem is that his method applied on my grammar outputs nothing.
> I banged my head against my desk for a while for looking what I did
> wrong with reusing Bart's code, until I tested his code and example
> as-is and found that it outputs nothing too...
> As the TL tutorial is build with antlr 3.2, I tried to recompile with
> 3.2 instead of 3.3 and then it is working as expected  o_O
>
> I cannot find in the 3.3 releases notes
> (http://www.antlr.org/wiki/display/ANTLR3/ANTLR+3.3+Release+Notes)
> what causes that behavior difference between 3.2 and 3.3.
>
> The specific code from Bart Kiers I have tried is from the post at
> http://bkiers.blogspot.com/2011/03/3-lexical-analysis-of-tl.html
>
> Thanks.
> --
> Sébastien Kirche
>
> 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