summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2009-03-09 01:04:32 +0000
committerAdrian Thurston <thurston@complang.org>2009-03-09 01:04:32 +0000
commit1e645bca5b679d0a26b8a5320f8dd2b4e981a0b8 (patch)
tree12ed566a99a95353bbbd01bcac1e168da7927bec
parent263d0ae256493a4295addb38bc24d5f0dc3b65fb (diff)
downloadcolm-1e645bca5b679d0a26b8a5320f8dd2b4e981a0b8.tar.gz
Some cleanup.
-rw-r--r--colm/fsmrun.cpp33
-rw-r--r--colm/pdarun.h1
2 files changed, 15 insertions, 19 deletions
diff --git a/colm/fsmrun.cpp b/colm/fsmrun.cpp
index 42cb6788..3e2e09aa 100644
--- a/colm/fsmrun.cpp
+++ b/colm/fsmrun.cpp
@@ -529,14 +529,14 @@ void generation_action( FsmRun *fsmRun, PdaRun *parser, int id, Head *tokdata,
}
/* Send back the accumulated ignore tokens. */
-void PdaRun::sendBackIgnore( )
+void send_back_queued_ignore( PdaRun *parser )
{
- Kid *ignore = extractIgnore();
- fsmRun->sendBackIgnore( this, ignore );
+ Kid *ignore = parser->extractIgnore();
+ parser->fsmRun->sendBackIgnore( parser, ignore );
while ( ignore != 0 ) {
Kid *next = ignore->next;
- tree_downref( prg, root, ignore->tree );
- prg->kidPool.free( ignore );
+ tree_downref( parser->prg, parser->root, ignore->tree );
+ parser->prg->kidPool.free( ignore );
ignore = next;
}
}
@@ -638,7 +638,7 @@ void send_ignore( FsmRun *fsmRun, PdaRun *parser, long id )
parser->ignore( tree );
}
-Head *FsmRun::extractMatch( )
+Head *FsmRun::extractMatch()
{
long length = p - tokstart;
return string_alloc_const( prg, tokstart, length );
@@ -789,13 +789,10 @@ void scanner_error( FsmRun *fsmRun, PdaRun *parser )
/* May have accumulated ignore tokens from a previous region.
* need to rescan them since we won't be sending tokens from
* this region. */
- parser->sendBackIgnore();
-
+ send_back_queued_ignore( parser );
parser->nextRegionInd += 1;
- return;
}
-
- if ( parser->numRetry > 0 ) {
+ else if ( parser->numRetry > 0 ) {
/* Invoke the parser's error handling. */
#ifdef COLM_LOG_PARSE
if ( colm_log_parse ) {
@@ -803,20 +800,20 @@ void scanner_error( FsmRun *fsmRun, PdaRun *parser )
}
#endif
- parser->sendBackIgnore();
+ send_back_queued_ignore( parser );
parser->parseToken( 0 );
if ( parser->errCount > 0 ) {
/* Error occured in the top-level parser. */
cerr << "PARSE ERROR" << endp;
}
- else {
- return;
- }
}
-
- /* Machine failed before finding a token. */
- cerr << "error:" << fsmRun->inputStream->line << ": scanner error" << endp;
+ else {
+ /* There are no alternative scanning regions to try, nor are there any
+ * alternatives stored in the current parse tree. No choice but to
+ * kill the parse. */
+ cerr << "error:" << fsmRun->inputStream->line << ": scanner error" << endp;
+ }
}
void parse( FsmRun *fsmRun, PdaRun *parser )
diff --git a/colm/pdarun.h b/colm/pdarun.h
index 240d97a4..f0d2a797 100644
--- a/colm/pdarun.h
+++ b/colm/pdarun.h
@@ -528,7 +528,6 @@ struct PdaRun
void send( Kid *kid );
void ignore( Tree *tree );
- void sendBackIgnore();
Kid *extractIgnore();
/* Report an error encountered by the parser. */