显示标签为“Computer.Development.Compiler”的博文。显示所有博文
显示标签为“Computer.Development.Compiler”的博文。显示所有博文

2007年12月31日星期一

Compilers & Interpreters

【ANTLR】
ANTLR

【JavaCC】

【JFlex】

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')+ ;