Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:45:18+00:00 2026-05-31T00:45:18+00:00

I am trying to use ANTLR on Android, and I found this: ANTLR and

  • 0

I am trying to use ANTLR on Android, and I found this:
ANTLR and Android

After downloading the AntlrJavaRuntime I am not sure of what to do, I am supposed to make this:

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

First of all, what does step 1 even means?

Secondly, when I try doing: make AntlrJavaRuntime I get the following error:

~/AntlrJavaRuntime$ make AntlrJavaRuntime
make: Nothing to be done for `AntlrJavaRuntime'.

It’s very hard to find documentation about this, so any help is really appreciated (or a clear example of how to get ANTLR ready for an Android project).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:45:19+00:00Added an answer on May 31, 2026 at 12:45 am

    Well, I just did a little test with a “plain” ANTLR version, and everything went just fine.

    Here’s what I did:

    1 new Android project

    Create a new project called AndAbac (Android-Abacus) with a package named bk.andabac and an activity called AndAbac.

    2 create a grammar

    Create a grammar file called Exp.g (explanation here) anywhere on your system and paste the following in it:

    grammar Exp;
    
    @parser::header {
      package bk.andabac;
    }
    
    @lexer::header {
      package bk.andabac;
    }
    
    eval returns [double value]
     : exp=additionExp {$value = $exp.value;}
     ;
    
    additionExp returns [double value]
     : m1=multiplyExp       {$value =  $m1.value;} 
       ( '+' m2=multiplyExp {$value += $m2.value;} 
       | '-' m2=multiplyExp {$value -= $m2.value;}
       )* 
     ;
    
    multiplyExp returns [double value]
     : a1=atomExp       {$value =  $a1.value;}
       ( '*' a2=atomExp {$value *= $a2.value;} 
       | '/' a2=atomExp {$value /= $a2.value;}
       )* 
     ;
    
    atomExp returns [double value]
     : n=Number                {$value = Double.parseDouble($n.text);}
     | '(' exp=additionExp ')' {$value = $exp.value;}
     ;
    
    Number
     : ('0'..'9')+ ('.' ('0'..'9')+)?
     ;
    
    WS  
     : (' ' | '\t' | '\r'| '\n') {$channel=HIDDEN;}
     ;
    

    3 download ANTLR & generate lexer/parser

    Download ANTLR here: http://www.antlr3.org/download/antlr-3.3-complete.jar and put it in the same directory as your Exp.g file. Generate a lexer and parser (explanation here) and copy the generated .java files to the following folder in your Android project: src/bk/andabac. Also put this ANTLR jar to the classpath of your Android project.

    4 change some project files

    Paste the following in res/layout/main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <EditText
            android:id="@+id/input_text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="5 * (8 + 2)"
            />
        <Button
            android:id="@+id/parse_button"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="eval" />
        <TextView
            android:id="@+id/output_text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text=""
            />
    </LinearLayout>
    

    and the following in src/bk/andabac/AndAbac.java:

    package bk.andabac;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import org.antlr.runtime.ANTLRStringStream;
    import org.antlr.runtime.CommonTokenStream;
    import org.antlr.runtime.RecognitionException;
    
    public class AndAbac extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.main);
    
            final Button button = (Button)findViewById(R.id.parse_button);
    
            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
    
                    EditText in = (EditText)findViewById(R.id.input_text);
                    TextView out = (TextView)findViewById(R.id.output_text);
    
                    String source = in.getText().toString();
                    ExpLexer lexer = new ExpLexer(new ANTLRStringStream(source));
                    ExpParser parser = new ExpParser(new CommonTokenStream(lexer));
    
                    try {
                        out.setText(source + " = " + parser.eval());
                    }
                    catch (RecognitionException e) {
                        out.setText("Oops: " + e.getMessage());
                    }
                }
            });
        }
    }
    

    5 test the app

    Either run the project in an emulator, or create an APK file and install this on an Android device (I tested both, and both worked). You will see the following after pressing the eval button:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying use a set of filter functions to run the appropriate routine,
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I am trying use javascript regular expressions to do some matching and I found
Trying to use this sql statement. The first 2 parts work fine, I am
I'm trying to use Antlr for some text IDE-like functions -- specifically parsing a
I'm trying to use ANTLR in my C++ project. I made a target for
According to these instructions , I'm trying to use ANTLR generated *.as files in
I'm trying to learn to use ANTLR, and seem to have come across an
I'm trying to create a very simple grammar to learn to use ANTLR but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.