bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++.bison


From: Hans Aberg
Subject: Re: C++.bison
Date: Fri, 5 Apr 2002 11:59:53 +0200

At 12:22 +0200 2002/04/04, Akim Demaille wrote:
>>>>>> "Hans" == Hans Aberg <address@hidden> writes:
>
>Hans> Does anybody have a m4 processed bison.c++ skeleton file?
>
>What is the problem you have with installing GNU M4?
>
>/tmp % mkdir hans                                                nostromo
>12:21
>/tmp % cd hans                                                   nostromo
>12:21
>/tmp/hans % echo "%%exp: '1' { fprintf (stderr, \"one\\\n\"); };" > hans.y
>/tmp/hans % bison -o hans.cc hans.y -S bison.c++                 nostromo
>12:21
>/tmp/hans % ls -ltr                                              nostromo
>12:21

This still does not contain bison.c++ (after run through m4); is it CVS
Bison that runs the skeleton file through m4 in order to produce multi-file
output?

Some notes:

- Why do you use uppercase names, when both C/C++ and Bison/Yacc use lower
case? For consistent style, I think it should be yy::stack, not yy::Stack.
(This is what namespaces are for: yy::Stack will not collide with
std::stack.)

- The operator[] of your stack class should probably use std::advance, so
that it works will other containers.

- The standard choice for std::stack is std::deque, perhaps because it for
some reason is more efficient. So perhaps you should use that default as
well.

- It is more efficient to use only one stack (I did that in my C++ skeleton
file).

- You should use the C++ IO standard streams, not the C compatibility ones
in <cstdio>. Even though the streams are the same, I think that when using
both, their buffers must be synchronized (or so I recall); which can cause
a performance penalty. (I did this change in my skeleton file.)

- In the case of the zero length rule default action, I think that you can
change to $$ = YYSTYPE(): Under C++, unlike (old) C, basic types have
default constructors. -- I think this was added in order to ensure various
template functions working. So one can just as well assume that the types
used have such a default constructor.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]