From 03be7ac1612f8469698059373fa8be130610b13b Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sun, 8 Mar 2009 21:52:37 +0000 Subject: 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. --- colm/fsmrun.cpp | 21 ++++++++------------- 1 file 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 ) { -- cgit v1.2.1