Bison & flex linkage - yylval type

1k Views Asked by At

I have a school project, building a compiler. There is a header file given by the course staff, "proj.h" including a struct "Node", which should be used to build the parsing tree, and a set of functions. (That header does not include a #define for YYSTYPE to the Node type, and shouldn't be changed). I would like to use Node* in my .lex file, such as:

yylval = makeNode(...);

definition of makeNode:

Node *makeNode(const char* type,const char* value, Node *child);

I have tried defining the YYSTYPE both in .lex file and .ypp.

.lex:

#include "proj.h"
#include "parser.tab.hpp"
#define YYSTYPE Node*

.ypp:

#include "proj.h"
#define YYSTYPE Node*

I'm compiling using g++. It seems that the lval doesn't get the actual defintion as Node* as it should. There is a compilation error when trying to assign lval:

Invalid conversion from 'Node* {aka n*}' to 'YYSTYPE {aka int}'

Any help appreciated.

0

There are 0 best solutions below