[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ code generation
From: |
Axel Kittenberger |
Subject: |
Re: C++ code generation |
Date: |
Tue, 10 Apr 2001 09:20:56 +0200 (MEST) |
Hi,
Yup, my bison parser is also compiling quite well with c++ compilers,
altough
the #define's TOKEN are somewhat inconvinent. Wouldn't maybe enum's fits
better?
The difference is that a #define'd token polutes over all namespace's for
files
included the bison generated header. Here also local declearation in the
inside of
other classes are first replaced by the preprocessor. Where in contrast an
enum'ed
identifier can be 'reused' in class or local context.
Well, I was trying to convert the bison.simple to a kinda new languange,
however most
all the goto's pestered me, don't want to implement goto's only for
bison...however I
worked around in a dirty way with a switch statment.
Has anybody looked once at at Lemon parser generator?
( http://www.hwaci.com/sw/lemon/ )
It's parser template looks a way it could be easily translated to a
beautiful c++
class.
Additionaly I personally like it's idea of naming the non-terminals in
expressions
instead of numbering them.. (I guess it's a common to track bugs in a
parser, caused
by missnumbering in larger rules). Also the need of renumbering all
arguments
when I add a new expression to the front would fall.
expr(A) : expr(B) '+' expr(C)
{ $A = $B + $C; )
;
However I donnot like that it removed the character terminals like '+'...
On the webpage it claims to be faster then yacc.... Well I didn't run any
performance
tests, but looking at the parser templates I would guess otherwise...
- Axel
> At 09:24 -0700 2001/04/07, Petar Teodosin jr. wrote:
> >Why there are no open source flex and bison tools
> >generating C++ code?
>
> Flex ftp://ftp.digital.com/pub/GNU/non-gnu/flex/flex-2.5.4a.tar.gz isn't
> GNU, but has an option to write a C++ class. -- I had to add some "std::"
> to the skeleton file.
>
> Bison works excellently under C++ by simply compiling the C files it
> outputs as C++.
>
> More advanced solutions may appear in the future, but not the current
> version (but I'm not GNU either, so I don't know exactly).
>
> One idea I have is this: I made a small "formatter" macro language (with
> the capacity to merge environments defined in different contexts), which
> can be used to produce more advanced outputs than what is possible by
> using
> merely a skeleton file. The idea I have then is to somehow link up this
> formatter with Bison, by which it would be simple to change the output
> language by merely changing a formatting file.
>
>
>
> _______________________________________________
> Help-bison mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/help-bison
>
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
"
Description: Binary data