[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unable to compile in Visual C++
From: |
Joel E. Denny |
Subject: |
Re: Unable to compile in Visual C++ |
Date: |
Sat, 20 Jun 2009 12:09:12 -0400 (EDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
On Fri, 19 Jun 2009, Ewa Rom wrote:
> %{
> int yylex();
> void yyerror(char *s);
> #include "stdafx.h"
> #include <stdio.h>
> #include <iostream>
> #include <stdlib.h>
> #include <stdarg.h>
> #include <string.h>
> #include <fstream>
> #include <windows.h>
> #include <Shellapi.h>
> #include "parser.hpp"
> #include "resource.h"
>
> nodeType *v(char s);
> nodeType *in(int i);
> nodeType *oper(char s,nodeType l,nodeType r);
>
> void printToFile(char *s);
>
> using namespace std;
> %}
>From the above block, try moving everything that the %union below depends
upon to a %code requires. I believe that's just:
%code requires {
#include "resource.h"
}
> %union {
> int iValue;
> char sIndex;
> nodeType *nPtr;
> }
> flex -olex.cpp CoProveLexer.lex
> bison -v -d --language=C++ -oparser.cpp CoProveParser.y
>
>
>
> Which generates me lex.cpp parser.cpp and parser.hpp files that I have
> included into my Visual C++ project.
>
> Then I try to build the project and I get the following error:
>
>
>
> 1>CoProveParser.y(28) : error C2143: syntax error : missing ';' before '*'
>
> 1>CoProveParser.y(28) : error C4430: missing type specifier - int assumed.
> Note: C++ does not support default-int
>
> 1>CoProveParser.y(28) : error C4430: missing type specifier - int assumed.
> Note: C++ does not support default-int
> It seems like the %union does not know about the definition of the
> nodeType structure defined in the resource.h file even if I include it
> in the first part of the y file enclosed by %{ %}
%{ %} does not generate code into the parser.hpp file. Based on the
information you've provided, I believe that's the problem you've
encountered. If so, the %code suggestion I gave above should fix it.
In general, you ought to consider using %code instead of the old %{ %} to
avoid these kinds of issues. See the %code entries in the section "Bison
Declaration Summary" in the Bison manual for a summary of its
functionality. See the section "Prologue Alternatives" for a detailed
discussion including the advantages of %code over %{ %}.
However, %code is not available in Bison 2.3a and earlier, so your
grammars would only work with more recent versions of Bison. If
compatibility is a concern for you, we can discuss other solutions, but
please try %code first to see if that fixes your problem.
Re: Unable to compile in Visual C++,
Joel E. Denny <=