[build2] Yacc module?

Joachim Kuebart joachim.kuebart at gmail.com
Sat Aug 31 18:49:57 UTC 2019


On Sat, 31 Aug 2019 at 13:03, Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> Joachim Kuebart <joachim.kuebart at gmail.com> writes:
>
> > I'm trying to write a build2 build system for a project which uses yacc
> > (weird I know). I didn't find an existing yacc module either shipped with
> > build2 or on cppget.
> >
> > I'm not disinclined to write a module myself for the platforms I use, just
> > wanted to make sure it's not a waste of effort, and perhaps ask for some
> > expert guidance on where best to start ;)
>
> Good timing: support for external build system modules was added to
> build2 about a week ago (so it's currently only available in the
> staged version[1]).
>
> There is a very basic (a stub, really) module implementation here:
>
> https://github.com/boris-kolpackov/libbuild2-hello
>
> I am also planning to write something more realistic so that it can
> be used as an example. Using yacc did cross my mind.
>
> So, if you are interested, I can sketch the initial implementation
> out and maybe you can contribute/take over?

Ok, I've upgraded to -stage and built libbuild2-hello, but haven't
been able to load the resulting module yet -- the test doesn't seem to do
that, does it?

I'd be interested in diving into this to create at least a basic structure
-- I won't promise to support a lot of platforms as that seems like a
particularly daunting task. Hopefully others will be able to step in.

> If that sounds like a plan, it would be good to get more information
> on your requirements. I did a bit of background reading[2] (it's been
> a while since I used lex/yacc) and there are some variances, like
> yacc vs bison, output file set and naming, C vs C++, etc. Not that
> it's problematic (the reason we write build2 modules in C++ is to be
> able to handle stuff like this), we just need to decide what we are
> going to start with.

I was thinking of just starting with yacc as specified by POSIX for the
time being, i.e. C only and no GNU extensions. From my experience on macOS,
bison does a decent job of emulating yacc. My platforms would be Fedora,
macOS, OpenBSD and eventually Windows.

Even so, I can think of a number of challenges:

 1. Anywhere from one to three output files with limited naming options.

 2. I frequently need to modify compiler options for yacc output, e.g.
    disable warnings. How would the build2 philosophy handle this?

 3. A library -ly is usually needed when linking yacc output, how would
    this best be handled?

 4. How should the dependency on yacc be handled? System dependency?
    Package it?

I'm sure there'll be more ;-)

Cheers,

Joachim



More information about the users mailing list