From 644bacec7894c7039f7950b41051d43d816508aa Mon Sep 17 00:00:00 2001 From: thurston Date: Fri, 28 Sep 2007 22:12:39 +0000 Subject: [PATCH] Scanner EOF transitions are now taken (C/D code only). git-svn-id: http://svn.complang.org/ragel/trunk@292 052ea7fc-9027-0410-9066-f65837a77df0 --- redfsm/gendata.cpp | 3 ++ redfsm/redfsm.cpp | 1 + redfsm/redfsm.h | 2 ++ rlgen-cd/fflatcodegen.cpp | 36 ++++++++++++++++++---- rlgen-cd/fgotocodegen.cpp | 29 +++++++++++++++--- rlgen-cd/flatcodegen.cpp | 71 +++++++++++++++++++++++++++++++++++-------- rlgen-cd/flatcodegen.h | 1 + rlgen-cd/fsmcodegen.h | 1 + rlgen-cd/ftabcodegen.cpp | 42 +++++++++++++++++++------ rlgen-cd/gotocodegen.cpp | 40 ++++++++++++++++++------ rlgen-cd/ipgotocodegen.cpp | 7 ++++- rlgen-cd/tabcodegen.cpp | 76 +++++++++++++++++++++++++++++++++++++--------- rlgen-cd/tabcodegen.h | 1 + test/checkeofact.txl | 6 ++++ test/cppscan3.rl | 10 +++--- test/cppscan5.rl | 6 ++-- test/cppscan6.rl | 4 +-- test/lmgoto.rl | 3 +- test/rlscan.rl | 1 + test/tokstart1.rl | 10 +++--- 20 files changed, 276 insertions(+), 74 deletions(-) diff --git a/redfsm/gendata.cpp b/redfsm/gendata.cpp index 24dbd07..a656041 100644 --- a/redfsm/gendata.cpp +++ b/redfsm/gendata.cpp @@ -655,6 +655,9 @@ void CodeGenData::analyzeMachine() if ( st->stateCondList.length() > 0 ) redFsm->bAnyConditions = true; + + if ( st->eofTrans != 0 ) + redFsm->bAnyEofTrans = true; } /* Assign ids to actions that are referenced. */ diff --git a/redfsm/redfsm.cpp b/redfsm/redfsm.cpp index 2eadcd2..658ef90 100644 --- a/redfsm/redfsm.cpp +++ b/redfsm/redfsm.cpp @@ -54,6 +54,7 @@ RedFsmAp::RedFsmAp() bAnyFromStateActions(false), bAnyRegActions(false), bAnyEofActions(false), + bAnyEofTrans(false), bAnyActionGotos(false), bAnyActionCalls(false), bAnyActionRets(false), diff --git a/redfsm/redfsm.h b/redfsm/redfsm.h index b4af46b..8e53b9e 100644 --- a/redfsm/redfsm.h +++ b/redfsm/redfsm.h @@ -422,6 +422,7 @@ struct RedFsmAp bool bAnyFromStateActions; bool bAnyRegActions; bool bAnyEofActions; + bool bAnyEofTrans; bool bAnyActionGotos; bool bAnyActionCalls; bool bAnyActionRets; @@ -456,6 +457,7 @@ struct RedFsmAp bool anyFromStateActions() { return bAnyFromStateActions; } bool anyRegActions() { return bAnyRegActions; } bool anyEofActions() { return bAnyEofActions; } + bool anyEofTrans() { return bAnyEofTrans; } bool anyActionGotos() { return bAnyActionGotos; } bool anyActionCalls() { return bAnyActionCalls; } bool anyActionRets() { return bAnyActionRets; } diff --git a/rlgen-cd/fflatcodegen.cpp b/rlgen-cd/fflatcodegen.cpp index 0e6f041..71975e8 100644 --- a/rlgen-cd/fflatcodegen.cpp +++ b/rlgen-cd/fflatcodegen.cpp @@ -226,6 +226,13 @@ void FFlatCodeGen::writeData() "\n"; } + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + STATE_IDS(); } @@ -288,6 +295,9 @@ void FFlatCodeGen::writeExec() COND_TRANSLATE(); LOCATE_TRANS(); + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:\n"; if ( redFsm->anyRegCurStateRef() ) out << " _ps = " << CS() << ";\n"; @@ -341,14 +351,28 @@ void FFlatCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " switch ( " << EA() << "[" << CS() << "] ) {\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " }\n" + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if ( " << ET() << "[" << CS() << "] > 0 ) {\n" + " _trans = " << ET() << "[" << CS() << "] - 1;\n" + " goto _eof_trans;\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch ( " << EA() << "[" << CS() << "] ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n"; + } + + out << " }\n" "\n"; } diff --git a/rlgen-cd/fgotocodegen.cpp b/rlgen-cd/fgotocodegen.cpp index b3b497b..2e1f195 100644 --- a/rlgen-cd/fgotocodegen.cpp +++ b/rlgen-cd/fgotocodegen.cpp @@ -258,14 +258,33 @@ void FGotoCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " switch ( " << EA() << "[" << CS() << "] ) {\n"; - EOF_ACTION_SWITCH(); + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " switch ( " << CS() << " ) {\n"; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << " case " << st->id << ": goto tr" << st->eofTrans->id << ";\n"; + } + SWITCH_DEFAULT() << - " }\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch ( " << EA() << "[" << CS() << "] ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n"; + } + + out << " }\n" "\n"; } diff --git a/rlgen-cd/flatcodegen.cpp b/rlgen-cd/flatcodegen.cpp index 7be6097..eb8e377 100644 --- a/rlgen-cd/flatcodegen.cpp +++ b/rlgen-cd/flatcodegen.cpp @@ -228,6 +228,29 @@ std::ostream &FlatCodeGen::EOF_ACTIONS() return out; } +std::ostream &FlatCodeGen::EOF_TRANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + + long trans = 0; + if ( st->eofTrans != 0 ) + trans = st->eofTrans->id+1; + out << trans; + + if ( !st.last() ) { + out << ", "; + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + std::ostream &FlatCodeGen::COND_KEYS() { out << '\t'; @@ -595,6 +618,13 @@ void FlatCodeGen::writeData() "\n"; } + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + STATE_IDS(); } @@ -713,6 +743,9 @@ void FlatCodeGen::writeExec() LOCATE_TRANS(); + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:\n"; + if ( redFsm->anyRegCurStateRef() ) out << " _ps = " << CS() << ";\n"; @@ -774,24 +807,38 @@ void FlatCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << POINTER() << "__acts = " << - ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" - " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" - " while ( __nacts-- > 0 ) {\n" - " switch ( *__acts++ ) {\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " }\n" - " }\n" + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if ( " << ET() << "[" << CS() << "] > 0 ) {\n" + " _trans = " << ET() << "[" << CS() << "] - 1;\n" + " goto _eof_trans;\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << + POINTER() << "__acts = " << + ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" + " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" + " while ( __nacts-- > 0 ) {\n" + " switch ( *__acts++ ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n" + " }\n"; + } + + out << " }\n" "\n"; } - if ( outLabelUsed ) out << " _out: {}\n"; diff --git a/rlgen-cd/flatcodegen.h b/rlgen-cd/flatcodegen.h index 4497b24..651f30c 100644 --- a/rlgen-cd/flatcodegen.h +++ b/rlgen-cd/flatcodegen.h @@ -54,6 +54,7 @@ protected: std::ostream &TO_STATE_ACTIONS(); std::ostream &FROM_STATE_ACTIONS(); std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); std::ostream &TRANS_TARGS(); std::ostream &TRANS_ACTIONS(); void LOCATE_TRANS(); diff --git a/rlgen-cd/fsmcodegen.h b/rlgen-cd/fsmcodegen.h index 9a82169..30eaa8f 100644 --- a/rlgen-cd/fsmcodegen.h +++ b/rlgen-cd/fsmcodegen.h @@ -120,6 +120,7 @@ protected: string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; } string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; } string EA() { return "_" + DATA_PREFIX() + "eof_actions"; } + string ET() { return "_" + DATA_PREFIX() + "eof_trans"; } string SP() { return "_" + DATA_PREFIX() + "key_spans"; } string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; } string START() { return DATA_PREFIX() + "start"; } diff --git a/rlgen-cd/ftabcodegen.cpp b/rlgen-cd/ftabcodegen.cpp index ed49cd7..f2c484c 100644 --- a/rlgen-cd/ftabcodegen.cpp +++ b/rlgen-cd/ftabcodegen.cpp @@ -280,6 +280,13 @@ void FTabCodeGen::writeData() "\n"; } + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + STATE_IDS(); } @@ -337,12 +344,15 @@ void FTabCodeGen::writeExec() out << "_match:\n"; - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << CS() << ";\n"; - if ( useIndicies ) out << " _trans = " << I() << "[_trans];\n"; + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << CS() << ";\n"; + out << " " << CS() << " = " << TT() << "[_trans];\n" "\n"; @@ -393,14 +403,28 @@ void FTabCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " switch ( " << EA() << "[" << CS() << "] ) {\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " }\n" + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if ( " << ET() << "[" << CS() << "] > 0 ) {\n" + " _trans = " << ET() << "[" << CS() << "] - 1;\n" + " goto _eof_trans;\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " switch ( " << EA() << "[" << CS() << "] ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n"; + } + + out << " }\n" "\n"; } diff --git a/rlgen-cd/gotocodegen.cpp b/rlgen-cd/gotocodegen.cpp index ea4337e..d163013 100644 --- a/rlgen-cd/gotocodegen.cpp +++ b/rlgen-cd/gotocodegen.cpp @@ -757,19 +757,39 @@ void GotoCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << POINTER() << "__acts = " << - ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" - " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" - " while ( __nacts-- > 0 ) {\n" - " switch ( *__acts++ ) {\n"; - EOF_ACTION_SWITCH(); + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " switch ( " << CS() << " ) {\n"; + + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << " case " << st->id << ": goto tr" << st->eofTrans->id << ";\n"; + } + SWITCH_DEFAULT() << - " }\n" - " }\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << + POINTER() << "__acts = " << + ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" + " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" + " while ( __nacts-- > 0 ) {\n" + " switch ( *__acts++ ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n" + " }\n"; + } + + out << " }\n" "\n"; } diff --git a/rlgen-cd/ipgotocodegen.cpp b/rlgen-cd/ipgotocodegen.cpp index 42659e3..0a35601 100644 --- a/rlgen-cd/ipgotocodegen.cpp +++ b/rlgen-cd/ipgotocodegen.cpp @@ -266,6 +266,11 @@ std::ostream &IpGotoCodeGen::FINISH_CASES() } } + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + if ( st->eofTrans != 0 ) + out << " case " << st->id << ": goto tr" << st->eofTrans->id << ";\n"; + } + for ( ActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { if ( act->eofRefs != 0 ) { for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ ) @@ -409,7 +414,7 @@ void IpGotoCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" " {\n" diff --git a/rlgen-cd/tabcodegen.cpp b/rlgen-cd/tabcodegen.cpp index 0787640..ee22831 100644 --- a/rlgen-cd/tabcodegen.cpp +++ b/rlgen-cd/tabcodegen.cpp @@ -327,6 +327,29 @@ std::ostream &TabCodeGen::EOF_ACTIONS() return out; } +std::ostream &TabCodeGen::EOF_TRANS() +{ + out << "\t"; + int totalStateNum = 0; + for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { + /* Write any eof action. */ + + long trans = 0; + if ( st->eofTrans != 0 ) + trans = st->eofTrans->id+1; + out << trans; + + if ( !st.last() ) { + out << ", "; + if ( ++totalStateNum % IALL == 0 ) + out << "\n\t"; + } + } + out << "\n"; + return out; +} + + std::ostream &TabCodeGen::COND_KEYS() { out << '\t'; @@ -809,6 +832,13 @@ void TabCodeGen::writeData() "\n"; } + if ( redFsm->anyEofTrans() ) { + OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex+1), ET() ); + EOF_TRANS(); + CLOSE_ARRAY() << + "\n"; + } + STATE_IDS(); } @@ -932,11 +962,14 @@ void TabCodeGen::writeExec() out << "_match:\n"; - if ( redFsm->anyRegCurStateRef() ) - out << " _ps = " << CS() << ";\n"; - if ( useIndicies ) out << " _trans = " << I() << "[_trans];\n"; + + if ( redFsm->anyEofTrans() ) + out << "_eof_trans:\n"; + + if ( redFsm->anyRegCurStateRef() ) + out << " _ps = " << CS() << ";\n"; out << " " << CS() << " = " << TT() << "[_trans];\n" @@ -996,19 +1029,34 @@ void TabCodeGen::writeExec() if ( testEofUsed ) out << " _test_eof: {}\n"; - if ( redFsm->anyEofActions() ) { + if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { out << " if ( " << P() << " == " << EOFV() << " )\n" - " {\n" - " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << - POINTER() << "__acts = " << ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" - " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" - " while ( __nacts-- > 0 ) {\n" - " switch ( *__acts++ ) {\n"; - EOF_ACTION_SWITCH(); - SWITCH_DEFAULT() << - " }\n" - " }\n" + " {\n"; + + if ( redFsm->anyEofTrans() ) { + out << + " if ( " << ET() << "[" << CS() << "] > 0 ) {\n" + " _trans = " << ET() << "[" << CS() << "] - 1;\n" + " goto _eof_trans;\n" + " }\n"; + } + + if ( redFsm->anyEofActions() ) { + out << + " " << PTR_CONST() << ARRAY_TYPE(redFsm->maxActArrItem) << + POINTER() << "__acts = " << + ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n" + " " << UINT() << " __nacts = " << CAST(UINT()) << " *__acts++;\n" + " while ( __nacts-- > 0 ) {\n" + " switch ( *__acts++ ) {\n"; + EOF_ACTION_SWITCH(); + SWITCH_DEFAULT() << + " }\n" + " }\n"; + } + + out << " }\n" "\n"; } diff --git a/rlgen-cd/tabcodegen.h b/rlgen-cd/tabcodegen.h index ea4d6d9..177896e 100644 --- a/rlgen-cd/tabcodegen.h +++ b/rlgen-cd/tabcodegen.h @@ -63,6 +63,7 @@ protected: std::ostream &TO_STATE_ACTIONS(); std::ostream &FROM_STATE_ACTIONS(); std::ostream &EOF_ACTIONS(); + std::ostream &EOF_TRANS(); std::ostream &TRANS_TARGS(); std::ostream &TRANS_ACTIONS(); std::ostream &TRANS_TARGS_WI(); diff --git a/test/checkeofact.txl b/test/checkeofact.txl index d01f788..8189013 100644 --- a/test/checkeofact.txl +++ b/test/checkeofact.txl @@ -66,6 +66,11 @@ rule findEof12 '<> 'eof _ [repeat machine_expr_item] end rule +rule findScanner + match [machine_expr_item] + '|* _ [repeat scanner_item] '*| +end rule + function findEof P [program] replace [program] _ [program] @@ -75,6 +80,7 @@ function findEof P [program] [findEof4] [findEof5] [findEof6] [findEof7] [findEof8] [findEof9] [findEof10] [findEof11] [findEof12] + [findScanner] by 'yes end function diff --git a/test/cppscan3.rl b/test/cppscan3.rl index 02c96be..1dacb1f 100644 --- a/test/cppscan3.rl +++ b/test/cppscan3.rl @@ -141,6 +141,7 @@ void Scanner::execute( char *data, int len ) { char *p = data; char *pe = data + len; + char *eof = pe; %% write exec; @@ -193,8 +194,7 @@ int main() "44. 44\n" "44 . 44\n" "44.44\n" - "_hithere22\n" - "\n" + "_hithere22" ); test( @@ -208,7 +208,7 @@ int main() "0x98\n" "0x\n" "//\n" - "/* * */\n" + "/* * */" ); test( @@ -246,7 +246,7 @@ int main() <241> <195> _hithere22 -P: 53 +P: 51 <193> '\'' <192> "\n\d'\"" <241> @@ -279,7 +279,7 @@ P: 53 <242> // <242> /* * */ -P: 56 +P: 55 P: 1 PARSE ERROR #endif diff --git a/test/cppscan5.rl b/test/cppscan5.rl index dcbb715..b7378f1 100644 --- a/test/cppscan5.rl +++ b/test/cppscan5.rl @@ -142,6 +142,7 @@ class Scanner { char *p = data; char *pe = data + len; + char *eof = pe; %% write exec; } @@ -185,8 +186,7 @@ int main() "44. 44\n" "44 . 44\n" "44.44\n" - "_hithere22\n" - "\n" + "_hithere22" ); test( @@ -200,7 +200,7 @@ int main() "0x98\n" "0x\n" "//\n" - "/* * */\n" + "/* * */" ); test( diff --git a/test/cppscan6.rl b/test/cppscan6.rl index c0fde39..f699ca0 100644 --- a/test/cppscan6.rl +++ b/test/cppscan6.rl @@ -288,8 +288,8 @@ int token; *|; }%% /* _____INPUT_____ -"\"\\\"hi\" /!\n!/\n44 .44\n44. 44\n44 . 44\n44.44\n_hithere22\n\n" -"'\\''\"\\n\\d'\\\"\"\nhi\n99\n.99\n99e-4\n->*\n||\n0x98\n0x\n//\n/! * !/\n" +"\"\\\"hi\" /!\n!/\n44 .44\n44. 44\n44 . 44\n44.44\n_hithere22" +"'\\''\"\\n\\d'\\\"\"\nhi\n99\n.99\n99e-4\n->*\n||\n0x98\n0x\n//\n/! * !/" "'\n'\n" _____INPUT_____ */ /* _____OUTPUT_____ diff --git a/test/lmgoto.rl b/test/lmgoto.rl index 4d9dac4..36a5e78 100644 --- a/test/lmgoto.rl +++ b/test/lmgoto.rl @@ -156,6 +156,7 @@ void Scanner::run( char *buf ) %% write init; char *p = buf; char *pe = buf + len; + char *eof = pe; %% write exec; if ( cs == Scanner_error ) { @@ -169,7 +170,7 @@ int main() Scanner scanner; scanner.run( "//hello*/\n" - "/*hi there*/ hello 0x88\n" + "/*hi there*/ hello 0x88" ); return 0; } diff --git a/test/rlscan.rl b/test/rlscan.rl index 24861b6..27cd655 100644 --- a/test/rlscan.rl +++ b/test/rlscan.rl @@ -258,6 +258,7 @@ void test( char *data ) /* Read in a block. */ char *p = data; char *pe = data + strlen( data ); + char *eof = pe; %% write exec; if ( cs == RagelScan_error ) { diff --git a/test/tokstart1.rl b/test/tokstart1.rl index cdf916d..52e9544 100644 --- a/test/tokstart1.rl +++ b/test/tokstart1.rl @@ -106,15 +106,11 @@ int Scanner::execute( char *data, int len ) { char *p = data; char *pe = data + len; + char *eof = pe; %% write exec; - int have = 0; - if ( tokstart != 0 ) { - have = pe - tokstart; - memmove( data, tokstart, have ); - } - return have; + return 0; } int Scanner::finish( ) @@ -237,4 +233,6 @@ from: fc = tokstart = 30 to: fc = tokstart = 30 +to: fc = + tokstart = -1 #endif -- 2.7.4