Boost logo

Boost-Build :

From: Kirill Lapshin (kir_at_[hidden])
Date: 2006-03-05 17:02:16


Hello,

First of all, have anyone worked on ANTLR toolset?

Assuming the answer is no (since I have not found many references
searching this list) what is the easiest way to deal with code
generating tool that generates many .cpp/.hpp files out of single source?

The way ANTLR works, you feed it a single grammar file (usually .g) and
it creates hpp/cpp pairs for lexer, parser, and tree walker (or subset
thereof) all in one go. There is no control over filenames it creates
from command line, only from grammar file.

I have couple of different approaches.

The most promising one was following whale.jam lead. It works pretty
well, except for one problem, since strictly speaking I have no control
over target names I can't rely on target name patterns (like
HPP(%_lexer) ). For time being I just hardcoded patterns which I know my
only grammar file conforms to, but it would be nice to find proper way.

That was achieved with simple

----------------
type.register ANTLR_G : g ;

generators.register-standard antlr.antlr-compile : ANTLR_G :
CPP(%_parser) HPP(%_parser) CPP(%_lexer) HPP(%_lexer) ;

actions antlr-compile
{
     $(.antlr) -o "$(<[1]:D)" "$(>)"
}
----------------

Solution like this will work on my project, as we can simply made a
policy that output files should follow this pattern, but if we want to
create generic antlr toolset more effort has to be put in. There might
be few ways -- ideally use sort of "scanner" which will deduce names
looking into grammar files, or alternatively let user specify all
targets, say:

antlr some_grammar : some_grammar.g : glexer.cpp glexer.hpp gparser.cpp
gparser.hpp ;

lib some_lib : some_grammar foo.cpp ;

Is it doable? If someone could lend me a hand on this one, I would
happily contribute antlr toolset to BB.

Alternative solution I've tried was following message I found in this
list archives:

http://article.gmane.org/gmane.comp.lib.boost.build/5858/match=antlr

I've tried to modify Chris' code for ANTLR, but finally had to give up,
because his code is written against quite old version of BBv2, and there
  seems to be no easy way to update it to work with current release.

The problem I am facing now is that abstract-file-target no longer has
ability to set action after construction, even though comments claim
otherwise (quoting virtual-target.jam):

     # If 'a' is supplied, sets action to 'a'.
     # Returns the action currently set.
     rule action ( )
     {
         return $(self.action) ;
     }

Which way is more promising? Adding generator or creating custom target?

Regards,
Kirill Lapshin


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk