[ccan] The lemon parser as a ccan module

Joel C. Salomon joelcsalomon at gmail.com
Mon Apr 13 10:46:23 EST 2009


On Wed, Apr 8, 2009 at 4:58 AM, Tim Post <echo at echoreply.us> wrote:
> Recently, I wanted to allow users to specify a printf style syntax like
> this in a configuration file, to dictate the output of a program:
>
> /tmp/foo/%s/jobs/%d.out
<snip>
> So either I come up with a hand rolled parser that knows to expand %s to
> a process name and %d to a job id (despite presence or order), or I
> depend on a generator that the user may or may not have, all to deal
> with a single string.

Sounds like a job for an extensible printf like Plan 9's libfmt, also
available for other OSs via plan9port at
<http://swtch.com/plan9port/>.  See
<http://swtch.com/plan9port/man/man3/fmtinstall.html> for details on
how that works.

The lemon parser idea still sounds cool, though.

—Joel Salomon



More information about the ccan mailing list