"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gotoloop.cc" between
ragel-7.0.0.11.tar.gz and ragel-7.0.0.12.tar.gz

About: Ragel compiles executable finite state machines from regular languages (C, C++, Obj-C, C#, D, Java, Go and Ruby). Development version.

gotoloop.cc  (ragel-7.0.0.11):gotoloop.cc  (ragel-7.0.0.12)
skipping to change at line 31 skipping to change at line 31
*/ */
#include "ragel.h" #include "ragel.h"
#include "gotoloop.h" #include "gotoloop.h"
#include "redfsm.h" #include "redfsm.h"
#include "bstmap.h" #include "bstmap.h"
#include "gendata.h" #include "gendata.h"
#include "parsedata.h" #include "parsedata.h"
#include "inputdata.h" #include "inputdata.h"
std::ostream &SwitchGotoLoop::ACTION_SWITCH() std::ostream &GotoLoop::ACTION_SWITCH()
{ {
/* Walk the list of functions, printing the cases. */ /* Walk the list of functions, printing the cases. */
for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) { for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) {
/* Write out referenced actions. */ /* Write out referenced actions. */
if ( act->numTransRefs > 0 ) { if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. * / /* Write the case label, the action and the case break. * /
out << "\t" << CASE( STR( act->actionId ) ) << "{\n"; out << "\t" << CASE( STR( act->actionId ) ) << "{\n";
ACTION( out, act, IlOpts( 0, false, false ) ); ACTION( out, act, IlOpts( 0, false, false ) );
out << "\n\t" << CEND() << "}\n"; out << "\n\t" << CEND() << "\n}\n";
} }
} }
return out; return out;
} }
std::ostream &SwitchGotoLoop::EOF_ACTION_SWITCH() std::ostream &GotoLoop::EOF_ACTION_SWITCH()
{ {
/* Walk the list of functions, printing the cases. */ /* Walk the list of functions, printing the cases. */
for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) { for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) {
/* Write out referenced actions. */ /* Write out referenced actions. */
if ( act->numEofRefs > 0 ) { if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. * / /* Write the case label, the action and the case break. * /
out << "\t" << CASE( STR( act->actionId ) ) << "{\n"; out << "\t" << CASE( STR( act->actionId ) ) << "{\n";
ACTION( out, act, IlOpts( 0, true, false ) ); ACTION( out, act, IlOpts( 0, true, false ) );
out << "\n\t" << CEND() << "}\n"; out << "\n\t" << CEND() << "\n}\n";
} }
} }
return out; return out;
} }
std::ostream &SwitchGotoLoop::FROM_STATE_ACTION_SWITCH() std::ostream &GotoLoop::FROM_STATE_ACTION_SWITCH()
{ {
/* Walk the list of functions, printing the cases. */ /* Walk the list of functions, printing the cases. */
for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) { for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) {
/* Write out referenced actions. */ /* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) { if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. * / /* Write the case label, the action and the case break. * /
out << "\t" << CASE( STR( act->actionId ) ) << "{\n"; out << "\t" << CASE( STR( act->actionId ) ) << "{\n";
ACTION( out, act, IlOpts( 0, false, false ) ); ACTION( out, act, IlOpts( 0, false, false ) );
out << "\n\t" << CEND() << "}\n"; out << "\n\t" << CEND() << "\n}\n";
} }
} }
return out; return out;
} }
std::ostream &SwitchGotoLoop::TO_STATE_ACTION_SWITCH() std::ostream &GotoLoop::TO_STATE_ACTION_SWITCH()
{ {
/* Walk the list of functions, printing the cases. */ /* Walk the list of functions, printing the cases. */
for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) { for ( GenActionList::Iter act = red->actionList; act.lte(); act++ ) {
/* Write out referenced actions. */ /* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) { if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. * / /* Write the case label, the action and the case break. * /
out << "\t" << CASE( STR( act->actionId ) ) << "{\n"; out << "\t" << CASE( STR( act->actionId ) ) << "{\n";
ACTION( out, act, IlOpts( 0, false, false ) ); ACTION( out, act, IlOpts( 0, false, false ) );
out << "\n\t" << CEND() << "}\n"; out << "\n\t" << CEND() << "\n}\n";
} }
} }
return out; return out;
} }
void SwitchGotoLoop::NFA_PUSH_ACTION( RedNfaTarg *targ ) void GotoLoop::NFA_PUSH_ACTION( RedNfaTarg *targ )
{ {
int act = 0; int act = 0;
if ( targ->push != 0 ) if ( targ->push != 0 )
act = targ->push->actListId+1; act = targ->push->actListId+1;
nfaPushActions.value( act ); nfaPushActions.value( act );
} }
void SwitchGotoLoop::NFA_POP_TEST( RedNfaTarg *targ ) void GotoLoop::NFA_POP_TEST( RedNfaTarg *targ )
{ {
int act = 0; int act = 0;
if ( targ->popTest != 0 ) if ( targ->popTest != 0 )
act = targ->popTest->actListId+1; act = targ->popTest->actListId+1;
nfaPopTrans.value( act ); nfaPopTrans.value( act );
} }
std::ostream &SwitchGotoLoop::EXEC_FUNCS() std::ostream &GotoLoop::EXEC_FUNCS()
{ {
/* Make labels that set acts and jump to execFuncs. Loop func indicies. * / /* Make labels that set acts and jump to execFuncs. Loop func indicies. * /
for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); r edAct++ ) { for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); r edAct++ ) {
if ( redAct->numTransRefs > 0 ) { if ( redAct->numTransRefs > 0 ) {
out << " f" << redAct->actListId << ": " << out << " f" << redAct->actListId << ": " <<
"" << acts << " = " << OFFSET( ARR_REF( actions ) , itoa( redAct->location+1 ) ) << ";" "" << acts << " = " << OFFSET( ARR_REF( actions ) , itoa( redAct->location+1 ) ) << ";"
" goto execFuncs;\n"; " goto execFuncs;\n";
} }
} }
out << out <<
"\n" "\n"
"execFuncs:\n"; "execFuncs:\n";
if ( redFsm->anyRegNbreak() ) if ( redFsm->anyRegNbreak() )
out << " _nbreak = 0;\n"; out << nbreak << " = 0;\n";
out << out <<
" " << nacts << " = " << CAST( UINT() ) << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << ";\n" " " << nacts << " = " << CAST( UINT() ) << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << ";\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" while ( " << nacts << " > 0 ) {\n" " while ( " << nacts << " > 0 ) {\n"
" switch ( " << DEREF( ARR_REF( actions ), "" + str ing(acts) + "" ) << " ) {\n"; " switch ( " << DEREF( ARR_REF( actions ), "" + str ing(acts) + "" ) << " ) {\n";
ACTION_SWITCH() << ACTION_SWITCH() <<
" }\n" " }\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" " << nacts << " -= 1;\n" " " << nacts << " -= 1;\n"
" }\n" " }\n"
"\n"; "\n";
if ( redFsm->anyRegNbreak() ) { if ( redFsm->anyRegNbreak() ) {
out << out <<
" if ( _nbreak == 1 )\n" " if ( " << nbreak << " == 1 )\n"
" goto _out;\n"; " goto " << _out << ";\n";
outLabelUsed = true;
} }
out << out <<
" goto _again;\n"; " goto _again;\n";
return out; return out;
} }
void SwitchGotoLoop::NFA_FROM_STATE_ACTION_EXEC() void GotoLoop::NFA_FROM_STATE_ACTION_EXEC()
{ {
if ( redFsm->anyFromStateActions() ) { if ( redFsm->anyFromStateActions() ) {
out << out <<
" " << acts << " = " << OFFSET( ARR_REF( actions ), ARR_REF( fromStateActions ) + "[nfa_bp[nfa_len].state]" ) << ";\n" " " << acts << " = " << OFFSET( ARR_REF( actions ), ARR_REF( fromStateActions ) + "[nfa_bp[nfa_len].state]" ) << ";\n"
" " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << ";\n" " " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << ";\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" while ( " << nacts << " > 0 ) {\n" " while ( " << nacts << " > 0 ) {\n"
" switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n"; " switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n";
FROM_STATE_ACTION_SWITCH() << FROM_STATE_ACTION_SWITCH() <<
" }\n" " }\n"
" " << nacts << " -= 1;\n" " " << nacts << " -= 1;\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" }\n" " }\n"
"\n"; "\n";
} }
} }
void SwitchGotoLoop::FROM_STATE_ACTIONS() void GotoLoop::FROM_STATE_ACTIONS()
{ {
if ( redFsm->anyFromStateActions() ) { if ( redFsm->anyFromStateActions() ) {
out << out <<
" " << acts << " = " << OFFSET( ARR_REF( actions ), " " << acts << " = " << OFFSET( ARR_REF( actions ),
ARR_REF( fromStateActions ) + "[" + vCS() + "]" ) << ";\n" ARR_REF( fromStateActions ) + "[" + vCS() + "]" ) << ";\n"
" " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << "; " << acts << " += 1;\n" " " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << "; " << acts << " += 1;\n"
" while ( " << nacts << " > 0 ) {\n" " while ( " << nacts << " > 0 ) {\n"
" switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n"; " switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n";
FROM_STATE_ACTION_SWITCH() << FROM_STATE_ACTION_SWITCH() <<
" }\n" " }\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" " << nacts << " -= 1;\n" " " << nacts << " -= 1;\n"
" }\n" " }\n"
"\n"; "\n";
} }
} }
void SwitchGotoLoop::TO_STATE_ACTIONS() void GotoLoop::TO_STATE_ACTIONS()
{ {
if ( redFsm->anyToStateActions() ) { if ( redFsm->anyToStateActions() ) {
out << out <<
" " << acts << " = " << OFFSET( ARR_REF( actions ), " " << acts << " = " << OFFSET( ARR_REF( actions ),
ARR_REF( toStateActions ) + "[" + vCS() + "]" ) << ";\n" ARR_REF( toStateActions ) + "[" + vCS() + "]" ) << ";\n"
" " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << "; " << acts << " += 1;\n" " " << nacts << " = " << CAST( UINT() ) << DEREF( A RR_REF( actions ), "" + string(acts) + "" ) << "; " << acts << " += 1;\n"
" while ( " << nacts << " > 0 ) {\n" " while ( " << nacts << " > 0 ) {\n"
" switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n"; " switch ( " << DEREF( ARR_REF( actions ), "" + string(acts) + "" ) << " ) {\n";
TO_STATE_ACTION_SWITCH() << TO_STATE_ACTION_SWITCH() <<
" }\n" " }\n"
" " << acts << " += 1;\n" " " << acts << " += 1;\n"
" " << nacts << " -= 1;\n" " " << nacts << " -= 1;\n"
" }\n" " }\n"
"\n"; "\n";
} }
} }
void SwitchGotoLoop::REG_ACTIONS() void GotoLoop::REG_ACTIONS()
{ {
} }
void SwitchGotoLoop::EOF_ACTIONS() void GotoLoop::EOF_ACTIONS()
{ {
if ( redFsm->anyEofActions() ) { if ( redFsm->anyEofActions() ) {
out << out <<
" " << INDEX( ARR_TYPE( actions ), "__acts" ) << "; \n" " " << INDEX( ARR_TYPE( actions ), "__acts" ) << "; \n"
" " << UINT() << " __nacts;\n" " " << UINT() << " __nacts;\n"
" __acts = " << OFFSET( ARR_REF( actions ), " __acts = " << OFFSET( ARR_REF( actions ),
ARR_REF( eofActions ) + "[" + vCS() + "]" ) << ";\n" ARR_REF( eofActions ) + "[" + vCS() + "]" ) << ";\n"
" __nacts = " << CAST( UINT() ) << DEREF( ARR_REF( actions ), "__acts" ) << "; __acts += 1;\n" " __nacts = " << CAST( UINT() ) << DEREF( ARR_REF( actions ), "__acts" ) << "; __acts += 1;\n"
" while ( __nacts > 0 ) {\n" " while ( __nacts > 0 ) {\n"
" switch ( " << DEREF( ARR_REF( actions ), "__acts" ) << " ) {\n"; " switch ( " << DEREF( ARR_REF( actions ), "__acts" ) << " ) {\n";
 End of changes. 18 change blocks. 
20 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)