From aff01fd8feb7faa715c0bbbc2f1eee51597c8eb2 Mon Sep 17 00:00:00 2001 From: thurston Date: Mon, 16 Mar 2009 01:58:23 +0000 Subject: [PATCH] The terminateAllParsers function moved into InputData. git-svn-id: http://svn.complang.org/ragel/trunk@742 052ea7fc-9027-0410-9066-f65837a77df0 --- ragel/inputdata.cpp | 14 ++++++++++++++ ragel/inputdata.h | 1 + ragel/main.cpp | 20 ++++++++------------ ragel/parsedata.cpp | 13 ------------- ragel/ragel.h | 1 - 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/ragel/inputdata.cpp b/ragel/inputdata.cpp index f2831e0..9e464d3 100644 --- a/ragel/inputdata.cpp +++ b/ragel/inputdata.cpp @@ -195,6 +195,20 @@ void InputData::generateReduced() } } +/* Send eof to all parsers. */ +void InputData::terminateAllParsers( ) +{ + /* FIXME: a proper token is needed here. Suppose we should use the + * location of EOF in the last file that the parser was referenced in. */ + InputLoc loc; + loc.fileName = ""; + loc.line = 0; + loc.col = 0; + for ( ParserDict::Iter pdel = parserDict; pdel.lte(); pdel++ ) + pdel->value->token( loc, Parser_tk_eof, 0, 0 ); +} + + void InputData::writeOutput() { if ( generateDot ) { diff --git a/ragel/inputdata.h b/ragel/inputdata.h index 93550fa..8ccabeb 100644 --- a/ragel/inputdata.h +++ b/ragel/inputdata.h @@ -48,6 +48,7 @@ struct InputData void openOutput(); void generateReduced(); void prepareMachineGen(); + void terminateAllParsers(); void cdDefaultFileName( const char *inputFile ); void javaDefaultFileName( const char *inputFile ); diff --git a/ragel/main.cpp b/ragel/main.cpp index 53ac915..970fefc 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -469,19 +469,7 @@ void process( const char *inputFileName ) /* Finished, final check for errors.. */ if ( gblErrorCount > 0 ) exit(1); - - /* Now send EOF to all parsers. */ - terminateAllParsers(); - - /* Finished, final check for errors.. */ - if ( gblErrorCount > 0 ) - exit(1); - - /* Bail on above error. */ - if ( gblErrorCount > 0 ) - exit(1); - /* Locate the backend program */ if ( generateDot ) { wantComplete = false; outputActive = false; @@ -489,6 +477,14 @@ void process( const char *inputFileName ) InputData inputData( inputFileName, outputActive, wantComplete ); + /* Now send EOF to all parsers. */ + inputData.terminateAllParsers(); + + /* Bail on above error. */ + if ( gblErrorCount > 0 ) + exit(1); + + /* Locate the backend program */ /* Compiles machines. */ inputData.prepareMachineGen(); diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index a534348..6ff3e75 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -1449,19 +1449,6 @@ void ParseData::generateReduced( InputData &inputData ) } } -/* Send eof to all parsers. */ -void terminateAllParsers( ) -{ - /* FIXME: a proper token is needed here. Suppose we should use the - * location of EOF in the last file that the parser was referenced in. */ - InputLoc loc; - loc.fileName = ""; - loc.line = 0; - loc.col = 0; - for ( ParserDict::Iter pdel = parserDict; pdel.lte(); pdel++ ) - pdel->value->token( loc, Parser_tk_eof, 0, 0 ); -} - void writeLanguage( std::ostream &out ) { out << " lang=\""; diff --git a/ragel/ragel.h b/ragel/ragel.h index 7a5dcd0..1372120 100644 --- a/ragel/ragel.h +++ b/ragel/ragel.h @@ -96,7 +96,6 @@ std::ostream &warning( const InputLoc &loc ); struct XmlParser; -void terminateAllParsers( ); void xmlEscapeHost( std::ostream &out, char *data, long len ); typedef Vector ArgsVector; -- 2.7.4