help-bison
[Top][All Lists]
Advanced

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

Re: Accessing data structures in grammar


From: Tim Van Holder
Subject: Re: Accessing data structures in grammar
Date: Thu, 24 Nov 2005 08:41:12 +0100
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Leon Mergen wrote:
> g++ -c -g -O0 asm_parser.cpp
> asm_parser.y: In member function `virtual int yy::Parser::parse()':
> asm_parser.y:84: error: request for member `char_t' in `(this +
>    44)->yy::Stack<T, S>::operator[] [with T = yystype, S =
> std::deque<yystype,
>    std::allocator<char> >](0)', which is of non-class type `char'
> asm_parser.y:85: error: request for member `data_t' in
> `this->yy::Parser::yyval
>    ', which is of non-class type `yystype'
> make: *** [asm_parser.o] Error 1
> 
> So basically, there's something wrong with my specification that has
> something to do with the datatype accessing... but I have /no/ idea
> what! 
> 
> Anyone here is able to help me ? This thing is bugging me for way too
> much time now.. :P

Well, bison is trying to access the char_t and data_t members of tokens
(on the parser stack in the first error, and in yyval in the case of
the second error).  But this fails because the stack item is of type
'char' and yyval is of type 'yystype'.
The cause is your #definition of YYSTYPE.  If you look at the header
bison produces you'll see that it creates a typedef for your union as
YYSTYPE, but only if neither YYSTYPE nor YYSTYPE_IS_DECLARED are defined
(or something similar - I don't don't use lalr1.cc, so it may produce
slightly different results).
So bison will process your grammar according to the %union, but it will
happily let you override the actual underlying type at compilation time,
and that's what you're doing.





reply via email to

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