Download presentation
Presentation is loading. Please wait.
Published byRoss Preston Modified over 9 years ago
1
ANTLR Andrew Pangborn & Zach Busser
2
ANTLR in a Nutshell ANother Tool for Language Recognition generates lexers generates parsers (and parse trees) Java-based, but has runtime implementations in other languages like python, javascript, c, c#, obj-c An LL(*) parser EBNF grammar notation
3
ANTLR Features Hierarchical lexical rules Abstract Syntax Tree generation Inline code execution Tree grammars
4
ANTLR Pros Target languages besides Java – C, python, Javascript, etc. LL(*) - not limited to 1 lookahead token Simpler to debug than LALR grammars (no cryptic shift-reduce / reduce-reduce errors) ANTLRWorks
5
ANTLR Shortcomings An LL parser – cannot support left-recursive grammars like YACC or PJ2 Recursive descent approach not great for efficiency No mechanism for specifying operator precedence
6
Getting started with ANTLR http://www.antlr.org/wiki/display/ANTLR3/FAQ+- +Getting+Started http://www.antlr.org/wiki/display/ANTLR3/FAQ+- +Getting+Started
7
Demo Time! A simple 4-function expression parser 4-function expression evaluator AST generation example
8
References http://www.corriganjc.net/weblog/archives/2007/06/ the_antlr_trini.html http://www.corriganjc.net/weblog/archives/2007/06/ the_antlr_trini.html http://www.antlr.org/wiki/display/ANTLR3/ANTLR+v 3+documentation http://www.antlr.org/wiki/display/ANTLR3/ANTLR+v 3+documentation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.