ANTLR 和安卓 [英] ANTLR and Android
问题描述
有没有关于如何在 Android 上使用 ANTLR 的指南?我找到了一些适用于 Android 的 ANTLR 移植,但看起来没有任何教程或手册.你知道在哪里可以找到一些吗?(是的,我一直在谷歌搜索...)
is there any guide how to use ANTLR on Android? I have found some ANTLR portation for Android but it looks like being without any tutorial or manual. Do you know where to find some? (and yes, I have been googling...)
谢谢
推荐答案
从这里阅读 README 后 ANTLR 端口:
After reading the README from this ANTLR port:
AntlrJavaRuntime - Earlence Fernandes,CRePE 项目,阿姆斯特丹 VU~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AntlrJavaRuntime - Earlence Fernandes, The CRePE Project, VU Amsterdam ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Runtime 可用作应用可以链接的外部库.它提供了必要的机制来执行由 ANTLR 工具生成的词法分析器/解析器代码.该模型是离线的,因为解析器/词法分析器是在台式计算机上的移动电话上生成的.生成的文件被传输到一个 Android 项目,然后该项目使用这个库.
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
~~~~~~~~
- 与合适的目标共进午餐
- 制作 AntlrJavaRuntime
- 验证 AntlrJavaRuntime.xml 是否放在/system/etc/permissions 中,AntlrJavaRuntime.jar 是否放在/system/framework 中
- 此后,您可以运行正常的 make
在我看来,唯一的区别是当您想在 Android 设备(或 -emulator)上运行解析器时,您必须在 Android 项目/应用程序中包含 AntlrJavaRuntime.
It seems to me that the only difference is when you want to run your parser on an Android device (or -emulator) you must include the AntlrJavaRuntime in your Android project/app.
因此,编写语法、从所述语法生成解析器和词法分析器与在普通"机器上相同.这是之前的问答,展示了如何编写一个简单的表达式解析器:ANTLR: Is there一个简单的例子?
So, writing the grammar, generating a parser and lexer from said grammar would be the same as on a "normal" machine. Here's a previous Q&A that shows how to write a simple expression parser: ANTLR: Is there a simple example?
另见此问答:android ANTLR 使无法正常工作
这篇关于ANTLR 和安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!