views:

265

answers:

6

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?

+1  A: 

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!)

hhafez
"we use lexx/yacc to parse strings coming over sockets" ->This is cool too ;)
Winston Chen
+1  A: 

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

Yishai
+3  A: 

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!-)

Alex Martelli
Yeah.. I remember noticing antlr in the db framework-hibernate. It's indeed a very useful tool in SQL or HQL domain.
Winston Chen
+1  A: 

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.

Simeon Pilgrim
+1  A: 

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

+1  A: 

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.

Kage