Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to ANTLR Jin Tianxing 5110309085.

Similar presentations


Presentation on theme: "Introduction to ANTLR Jin Tianxing 5110309085."— Presentation transcript:

1 Introduction to ANTLR Jin Tianxing

2 What ANTLR do All ANTLR need is a grammar file where the syntactic rule is defined. The output of ANTLR is a Lexer and a Parser written with Java.

3 About Versions ANTLR 3.5 ANTLR 4 Tree-rewrite enabled(AST)
No GUI Interface to display trees ANTLR 4 Tree-rewrite disabled(Parsing tree) GUI Interface

4 Grammar grammar example; prog: (expr NEWLINE)* ; expr: INT (OP expr)?
NEWLINE: ('\r' | '\n')+; INT: ('0'..'9')+; OP: '+' | '-' | '*' | '/'; However, using this grammar still produce a Parsing Tree.

5 Tree-Rewrite(ANTLR 3.x)
Option: output=AST Different ways of Rewrite: expr: INT (OP^ expr); expr: INT (OP expr) -> ^(OP INT expr); expr: ‘(‘! expr^ ‘)’!; ANTLR 4.x does not support rewrite


Download ppt "Introduction to ANTLR Jin Tianxing 5110309085."

Similar presentations


Ads by Google