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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:45:49+00:00 2026-06-04T14:45:49+00:00

I need to parse files generated by a third-party application. Using ANTLR, I have

  • 0

I need to parse files generated by a third-party application. Using ANTLR, I have constructed a parser that seemed to work fine, until I hit the following snag.

The file type is line-based and uses several keywords to define a hierarchical structure; so-called ‘blocks’, which themselves can have sub-blocks, and so on. Depending on the type of the current block, various lines have a special meaning, e.g. in one particular block, line #5 (relative to the block’s start) holds the author of the file, in another, line #3 is a file name, etc. All of these are essentially strings, i.e. the user can input anything they want for data when creating the file; but the fact that they are strings is known only implicitly, through the line number.

Because there are no quotation marks or anything to identify these strings by, my lexer occasionally tokenizes part of these texts (like numbers, or words that are identical to keywords), with the result that I can’t reliably reconstruct the original strings from the tokens in the parser’s rules.

Is it possible to handle this kind of file with a parser generator like I’m trying to? Since I am not very well-versed in parser construction, I hope there is a simple workaround or feature of ANTLR that will help overcome this small issue.

  • 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-04T14:45:50+00:00Added an answer on June 4, 2026 at 2:45 pm

    Do not use ANTLR or Yacc or any other similar tool for parsing such a grammar (with no distinct and context-independent set of pre-defined tokens).

    A lexerless approach (like Packrat, or any other way of interpreting PEGs) would be better.

    There are many Packrat implementations around, and it is not that difficult to code an ad hoc recursive descent PEG parser in any language, without any third party tools, especially for a trivial grammar with no specific performance requirements.

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

Sidebar

Related Questions

I have a couple of XML files that I need to work with, and
I need a PHP Regex that can parse .strings files. In particular, it needs
I have an XML file which I need to parse using PHP and send
I am writing a parser to parse incoming text files. I have it to
I have a very large XML file that I need to parse so I
I have a bunch of javascript files I need to parse via PHP (I
Using pycparser to parse a slew of .c source files, but the parser can't
Need to parse a file for lines of data that start with this pattern
I need to parse the bytes from a file so that I only take
I've got some HTML files that need to be parsed and cleaned, and they

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.