[antlr-interest] Re: ANTLR generated C (not C++), anyone??
lgcraymer
lgc at mail1.jpl.nasa.gov
Sat Jul 24 00:39:54 PDT 2004
I don't think that Ric meant "it is difficult"; rather, the result
will be unpleasant--you would have both the C and C++ runtime and the
code bloat would be significant.
Rather than using ANTLR 2, I would suggest using PCCTS--it should be
possible to write a PCCTS to ANTLR 3 translator (for parsers and tree
walkers), where it wasn't for ANTLR 2 because of the lack of semantic
predicate hoisting. (Predicate hoisting is much missed in ANTLR 2--it
provides an excellent solution for the keyword/identifier problem.)
PCCTS generates fast C (or C++) parsers, and Tom Moog has done an
excellent job in maintaining PCCTS. You can get it from
<http://www.polhode.com/pccts.html>. For Bryan's problem, it would
make sense to keep the lex-based lexer (see the notes on the
referenced web page) and translate the parser(s) to ANTLR 1. I plan
to do a PCCTS to ANTLR 3 translator if Ter doesn't write one, so Bryan
should be able to upgrade later.
--Loring
--- In antlr-interest at yahoogroups.com, "Sergey Bogdanov"
<serge.bogdanov at i...> wrote:
> --- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...>
> wrote:
> > Hi,
> >
> > On Wed, Jul 21, 2004 at 07:46:32AM -0700, Bryan Ewbank wrote:
> > > I'm evaluating ANTLR as a replacement for lex, yacc, and several
> > > thousand lines of source code in a legacy system. The key
> problem is
> > > that ANTLR generates C++ code - not C - and there doesn't seem
> to be
> > > a clear way for C to interface neatly with C++.
> >
> > It will probably be a horror to try and do that.
> >
>
> ANTLR could pretty much be used the same way as lex/yacc and others
> by utilising callback C functions. At this level 'extern "C"'
> interface would cleanly solve all your problems. There could be a
> pretty small piece of c++ code to satisfy ANTLR initialization and
> you have to acquire a limited knowledge of some ANTLR data types to
> correctly interface your callbacks, mainly the Token class.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list