Re: Parsing C++ with lex++ and bison++ ?

aleung@netcom.com (Allen Leung)
Sat, 25 Jun 1994 23:49:45 GMT

          From comp.compilers

Related articles
Parsing C++ with lex++ and bison++ ? kumar@decster.uta.edu (1994-06-16)
Re: Parsing C++ with lex++ and bison++ ? ruiter@ruls41.leidenuniv.nl (1994-06-19)
Re: Parsing C++ with lex++ and bison++ ? bburshte@us.oracle.com (Boris Burshteyn) (1994-06-23)
Re: Parsing C++ with lex++ and bison++ ? aleung@netcom.com (1994-06-25)
Re: Parsing C++ with lex++ and bison++ ? bburshte@us.oracle.com (Boris Burshteyn) (1994-06-29)
| List of all articles for this month |

Newsgroups: comp.compilers
From: aleung@netcom.com (Allen Leung)
Keywords: C++, parse, tools, comment
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: 94-06-117 94-06-172
Date: Sat, 25 Jun 1994 23:49:45 GMT

Boris Burshteyn <bburshte@us.oracle.com>:
>I do not know exactly why BISON++ does not allow $-types with user-defined
>constructors, but one could suppose this comes from the fact that a
>LR1 parser constantly pushes attributes on the stack during shifts and goto
>steps, and then pops them out at reductions. ...


Greetings,
          I haven't had a chance to use Bison++ or Flex++ yet but I'll
hazard a guess why $-type with constructors aren't allowed: the semantic
stack(at least in Bison) is implemented as an array of unions and
C++ disallows constructors in components of a union.


        BTW, isn't the output of Bison++ and Flex++ similar to that of
Bison and Flex; they all generate lookup tables, right?


---a
[The problem is that the parse value stack is an array of unions, so that
when you push and pop them stack C++ can't tell what type each is. In fact,
yacc programmers invariably use %type to tell yacc what type each each
stack entry is, give or take a little cheating, but there seems to be no
way to communicate this to C++. C++ has no discriminated union type
and it's painful to fake with classes. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.