2007年12月22日星期六

ANTLR

(Suppose antlr.jar is in C:\)
(1)java -classpath C:\antlr.jar antlr.Tool test.g
(2)write main, with generated files, compile and run

test.g:
class CaculatorParser extends Parser;
expr: INT PLUS INT;

class CaculatorLexer extends Lexer;
PLUS : '+' ;
INT : ('0'..'9')+ ;

没有评论: