LL(1) table-driven compilers with ANTLR or ANTLR3

2019-07-24 14:44发布

问题:

Is it possible to create a LL(1) table-driven (non-recursive) compiler with ANTLR or ANTLR3 ?

回答1:

No.

However since ANTLR is open source you could modify a fork of ANTLR to do it.

ANTLR builds lexers and parsers as recursive descent source code. This is why ANTLR is easy to use and popular because people can look at the source code and understand how the lexer and parser work versus looking at table entries. Because it is source code, one can also use tools to debug the source code. If ANTLR used tables instead of source code output it would lose its ease of understanding and usefulness for those learning lexing and parsing on their own.