Winston Chen
Winston Chen

Reputation: 6879

What do people do with Parsers, like antlr javacc?

Out of curiosity, I wonder what can people do with parsers, how they are applied, and what do people usually create with it?

I know it's widely used in programming language industry, however I think this is just a tiny portion of it, right?

Upvotes: 3

Views: 634

Answers (6)

Kage
Kage

Reputation: 425

You can use it to extend your favorite language by getting its language definition from their repository and then adding what you've always wanted to have. You can pass the regular syntax to your application and handle the extension in your own program.

Upvotes: 1

kingchris
kingchris

Reputation: 1757

I used parsers to help process +/- 800 Clipper source files into similar PRGs that could be compiled with Alaksa Xbase 32.

Upvotes: 1

Simeon Pilgrim
Simeon Pilgrim

Reputation: 26068

Previously I have seen it used to parse the command line based output of another software tool. This way the outer tool (VPN software) could re-use the base router IPSec code without modification. As lots of what was being parsed was IP Route tables and other structured repeated text.

Using a parser allowed simple changes when the formatting changed, instead of trying to find and tweak the a hand written parser. And the output did change a few times of the life of the product.

Upvotes: 1

Alex Martelli
Alex Martelli

Reputation: 882421

Besides special-purpose languages, my most ambitious use of a parser generator yet (with good old yacc back in C, and again later with pyparsing in Python) was to extract, validate and possibly alter certain meta-info from SQL queries -- parsing SQL properly is a real challenge (especially if you hope to support more than one dialect!-), a parser generator (and a lexer it sits on top of) at least remove THAT part of the job!-)

Upvotes: 3

Yishai
Yishai

Reputation: 91921

Generally to parse Domain Specific Languages or scripting languages, or similar support for code snipits.

Upvotes: 1

hhafez
hhafez

Reputation: 39790

They are used to parse text....

To give a more concrete example, where I work we use lexx/yacc to parse strings coming over sockets.

Also from the name it should give you an idea what javacc is used for (java compiler compiler!)

Upvotes: 1

Related Questions