#pragma once
#include "lemonpp.h"
class lemon_c: public lemon {
private:
bool mhflag;
public:
lemon_c(char *argv0, const std::string & filename, bool basisflag,
bool nolinenosflag);
virtual ~lemon_c();
virtual void doOutput();
void ReportTable();
void ReportHeader();
void makeheaders(bool mhflag);
static const char *minimum_size_type(int lwr, int upr);
void print_stack_union(FILE * out, int *plineno);
void translate_code(rule*);
void emit_code(FILE*, rule*, int*);
void emit_destructor_code(FILE * out, symbol *sp, int *lineno);
};
/*
** Each state contains a set of token transaction and a set of
** nonterminal transactions. Each of these sets makes an instance
** of the following structure. An array of these structures is used
** to order the creation of entries in the yy_action[] table.
*/
class axset {
public:
state *stp; /* A pointer to a state */
int isTkn; /* True to use tokens. False for non-terminals */
int nAction; /* Number of actions */
};
/*
** The state of the yy_action table under construction is an instance of
** the following structure
*/
class acttab {
public:
int nAction; /* Number of used slots in aAction[] */
int nActionAlloc; /* Slots allocated for aAction[] */
struct action {
int lookahead; /* Value of the lookahead token */
int action; /* Action to take on the given lookahead */
} *aAction, /* The yy_action[] table under construction */
*aLookahead; /* A single new transaction set */
int mnLookahead; /* Minimum aLookahead[].lookahead */
int mnAction; /* Action associated with mnLookahead */
int mxLookahead; /* Maximum aLookahead[].lookahead */
int nLookahead; /* Used slots in aLookahead[] */
int nLookaheadAlloc; /* Slots allocated in aLookahead[] */
acttab();
virtual ~acttab();
void do_action(int lookahead, int action);
int insert();
/* Return the number of entries in the yy_action table */
inline int size() {
return this->nAction;
}
/* The value for the N-th entry in yy_action */
inline int yyaction(int N) {
return this->aAction[N].action;
}
/* The value for the N-th entry in yy_lookahead */
inline int yylookahead(int N) {
return this->aAction[N].lookahead;
}
};