ANTLR and Android

后端 未结 3 1800
抹茶落季
抹茶落季 2020-12-18 13:12

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 fi

3条回答
  •  余生分开走
    2020-12-18 13:56

    After reading the README from this 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

    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.

    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?

    EDIT

    Also see this Q&A: android ANTLR make not working properly

提交回复
热议问题