I have a C++ library project, and it includes a Lex lexer and a YACC parser. Everything in the project is under a common namespace, with some parts in other namespaces under that. I want all the code generated by Lex and YACC to be under the namespace "lexyacc" under the common namespace.
I did it by putting these lines in the header parts of the Lex and YACC files:
Code:
namespace LANG_NAMESPACE { namespace lexyacc {
Tge problem is that when compiling, the code generated by Lex and YACC throws a huge about of errors about using types that don't exist (even though their header files are included). What do I do?
EDIT: here's a snippet from YACC's output:
Code:
/* Line 189 of yacc.c */
#line 1 "/home/michael/Projects/lang/lib/yacc_parser.y"
#include "config.hh"
#include "node_call_param_list.hh"
#include "node_func_param_list.hh"
#include "nodes.hh"
#include <iostream>
#include "y.tab.hh"
namespace LANG_NAMESPACE { namespace lexyacc {
int yylex();
void yyerror(char*);
FILE *input;
extern char *yytext;
char *__parser_filename__;
int __parser_line__;
<snip>
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 214 of yacc.c */
#line 19 "/home/michael/Projects/lang/lib/yacc_parser.y"
Node *node;
NodeFuncParamList *fParam;
NodeCallParamList *cParam;
char *str;
struct {
char *name;
Node *node;
} nameNodePair;
/* Line 214 of yacc.c */
#line 179 "/home/michael/Projects/lang/build/lib/y.tab.cc"
} YYSTYPE;
First is says "#include "nodes.hh"", and then it uses Node in the declaration of YYSTYPE. Tell me, how could Node possibly not have been defined?