android - ANTLR 和 Android

标签 android antlr

有没有关于如何在 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
~~~~~~~~

  1. lunch the appropriate target
  2. make AntlrJavaRuntime
  3. verify that AntlrJavaRuntime.xml was placed in /system/etc/permissions and AntlrJavaRuntime.jar was placed in /system/framework
  4. after this, you can run a normal make

在我看来,唯一的区别是当您想在 Android 设备(或模拟器)上运行解析器时,您必须在 Android 项目/应用程序中包含 AntlrJavaRuntime。

因此,编写语法、从所述语法生成解析器和词法分析器将与在“普通”机器上相同。这是之前的问答,展示了如何编写简单的表达式解析器:ANTLR: Is there a simple example?

编辑

另请参阅此问答:android ANTLR make not working properly

关于android - ANTLR 和 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596609/

相关文章:

android - 在 finish() 之后,发布到 Activity 的 Handler 的 Runnables 将继续执行多长时间?

android - android中的分段recyclerview标题和子项目

android - 在android中使用WebView获取最新的webkit版本

java - ANTLR序列化

regex - 我们如何将正则表达式转换为 ANTLR 4 表达式

java - AsyncTask 不断提供输出并更新我的列表

android - 位图大小超出了 Android 上的 VM 预算错误

C++、ANTLR 和 VECTORS

java - ANTLR:通过stringtemplate将修改后的AST翻译成java源码

c# - 使用 ANTLR4 解析并返回 double 列表