带有 ANTLR 或 ANTLR3 的 LL(1) 表驱动编译器 [英] LL(1) table-driven compilers with ANTLR or ANTLR3

查看:51
本文介绍了带有 ANTLR 或 ANTLR3 的 LL(1) 表驱动编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 ANTLR 或 ANTLR3 创建一个 LL(1) 表驱动(非递归)编译器?

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

推荐答案

没有

然而,由于 ANTLR 是开源的,你可以修改 ANTLR 的一个分支来做到这一点.

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

ANTLR 将词法分析器和解析器构建为递归下降源代码.这就是 ANTLR 易于使用和流行的原因,因为人们可以查看源代码并了解词法分析器和解析器与查看表条目相比如何工作.因为是源代码,所以也可以使用工具来调试源代码.如果 ANTLR 使用表格而不是源代码输出,那么对于那些自己学习词法和解析的人来说,它会失去容易理解和有用性.

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.

这篇关于带有 ANTLR 或 ANTLR3 的 LL(1) 表驱动编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆