summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2009-03-08 21:52:37 +0000
committerAdrian Thurston <thurston@complang.org>2009-03-08 21:52:37 +0000
commit03be7ac1612f8469698059373fa8be130610b13b (patch)
tree1311ad71587e93ad633544bbb5c7f75f4286c1ee
parent349414ea84df7259368a030327eabe98d29bf343 (diff)
downloadcolm-03be7ac1612f8469698059373fa8be130610b13b.tar.gz
Don't need to recompute p when there is traling context in all of send_token,
send_ignore and exec_gen. Can do it after FsmRun::exeute is called in FsmRun::scan.
-rw-r--r--colm/fsmrun.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/colm/fsmrun.cpp b/colm/fsmrun.cpp
index 0f864ae2..3280242b 100644
--- a/colm/fsmrun.cpp
+++ b/colm/fsmrun.cpp
@@ -606,10 +606,6 @@ void exec_gen( FsmRun *fsmRun, PdaRun *parser, long id )
}
#endif
- LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
- if ( lelInfo[id].markId >= 0 )
- fsmRun->p = fsmRun->mark[lelInfo[id].markId];
-
/* Make the token data. */
long length = fsmRun->p - fsmRun->tokstart;
Head *tokdata = string_alloc_const( fsmRun->prg, fsmRun->tokstart, length );
@@ -630,10 +626,6 @@ void send_ignore( FsmRun *fsmRun, PdaRun *parser, long id )
}
#endif
- LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
- if ( lelInfo[id].markId >= 0 )
- fsmRun->p = fsmRun->mark[lelInfo[id].markId];
-
/* Make the ignore string. */
int length = fsmRun->p - fsmRun->tokstart;
Head *ignoreStr = string_alloc_const( fsmRun->prg, fsmRun->tokstart, length );
@@ -656,10 +648,6 @@ void send_token( FsmRun *fsmRun, PdaRun *parser, long id )
}
#endif
- LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
- if ( lelInfo[id].markId >= 0 )
- fsmRun->p = fsmRun->mark[lelInfo[id].markId];
-
/* Make the token data. */
long length = fsmRun->p - fsmRun->tokstart;
Head *tokdata = string_alloc_const( fsmRun->prg, fsmRun->tokstart, length );
@@ -904,8 +892,15 @@ long FsmRun::scanToken( PdaRun *parser )
execute();
/* First check if scanning stopped because we have a token. */
- if ( matchedToken > 0 )
+ if ( matchedToken > 0 ) {
+ /* If the token has a marker indicating the end (due to trailing
+ * context) then adjust p now. */
+ LangElInfo *lelInfo = parser->tables->rtd->lelInfo;
+ if ( lelInfo[matchedToken].markId >= 0 )
+ p = mark[lelInfo[matchedToken].markId];
+
return matchedToken;
+ }
/* Check for error. */
if ( cs == tables->errorState ) {