[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

Building a Text parser using lex/yacc

I am trying to build a text parser in Java and hope to find a lex/yacc combo.  I have found JLex that looks like a good lexer but I am having trouble finding yacc.

Any suggestions?  Examples would be good to.

Thanks
0
whitej8
Asked:
whitej8
1 Solution
 
Jim CakalicSenior Developer/ArchitectCommented:
Having experience myself with lex/yacc, I found JavaCC to be reasonably intuitive. The original implementation was by Sun, subsequently moved to Metameta which is now a wholly owned subsidiary of WebGain. However JavaCC is still legally owned by Sun -- WebGain is referred to as the "caretaker".
    http://www.webgain.com/products/java_cc/

One great thing about it (perhaps about JLex too?) is that the generated code does not rely on any external runtime libraries or jars that would have to be deployed with your code. Just the code and nothing but the code.

Here are links to a few JavaCC articles:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-cooltools.html
    http://www.javaworld.com/javaworld/jw-12-1996/jw-12-jack.html

And here is a "big" list of java compiler construction tools (but I have only used JavaCC):
    http://catalog.compilertools.net/java.html

Best regards,
Jim Cakalic
0
 
gadioCommented:
I can also recommend using javaCC. Its simple and I like the fact that its input is a superset of java (all of the definitions are in the same file). It can also generate the jjtree - a code that deals directly with the tree structure of the parsed expression.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now