help-bison
[Top][All Lists]
Advanced

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

Re: Unable to compile in Visual C++


From: Mary Ann O'Connor
Subject: Re: Unable to compile in Visual C++
Date: Fri, 19 Jun 2009 15:46:59 +0000 (UTC)

Just a generic comment: Whenever I think I've defined something via an included 
header file, but get this type of error, I generate the preprocessor output to 
see what the compiler really is seeing. There might be some macro preventing 
the definition from really being included. 

-Mary Ann 

----- Original Message ----- 
From: "Ewa Rom" <address@hidden> 
To: address@hidden 
Sent: Friday, June 19, 2009 11:38:03 AM GMT -05:00 US/Canada Eastern 
Subject: Unable to compile in Visual C++ 


Hi all, 



I'm writing my Master thesis that includes a parser. I chose to use Flex and 
Bison to help me with this and include the parser into my Visual C++ project. 



I stoped at the following issue and I do not know how to recover from it. 
Everything appears to be fine as far as I can see. 



I have a resource.h file where I define the following: 



typedef enum {Var, Int, Opr} nodeEnum; 

typedef struct VariableNode{ 

nodeEnum type; 

char *s; 

}; 

typedef struct IntNode{ 

nodeEnum type; 

int i; 

}; 

typedef struct OperNode{ 

nodeEnum type; 

char *op; 

struct nodeType *r; 

struct nodeType *l; 

}; 

typedef struct nodeType{ 

nodeEnum type; 

VariableNode v; 

IntNode in; 

OperNode oper; 

}; 



Then in the CoProveParser.y file I have the following: 



%{ 
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; 
%} 

%union { 
int iValue; 
char sIndex; 
nodeType *nPtr; 
} 

%token <sIndex> STRING 
%token <iValue> INTEGER 
... 



%type <nPtr> factor logic boolexpr prgrams expr term stmts statement 

%% 


Grammar.... 


%% 

// stuff from lex that yacc needs to know about: 
extern int yylex(); 
extern int yyparse(); 
extern FILE *yyin; 
extern FILE *log; 
extern int debug; 

int status; 



nodeType *v(char s){ 
nodeType *p; 

p = (nodeType*)malloc(sizeof(struct VariableNode)); 

p->type = Var; 
p->v.s = &s; 

return p; 
} 



nodeType *in(int i){ 
nodeType *p; 

p = (nodeType*)malloc(sizeof(struct IntNode)); 

p->type = Int; 
p->in.i = i; 

return p; 
} 



nodeType *oper(char s,nodeType l,nodeType r){ 
nodeType *p; 

p = (nodeType*)malloc(sizeof(struct OperNode)); 

p->type = Opr; 
p->oper.op = &s; 
p->oper.r = &r; 
p->oper.l = &l; 

return p; 
} 



int proving() { 
yyparse(); 
return 1; 
} 



I do the following: 



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 




This corresponds to the following block: 



%union { 
int iValue; 
char sIndex; 
nodeType *nPtr; 
} 



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 %{ %} 



Any suggestions much appreciated. 



Thank you 

Ewa 

_________________________________________________________________ 
We are your photos. Share us now with Windows Live Photos. 
http://go.microsoft.com/?linkid=9666047_______________________________________________
 
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison 


reply via email to

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