help-bison
[Top][All Lists]
Advanced

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

Re: %union errors


From: Vukki Starborn
Subject: Re: %union errors
Date: Sat, 6 Dec 2008 10:33:40 +0300

May be your structures were defined in namespace? Or this may be some kind
of include guards fail.
General way to solve this: examine generated by bison code. If it would be
seem ok, you can produce preprocessed code from it by running your compiler
with special options ( -E for gcc). There you must the the real way
definitions included.


2008/12/6 Benny Hardage <address@hidden>

> Hello,
>
> I'm receiving the following errors when I compile:
>
> In file included from compiler.l:17:
> parser.y:27: error: ISO C++ forbids declaration of 'list' with no type
> parser.y:27: error: invalid use of '::'
> parser.y:27: error: expected ';' before '<' token
> parser.y:28: error: ISO C++ forbids declaration of 'Variable' with no type
> parser.y:28: error: expected ';' before '*' token
> parser.y:29: error: ISO C++ forbids declaration of 'UnaryOperation' with no
> type
> parser.y:29: error: expected ';' before '*' token
> parser.y:30: error: ISO C++ forbids declaration of 'BinaryOperation'
> with no type
> parser.y:30: error: expected ';' before '*' token
> parser.y:31: error: ISO C++ forbids declaration of 'Expression' with no
> type
> parser.y:31: error: expected ';' before '*' token
> parser.y:32: error: ISO C++ forbids declaration of 'DataLiteral' with no
> type
> parser.y:32: error: expected ';' before '*' token
>
> I've seen a fairly old thread that attempted to address this issue,
> saying that my include files might not be in the right order, but the
> top of my file looks like the following:
>
> %error-verbose
>
> %{
>
> int yylex();
>
> #include <iostream>
> #include "expressions.hpp"
> #include "statements.hpp"
>
> extern bool outputTokens;
> extern bool outputParser;
>
> void yyerror( char* msg )
> {
>        std::cerr << msg << std::endl;
> }
>
> %}
>
> %union
> {
>        int intVal;
>        bool boolVal;
>        char* strVal;
>        std::list<const Variable::Qualifier*>* qList;
>        Variable* var;
>        UnaryOperation* uop;
>        BinaryOperation* binop;
>        Expression* expr;
>        DataLiteral* datalit;
> }
>
> expressions.hpp contains the datatypes in question.
>
> I was wondering if someone might let me know what I was doing wrong.
>
> Thanks,
> B.J.
>
>
> _______________________________________________
> address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
>


reply via email to

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