#include "global.h"
#include "source.h"
#include "lex.h"
#include "list.h"
#include "irep.h"
#include "parser.h"
#include "lexparse.h"
#include "fsa.h"
#include "fsatab.h"
#include "gen.h"
// The workings of LexGen are brought together within main() function.
int main(int argc, char **argv)
{
// Open the input file
LexGenParser input(argc == 1 ? "-" : argv[1]);
// Read in specifications
input.specification();
// Process rules and obtain initial state
fsaState::makeFsa();
#ifdef DEBUGPRINT
listIter<fsaState *> forEach(&fsaState::stateSet);
fsaState **s;
while (s = forEach()) (*s)->print();
#endif
// Make deterministic machine
dfsaState::makeDfsa();
#ifdef DEBUGPRINT
listIter<dfsaState *> dforEach(&dfsaState::stateSet);
dfsaState **ds;
while (ds = dforEach()) (*ds)->print();
#endif
// Make optimised machine
odfsaState::optimiseDfsa();
#ifdef DEBUGPRINT
printf("init state: %d\nerror state: %d\n",
odfsaState::initialPartition->id(),
-1);
listIter<odfsaState *> odforEach(&odfsaState::stateSet);
odfsaState **ods;
while (ods = odforEach()) (*ods)->print();
#endif
// Output final machine
FsaTable table(&odfsaState::stateSet);
Copier copy(&table, "glexerc.tpl", "glexer.cc");
Copier copy2(&table, "glexerh.tpl", "glexer.h");
}
syntax highlighted by Code2HTML, v. 0.9.1