Hi, I'm having trouble getting this to work. I don't know whether my code is set up correctly. I can't seem to find any other answers that help. Thank you.
top part of my lex grammar .l file ############################# %option c++ %{ #include <cstdint> #ifdef DEBUGON #ifndef DEBUG #define DEBUG #endif #endif #include "lex.hpp" #include "List.hpp" #include "symtab.hpp" #include "data.hpp" #include "lex.hpp" #undef YY_DECL #define YY_DECL uccParser::symbol_type uccLexer::yylex(uccParser::semantic_type* const lval, uccParser::location_type* location) #include "ucc.tab.hpp" #include "compiler.hpp" using namespace ucc; using token = uccParser::token; #define YY_USER_ACTION loc->step(); loc->columns(yyleng); %} %option stack %option yylineno %option yyclass="uccLexer" %s initial %x astring %x comment DIGIT [0-9] LETTER [A-Za-z\_] SPACE [ ] EOLN \\n PERCENT \% QUESTION \? NULLS \\0 BEGCOM "\/\*" ENDCOM "\*\/" ELIP "..." EQUEQU "==" NEQ "\!=" LEQ "<=" GEQ ">=" ADOF "&" %% ####################################### top part of my bison grammar file .ypp ######################################### %{ #include <cstdio> #include <string> #ifdef DEBUGON #ifndef DEBUG #define DEBUG #endif #endif #include "type.hpp" #include "List.hpp" #include "symtab.hpp" #include "data.hpp" #include "trans.hpp" #include "lex.hpp" #include "cpptypes.hpp" using namespace ucc; #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYERROR_VERBOSE 1 #include "compiler.hpp" Funcb* currentFunc; int yyerror(std::string err,Compiler& compiler); %} %expect 1 %skeleton "lalr1.cc" %require "3.7" %define parse.assert %defines %locations %define api.value.type variant //%define api.token.constructor %define api.token.raw %define api.namespace{ucc} %define api.parser.class {uccParser} %code requires { namespace ucc{ class Compiler; class Constant; } #include "List.hpp" #include "type.hpp" using namespace ucc; } %parse-param{ Compiler& compiler } //%lex-param{ uccParser::semantic_type* const lval } //%lex-param{ uccParser::location_type* loc } %code{ #undef yylex #define yylex compiler.lexer.yylex } ################################################## i've played around with having the param turned on and either full %param, or %lex %parse specific. I've turned on and off token.raw and token.constructor but it doesn't seem to work. the translate_ function still seems to want to accept an (int) from yylex but should it be used if api.token.raw is turned on? Maybe i'm thinking the translate_ function is used differently. Let me know if you need more code. Thank you in advance. Scotty