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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:34:20+00:00 2026-06-15T21:34:20+00:00

The issue we’re having with ANTLR is that we have a grammar that’s parsing

  • 0

The issue we’re having with ANTLR is that we have a grammar that’s parsing something like this:

Hello, my name is bob.
bob offset: 5

Keep in mind that the “bob.” in the first line is dynamic, and could be anything. One of those things is “bob”. The “bob offset” line is not dynamic, and is in every file of the type that we are parsing.

So, to parse this, we have a couple of rules:

greeting: 'Hello, my name is' id1=IDENT '.' NEWLINE
    { System.out.println("Name: " + $id1.text"); }
    ;

bob_offset: 'bob offset:' id1=5 NEWLINE
    { System.out.println("bob offset: " + $id1.text); }
    ;

So, the issue is that ‘bob offset:’ is a token that the lexer reads. Now, when the greeting rule goes, an error is thrown because it’s trying to match ‘bob’ to ‘bob offset:’, but it can’t.

The solution that would be ideal is if ANTLR had some way to specify context- or parser rule-specific lexer rules. This way, the ‘bob offset:’ token wouldn’t be mistaken anywhere else in the grammar.

Any thoughts on this issue would be appreciated.

  • 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-15T21:34:21+00:00Added an answer on June 15, 2026 at 9:34 pm

    We ended up having to work around this with more parser rules to flesh it out more specifically for ANTLR.

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

Sidebar

Related Questions

Issue is that I have one value that is returned by $(this).attr(ows_Modified); //(Sharepoint and
Issue: I have a markup like this (only the important lines): <%@ Control Language=C#
Issue What is your strategy for building a desktop-like webapp that needs to be
Issue I'm planning on making a lightbox-like project page. I want to have it
Issue is related to this and this . The problem is that when a
Issue is that I can't change a column type to 'Text' This is the
Issue adding on change event to a control. I currently have a page that
Issue I have a report in CR 2008 that I inherited from someone else
Issue is only with Safari: I have three tabs that each show a div
Issue is that I have wrote a method to duplicate selected row in a

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.