>java org.antlr.tool.Interp 文法ファイル WS トップレベル? 入力ファイル

てやると,何か構文木っぽいものが出てくる.

たとえば,

>java org.antlr.tool.Interp SimpleC.g WS program input

なら

input:

char c;
int x;

void bar(int x);

int foo(int y, char d) {
  int i;
  for (i=0; i<3; i=i+1) {
    x=3;
    y=5;
  }
}

こんなのが.

(<grammar SimpleC> (program (declaration (variable (type char) (declarator c) ;)) (declaration (variable (type int) (declarator x) ;)) (declaration (functionHeader (type void) bar ( (formalParameter (type int) (declarator x)) )) ;) (declaration (functionHeader (type int) foo ( (formalParameter (type int) (declarator y)) , (formalParameter (type char) (declarator d)) )) (block { (variable (type int) (declarator i) ;) (stat (forStat for ( (assignStat i = (expr (condExpr (aexpr (atom 0))))) ; (expr (condExpr (aexpr (atom i)) < (aexpr (atom 3)))) ; (assignStat i = (expr (condExpr (aexpr (atom i) + (atom 1))))) ) (block { (stat (assignStat x = (expr (condExpr (aexpr (atom 3))))) ;) (stat (assignStat y = (expr (condExpr (aexpr (atom 5))))) ;) }))) }))))

エラーハンドリングが厄介そうなのと,ANTLRと独立して動かせないことを除けば使えなくはない?