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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:44:27+00:00 2026-05-17T02:44:27+00:00

I am new to JFlex. I have gathered that JFlex is a parser generator.

  • 0

I am new to JFlex. I have gathered that JFlex is a parser generator.
However, I am still not clear about the following and need clarification around the same.

  1. How different this is from using regex for pattern identification and data segregation and what are the additional benefits of using JFlex.

  2. Any specific use case where JFlex is useful over regex.

  3. Is it anyways useful for general parsing , say of text / xml files ?

Thanks in advance.

  • 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-17T02:44:28+00:00Added an answer on May 17, 2026 at 2:44 am

    JFlex is not a parser generator, but a scanner generator. It tokenizes the input. Use it in combination with a parser generator like CUP or BYACC/J.

    There’s an important difference among scanner and parser:

    • A scanner can recognise a Regular Language, whereas
    • A parser can recognise a Context-Free Language.

    Your questions:

    1) and 2) Suppose that you have to convert an input stream of characters into a stream of tokens, given the following patterns:

    • if the input matches [0-9]+ (something different than \. follows) then it’s an unsigned integral. Send "INTEGER" to the output.
    • if the input matches [0.9]+\.[0-9]* then it’s an unsigned floating point. Send "FLOAT" to the output.

    Note that they share a common prefix. If you want to scan the input with regular expressions, you’ll have to split them in their common prefix (unless you want it to be very slow since regexes are expensive). At runtime, you’ll have to first evaluate the prefix, if matches, then evaluate what follows, if ^\., you have an integral and will start over again, if \. you will have to evaluate if the following text is the mantissa of a floating point number. If so, you have a FLOAT.

    Basically what you have to build is a finite state automaton in which states are points of decision and reflect the input seen so far, and transitions are evaluations on the current character seen in the input.

    JFlex (as many other scanner generators) will allow you to generate the code for such automata automatically, by only providing regexes (basically). And will generate very efficient code for it.

    3) You can use a generated scanner and a generated parser in tandem to recognise any context-free languages. Such as programming languages. Although it should be possible to parse XML with it (I’ve never tried), specific-purpose parsers are usually used for XML (such as SAX, StAX, etc, etc) since XML has a well-known structure and then no need to generate a parser .

    BTW, please bear in mind that you cannot parse XML with Regex. 😉

    Regards.

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

Sidebar

Related Questions

I'm fairly new to JFlex and JSyntaxPane although I have managed to hack together
I have a new web app that is packaged as a WAR as part
New to DDD here and have a architecture question which should be a typical
New guy here so bear with me. Ive got a basic XSL file that
New to the MVC.net scene (and .net for that matter), but seems I find
New to Objective C. I have created a few directories which contain pdf files
I have found this example on StackOverflow: var people = new List<Person> { new
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
New class is a subclass of the original object It needs to be php4

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.