pacc logo

C interface

There's a near-OO interface in pacc.tmpl, but it's currently actually hidden from the user with names that start _pacc_. The wrapper function parse() is all right, but we need to offer more control, and perhaps a variety of different wrappers.

The thing about _pacc_parser_new() is that it has the grammar rules embedded in it. So it would have to be YY_new() (where YY is the user-supplied string). That could work. Or, could we truly have a pacc_parser_new() function that returns a generic parser object, a later method call setting the grammar to use with it? Thing is, "a grammar" carries quite a lot of baggage: a pointer to the engine() function, the return type, the number of rules...

So let's spin out the first idea.

p = YY_new(void)
Returns a new pacc parser object for the YY grammar. We don't need the name parameter that the current _pacc_parser_new() has: that's YY. No it's not, it's the filename that the input came from, and YY_error() would very much like to have it still. This function won't actually be able to do all that much, since it doesn't know how long the input is.
void YY_input(p, char *name, char *addr, off_t length)
Sets the text to be parsed.
int YY_parse(p)
Actually performs the parse, returning 1 if it was sucessful.
YY_type YY_result(p)
If the parse was successful, returns the result. Ooh. Do we want to defer the actual evaluation till this point? Hmm... think about that. [1]
If the parse was unsuccessful, report an error.

That looks like it could work out pretty well. Let's give it a go... Yup, seems to be sorted. Now to build a feeder that uses it. Done. Fiddly, as anticipated, but it works! As far as I know this is a world first (apart from my previous proof-of-concept). If anybody's got a rooftop, I'd like to shout from it.

[1]Unfortunately, it's not so easy to move the evaluation code out into a separate function, as it uses the same explicit control infrastructure (goto contin; and such like) as the actual parser. Since I've claimed I'm getting the first release out in the next 10 days, I really don't have time for this at the moment! I've added it to the To Do list, though, as I think it's a great idea.

Last updated: 2015-05-24 19:45:23 UTC


Porting and packaging

One thing pacc needs is more users. And, perhaps, one way to get more users is to reduce the friction in getting started with pacc. An obvious lubricant is packaging. Read More...

Release relief

Looking at _pacc_coords(), I noticed that it seemed to have the same realloc() bug that I'd just fixed in _pacc_result(). However, the "list of arrays" trick really wasn't going to work here. Read More...

See more news articles