[antlr-interest] Outputting ASP from tinyc

edcjones <edcjones at yahoo.com> edcjones at yahoo.com
Mon Feb 3 21:01:02 PST 2003


I would like to get the tinyc example to output ASPs in some lisp-like
notation.

Here is the "Main" part of tinyc.g:

----
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            TinyCLexer lexer = new TinyCLexer(new 
                             DataInputStream(System.in));
            TinyCParser parser = new TinyCParser(lexer);
            parser.program();
            antlr.CommonAST ast = (antlr.CommonAST)parser.getAST();
            if (ast != null) {
                System.out.println(ast.toStringList());
            } else {
                System.out.println("null AST");
            }
        } catch(Exception e) {
            System.err.println("exception: "+e);
        }
    }
}
----

Here is the output:

 int i ; int * i ; int f ( char c , char * d ) { int f ; c = '\033' +
'\47' + '\'' + '\\' ; d = " \" '\\' foo" ; i = c + 3 * f ; if ( i ) {
f = c ; } else { f = 1 ; } } null

If I use toStringTree, the output is " int" only.

What am I doing wrong?



 

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



More information about the antlr-interest mailing list