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 7894561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:25:38+00:00 2026-06-03T07:25:38+00:00

I recently purchased The Definitive ANTLR Reference and I am excited to begin using

  • 0

I recently purchased The Definitive ANTLR Reference and I am excited to begin using ANTLR.
In the first chapter, this grammar is shown:

grammar T;

options {
    language = Java;
}

r : 'call' ID ';' {System.out.println("invoke " + $ID.text);} ;
ID : 'a'..'z'+ ;
WS : (' '|'\n'|'\r')+   {$channel=HIDDEN;} ;

I copied this grammar down into a file, (.g extension), generated the Lexer and Parser, and created a main class like so:

import org.antlr.runtime.*;

public final class Test {
    public static void main(String[] args) throws Exception {
        ANTLRInputStream input = new ANTLRInputStream(System.in);
        TLexer lexer = new TLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        TParser parser = new TParser(tokens);

        parser.r();
    }
}

There are no real errors, but when I run the main class and enter:

call foo;

Nothing happens. “invoke foo” should be outputted to the screen, but nothing happens. I don’t want to go on in the book without completing any one exercise. I’m using ANTLR 3.4 in Eclipse if it matters. Sorry if this seems like an easy question, but I’m new to ANTLR.

Thanks,
Omer

  • 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-06-03T07:25:39+00:00Added an answer on June 3, 2026 at 7:25 am

    You need to enter the EOF character.

    For UNIX based systems it is Ctrl-D.

    For Windows based systems it is Ctrl-Z.

    EDIT

    Since you are entering input via the console, and ANTLR is reading the data as a stream, it needs the EOF. Later in the book you will be entering data via a file and the file’s EOF will end the stream. You can also save the input to a file, and then pipe the input from the file into the command.

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

Sidebar

Related Questions

I recently purchased a copy of Practical Android Projects . Chapter 8 talks about
I've recently purchased Samsung Galaxy Android phone after using Openmoko phone for 2 years.
I recently purchased an XBox 360 and was first introduced to the term Media
I recently purchased an authenticode certificate from globalsign and am having problems signing my
I've recently purchased a Mac and use it primarily for C# development under VMWare
While not entirely programming related. I recently purchased a SSL certificate, and during the
I have a asp.net web site built with .net 2.0 framework. we recently purchased
Recently I was trying some practice programs in python and I came across this
I recently purchased PAF files from the Royal Mail. I've received them all but
I recently purchased a virtual server from Hetzner.de, and am trying to use it

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.