有没有关于如何在 Android 上使用 ANTLR 的指南?我找到了一些适用于 Android 的 ANTLR 移植,但看起来没有任何教程或手册。你知道在哪里可以找到一些吗? (是的,我一直在谷歌搜索......)
谢谢
最佳答案
阅读此 ANTLR port 中的自述文件后:
AntlrJavaRuntime - Earlence Fernandes, The CRePE Project, VU Amsterdam ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Runtime is available as an external library against which apps can link. It provides the necessary mechanisms to execute Lexer/Parser code generated by the ANTLR tool. The model is offline, in the sense that the parser/lexer is generated off the mobile phone on a desktop computer. The resulting files are transferred to an Android project which then uses this library.
Building
~~~~~~~~
- lunch the appropriate target
- make AntlrJavaRuntime
- verify that AntlrJavaRuntime.xml was placed in /system/etc/permissions and AntlrJavaRuntime.jar was placed in /system/framework
- after this, you can run a normal make
在我看来,唯一的区别是当您想在 Android 设备(或模拟器)上运行解析器时,您必须在 Android 项目/应用程序中包含 AntlrJavaRuntime。
因此,编写语法、从所述语法生成解析器和词法分析器将与在“普通”机器上相同。这是之前的问答,展示了如何编写简单的表达式解析器:ANTLR: Is there a simple example?
编辑
关于android - ANTLR 和 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596609/