Improving the pseudo-ini parser

In a previous article I described how to create a parser for a pseudo-INI file. The grammar presented in the post is unfortunately unable to parse inline comments correctly.

I asked for ways to improve it, both on perlmonks and on IRC. After some testing it turns out that a slight change is enough: the first line of the grammar should be changed to:

AsIni: <skip: qr{s*(;[^n]*ns*)?}s> Line(s?) /Z/

Unfortunately, this won't print the skipped content (as CommentLine) does. From the answers I had it's not quite clear if this is actually possible with Parse::RecDescent. Anyway, I am satisfied with the result so far 🙂

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s