From 093d15d329a29d026ab99e17f48f6a0913730d63 Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 14 Mar 2009 16:56:37 +0000 Subject: [PATCH] Updated the help output. Moved some code from InputData:: to main. git-svn-id: http://svn.complang.org/ragel/trunk@734 052ea7fc-9027-0410-9066-f65837a77df0 --- ragel/inputdata.cpp | 14 +++++--------- ragel/inputdata.h | 1 + ragel/main.cpp | 19 ++++++++++++++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ragel/inputdata.cpp b/ragel/inputdata.cpp index 5922a53..4b8446b 100644 --- a/ragel/inputdata.cpp +++ b/ragel/inputdata.cpp @@ -88,7 +88,7 @@ void InputData::openOutput() } } -void InputData::generateReduced() +void InputData::prepareMachineGen() { /* No machine spec or machine name given. Generate everything. */ for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) { @@ -96,19 +96,15 @@ void InputData::generateReduced() if ( pd->instanceList.length() > 0 ) pd->prepareMachineGen( 0 ); } +} - openOutput(); - - if ( gblErrorCount > 0 ) - return; - +void InputData::generateReduced() +{ for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) { ParseData *pd = parser->value->pd; if ( pd->instanceList.length() > 0 ) pd->generateReduced( *this ); } - - writeOutput(); } void InputData::writeOutput() @@ -121,7 +117,7 @@ void InputData::writeOutput() cgd->writeStatement( ii->loc, ii->writeArgs.length()-1, ii->writeArgs.data ); } - else { + else /*if ( /!generateDot )*/ { *outStream << '\n'; lineDirective( *outStream, inputFileName, ii->loc.line ); *outStream << ii->data.str(); diff --git a/ragel/inputdata.h b/ragel/inputdata.h index 0c39927..d40bc5d 100644 --- a/ragel/inputdata.h +++ b/ragel/inputdata.h @@ -45,6 +45,7 @@ struct InputData void generateSpecificReduced(); void openOutput(); void generateReduced(); + void prepareMachineGen(); }; #endif diff --git a/ragel/main.cpp b/ragel/main.cpp index da28ee9..28b2126 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -125,8 +125,8 @@ void usage() " -x Run the frontend only: emit XML intermediate format\n" " -V Generate a dot file for Graphviz\n" " -p Display printable characters on labels\n" -" -S FSM specification to output (for rlgen-dot)\n" -" -M Machine definition/instantiation to output (for rlgen-dot)\n" +" -S FSM specification to output (for graphviz output)\n" +" -M Machine definition/instantiation to output (for graphviz output)\n" "host language:\n" " -C The host language is C, C++, Obj-C or Obj-C++ (default)\n" " -D The host language is D\n" @@ -489,9 +489,22 @@ void process( const char *inputFileName ) InputData inputData( inputFileName, outputActive, wantComplete ); - /* Write the machines, then the surrounding code. */ + /* Compiles machines. */ + inputData.prepareMachineGen(); + + if ( gblErrorCount > 0 ) + exit(1); + + inputData.openOutput(); + + /* Generates the reduced machine, which we use to write output. */ inputData.generateReduced(); + if ( gblErrorCount > 0 ) + exit(1); + + inputData.writeOutput(); + /* Close the input and the intermediate file. */ delete inFile; -- 2.7.4