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

  • Home
  • SEARCH
  • 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 7835783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:48:19+00:00 2026-06-02T13:48:19+00:00

In a typical parser generator situation (eg. ANTLR or Beaver), how might one handle

  • 0

In a typical parser generator situation (eg. ANTLR or Beaver), how might one handle the following situation:

0051A2B3C4D5E
0031G2T3H

Where it’s a 3 character numeric field that tells you how many iterations of a repeating field comes after it.

I know there are possibilities of post processing, but won’t be useful in some cases, so I’m trying to find if there is some way for the parser to handle it. It would be acceptable if there was a solution that involves interacting with the parser when it reads in the numeric field–somehow telling it to go read in the next N items based on a certain production.

  • 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-02T13:48:23+00:00Added an answer on June 2, 2026 at 1:48 pm

    Whether this is possible depends on the parser generator.

    You lexer will need to be aware of its surroundings (context sensitive). You’ll only want to create a Num token at the start of a line. In ANTLR, you can do that by adding the predicate getCharPositionInLine()==0 in front of the Num rule.

    And then in your parser rule, line, you need keep consuming Block tokens (your double chars) as long as the counter is more than zero (the counter being the value of Num).

    A quick ANTLR demo:

    grammar T;  
    
    parse
     : line* EOF 
     ;
    
    line
    @init{int n = 0;}
     : Num {n = Integer.valueOf($Num.text);} ({n > 0}?=> Block {n--;})*
     ;
    
    Num
     : {getCharPositionInLine()==0}?=> Digit Digit Digit
     ;
    
    Block
     : AlphaNum AlphaNum
     ;
    
    Space
     : (' ' | '\t' | '\r' | '\n')+ {skip();}
     ;
    
    fragment Digit : '0'..'9';
    fragment Letter : 'a'..'z' | 'A'..'Z';
    fragment AlphaNum : Letter | Digit;
    

    would parse your input:

    0051A2B3C4D5E
    0031G2T3H
    

    as follows:

    enter image description here

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

Sidebar

Related Questions

Typical SAX Parser - I am building a list out of the endElement. I
The typical Python threadpool will have a structure like this one: def run(self): while
Consider a typical social networking website, which has more or less the following models:
I have my resource and they typical overridden method to handle POST requests. public
Typical approaches recommend reading the binary via FileStream and comparing it byte-by-byte. Would a
Typical jQuery over-use: $('button').click(function() { alert('Button clicked: ' + $(this).attr('id')); }); Which can be
My typical workflow is that I develop on localhost, but with Google Apps Marketplace
For typical most typical internet facing websites when you login & leave the website
I have a typical User model (username, password, name, etc). I want to allow
I have a pretty typical bookmarklet code that's working perfectly for me in all

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.