[antlr-interest] Interpreter and Bug with Java-Genericity in ANTLR v3

Karl Gmeiner karl.gmeiner at gmail.com
Wed Mar 21 16:28:04 PDT 2007


Hello,

I am trying to create a small interpreter in Java similar to the 
Expression evaluator (I'm using ANTLRWorks 1.0b9 under MacOSX) but I 
want my instructions to be executed as soon as possible so that I can 
enter new instructions based on my previous results (just like an 
interpreter) and not after an EOF. Is there any adapted ANTLRInputStream 
or something similar for this purpose?

I also ran over a small bug: Generic return types like in the rule

condition returns [Pair<Term, Term> value]
    :    s=term '->*' t=term { $value = new Pair<Term, Term>($s.value, 
$t.value); }
    ;
(where Pair<K, V> is a generic class) are transformed to
    public static class condition_return extends ParserRuleReturnScope {
        public Pair<Term;
        public Term> value;
    };
instead of
    public static class condition_return extends ParserRuleReturnScope {
        public Pair<Term, Term> value;
    };

Thanks a lot,
Karl


More information about the antlr-interest mailing list