"Fossies" - the Fresh Open Source Software Archive  

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

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

ipgoto.cc  (ragel-7.0.0.10):ipgoto.cc  (ragel-7.0.0.11)
/* /*
* Copyright 2001-2014 Adrian Thurston <thurston@colm.net> * Copyright 2001-2018 Adrian Thurston <thurston@colm.net>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the * deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is * sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in al l * The above copyright notice and this permission notice shall be included in al l
* copies or substantial portions of the Software. * copies or substantial portions of the Software.
skipping to change at line 482 skipping to change at line 482
{ {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
out << TABS(1) << "case " << st->id << ":\n"; out << TABS(1) << "case " << st->id << ":\n";
out << TABS(2) << "goto st_case_" << st->id << ";\n"; out << TABS(2) << "goto st_case_" << st->id << ";\n";
} }
return out; return out;
} }
void IpGoto::NFA_PUSH( RedStateAp *state ) void IpGoto::NFA_PUSH( RedStateAp *state )
{ {
if ( redFsm->anyNfaStates() ) { std::stringstream ss;
out << ss << state->id;
" if ( " << ARR_REF( nfaOffsets ) << "[" << state-> CodeGen::NFA_PUSH( ss.str() );
id << "] ) {\n"
" int alt = 0; \n"
" int new_recs = " << ARR_REF( nfaTargs ) <
< "[" << CAST("int") <<
ARR_REF( nfaOffsets ) << "[" << s
tate->id << "]];\n";
if ( red->nfaPrePushExpr != 0 ) {
out << OPEN_HOST_BLOCK( red->nfaPrePushExpr );
INLINE_LIST( out, red->nfaPrePushExpr->inlineList, 0, fal
se, false );
out << CLOSE_HOST_BLOCK();
}
out <<
" while ( alt < new_recs ) { \n";
out <<
" nfa_bp[nfa_len].state = " << ARR_
REF( nfaTargs ) << "[" << CAST("int") <<
ARR_REF( nfaOffsets ) <<
"[" << state->id << "] + 1 + alt];\n"
" nfa_bp[nfa_len].p = " << P() << "
;\n";
if ( redFsm->bAnyNfaPops ) {
out <<
" nfa_bp[nfa_len].popTrans
= " << CAST("long") <<
ARR_REF( nfaOffse
ts ) << "[" << state->id << "] + 1 + alt;\n"
"\n"
;
}
if ( redFsm->bAnyNfaPushes ) {
out <<
" switch ( " << ARR_REF( nf
aPushActions ) << "[" << CAST("int") <<
ARR_REF( nfaOffse
ts ) << "[" << state->id << "] + 1 + alt] ) {\n";
/* Loop the actions. */
for ( GenActionTableMap::Iter redAct = redFsm->actionMap;
redAct.lte(); redAct++ )
{
if ( redAct->numNfaPushRefs > 0 ) {
/* Write the entry label. */
out << "\t " << CASE( STR( redAct->actLis
tId+1 ) ) << " {\n";
/* Write each action in the list of actio
n items. */
for ( GenActionTable::Iter item = redAct-
>key; item.lte(); item++ )
ACTION( out, item->value, IlOpts(
0, false, false ) );
out << "\n\t" << CEND() << "}\n";
}
}
out <<
" }\n";
}
out <<
" nfa_len += 1;\n"
" alt += 1;\n"
" }\n"
" }\n"
;
}
} }
std::ostream &IpGoto::STATE_GOTOS() std::ostream &IpGoto::STATE_GOTOS()
{ {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st == redFsm->errState ) if ( st == redFsm->errState )
STATE_GOTO_ERROR(); STATE_GOTO_ERROR();
else { else {
/* Writing code above state gotos. */ /* Writing code above state gotos. */
GOTO_HEADER( st ); GOTO_HEADER( st );
skipping to change at line 585 skipping to change at line 527
std::ostream &IpGoto::FINISH_CASES() std::ostream &IpGoto::FINISH_CASES()
{ {
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st->eofAction != 0 ) { if ( st->eofAction != 0 ) {
if ( st->eofAction->eofRefs == 0 ) if ( st->eofAction->eofRefs == 0 )
st->eofAction->eofRefs = new IntSet; st->eofAction->eofRefs = new IntSet;
st->eofAction->eofRefs->insert( st->id ); st->eofAction->eofRefs->insert( st->id );
} }
} }
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st->eofTrans != 0 ) {
RedCondPair *cond = st->eofTrans->outCond( 0 );
out << " case " << st->id << ": goto ctr" << cond-
>id << ";\n";
}
}
for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) { for ( GenActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) {
if ( act->eofRefs != 0 ) { if ( act->eofRefs != 0 ) {
for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ ) { for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ ) {
out << " case " << *pst << ": \n"; out << " case " << *pst << ": \n";
if ( ! pst.last() ) if ( ! pst.last() )
out << " " << FALLTHROUGH( ) << "\n"; out << " " << FALLTHROUGH( ) << "\n";
} }
/* Write each action in the eof action list. */ /* Write each action in the eof action list. */
for ( GenActionTable::Iter item = act->key; item.lte(); i tem++ ) for ( GenActionTable::Iter item = act->key; item.lte(); i tem++ )
ACTION( out, item->value, IlOpts( STATE_ERR_STATE , true, false ) ); ACTION( out, item->value, IlOpts( STATE_ERR_STATE , true, false ) );
out << "\n\tbreak;\n"; out << "\n\tbreak;\n";
} }
} }
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
if ( st->eofTrans != 0 ) {
RedCondPair *cond = st->eofTrans->outCond( 0 );
out << " case " << st->id << ": goto ctr" << cond-
>id << ";\n";
}
}
return out; return out;
} }
void IpGoto::setLabelsNeeded( GenInlineList *inlineList ) void IpGoto::setLabelsNeeded( GenInlineList *inlineList )
{ {
for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) { for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) {
switch ( item->type ) { switch ( item->type ) {
case GenInlineItem::Goto: case GenInlineItem::Call: case GenInlineItem::Goto: case GenInlineItem::Call:
case GenInlineItem::Ncall: { case GenInlineItem::Ncall: {
/* Mark the target as needing a label. */ /* Mark the target as needing a label. */
skipping to change at line 760 skipping to change at line 702
" st_out:\n"; " st_out:\n";
EXIT_STATES() << EXIT_STATES() <<
"\n"; "\n";
if ( testEofUsed ) if ( testEofUsed )
out << " _test_eof: {}\n"; out << " _test_eof: {}\n";
if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
out << out <<
" if ( " << P() << " == " << vEOF() << " )\n" " if ( " << P() << " == " << vEOF() << " )\n"
" {\n" " {\n";
out <<
" switch ( " << vCS() << " ) {\n";
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
{
out << " case " << st->id << ": {\n";
NFA_PUSH( st );
out << "\n\t" << CEND() << "}\n";
}
out <<
" }\n";
out <<
" switch ( " << vCS() << " ) {\n";
bool okeydokey = false;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
{
if ( st->outCondSpace != 0 ) {
out << " case " << st->id << ": {\n";
out << "int ck = 0;\n";
for ( GenCondSet::Iter csi = st->outCondSpace->co
ndSet; csi.lte(); csi++ ) {
out << "if ( ";
CONDITION( out, *csi );
Size condValOffset = (1 << csi.pos());
out << " ) ck += " << condValOffset << ";
\n";
}
out << " switch ( ck ) {\n";
for ( CondKeySet::Iter k = st->outCondKeys; k.lte
(); k++ ) {
out << "case " << *k << ": goto _okeydoke
y;\n";
okeydokey = true;
}
out << "}\n";
out << vCS() << " = " << ERROR_STATE() << ";\n";
out << "goto _out;\n";
out << "}\n";
}
}
out <<
" }\n";
if ( okeydokey ) {
out <<
"_okeydokey: {}\n";
}
out <<
" switch ( " << vCS() << " ) {\n"; " switch ( " << vCS() << " ) {\n";
FINISH_CASES() << FINISH_CASES() <<
" }\n" " }\n"
" }\n" " }\n"
"\n"; "\n";
} }
if ( outLabelUsed ) if ( outLabelUsed )
out << " _out: {}\n"; out << " _out: {}\n";
 End of changes. 5 change blocks. 
86 lines changed or deleted 70 lines changed or added

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