Lex based Config Parser/Reader

A long lost how-to snippet: simple, one-liner configuration file parser written in lex and C. Serves the purpose most of the time. Quite simple and neat!

A typically super-verbose config.c gets auto-generated from lex code.

Yes, I can hear the skeptics! 🙄 Why call parser if it is based on a lexer? Well… it is a Type-3 Grammar (Chomsky hierarchy), i.e. regex. So the configuration data is placed in “structured” (hence, parser!) manner into a representation defined by the application program.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s