X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=ragel%2Fxmlcodegen.cpp;h=8cbe73875d5b0f6a548b8b18f9c0554a09117ae6;hb=6f464c641200198eb35dbfc2429fa0acda37c2a9;hp=dd3616735eb3569be18507d90103671b6bea0652;hpb=6c5e5cce0ac071379a3fff42482e1bbef7eb264d;p=external%2Fragel.git diff --git a/ragel/xmlcodegen.cpp b/ragel/xmlcodegen.cpp index dd36167..8cbe738 100644 --- a/ragel/xmlcodegen.cpp +++ b/ragel/xmlcodegen.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007 Adrian Thurston + * Copyright 2005-2007 Adrian Thurston */ /* This file is part of Ragel. @@ -175,6 +175,26 @@ void XMLCodeGen::writeTransList( StateAp *state ) out << " \n"; } +void XMLCodeGen::writeEofTrans( StateAp *state ) +{ + RedActionTable *eofActions = 0; + if ( state->eofActionTable.length() > 0 ) + eofActions = actionTableMap.find( state->eofActionTable ); + + /* The is used when there is an eof target, otherwise the eof + * action goes into state actions. */ + if ( state->eofTarget != 0 ) { + out << " " << state->eofTarget->alg.stateNum; + + if ( eofActions != 0 ) + out << " " << eofActions->id; + else + out << " x"; + + out << "" << endl; + } +} + void XMLCodeGen::writeText( InlineItem *item ) { if ( item->prev == 0 || item->prev->type != InlineItem::Text ) @@ -291,6 +311,11 @@ void XMLCodeGen::writeLmSwitch( InlineItem *item ) LongestMatch *longestMatch = item->longestMatch; out << "\n"; + /* We can't put the here because we may need to handle the error + * case and in that case p should not be changed. Instead use a default + * label in the switch to adjust p when user actions are not set. An id of + * -1 indicates the default. */ + if ( longestMatch->lmSwitchHandlesError ) { /* If the switch handles error then we should have also forced the * error state. */ @@ -301,17 +326,27 @@ void XMLCodeGen::writeLmSwitch( InlineItem *item ) out << "\n"; } + bool needDefault = false; for ( LmPartList::Iter lmi = *longestMatch->longestMatchList; lmi.lte(); lmi++ ) { - if ( lmi->inLmSelect && lmi->action != 0 ) { - /* Open the action. Write it with the context that sets up _p - * when doing control flow changes from inside the machine. */ - out << " longestMatchId << "\">"; - out << ""; - writeInlineList( lmi->action->inlineList ); - out << "\n"; + if ( lmi->inLmSelect ) { + if ( lmi->action == 0 ) + needDefault = true; + else { + /* Open the action. Write it with the context that sets up _p + * when doing control flow changes from inside the machine. */ + out << " longestMatchId << "\">"; + out << ""; + writeInlineList( lmi->action->inlineList ); + out << "\n"; + } } } + if ( needDefault ) { + out << " " + "\n"; + } + out << " "; } @@ -438,8 +473,10 @@ void XMLCodeGen::writeStateActions( StateAp *state ) if ( state->fromStateActionTable.length() > 0 ) fromStateActions = actionTableMap.find( state->fromStateActionTable ); + /* EOF actions go out here only if the state has no eof target. If it has + * an eof target then an eof transition will be used instead. */ RedActionTable *eofActions = 0; - if ( state->eofActionTable.length() > 0 ) + if ( state->eofTarget == 0 && state->eofActionTable.length() > 0 ) eofActions = actionTableMap.find( state->eofActionTable ); if ( toStateActions != 0 || fromStateActions != 0 || eofActions != 0 ) { @@ -457,7 +494,9 @@ void XMLCodeGen::writeStateActions( StateAp *state ) if ( eofActions != 0 ) out << " " << eofActions->id; else - out << " x"; out << "\n"; + out << " x"; + + out << "\n"; } } @@ -489,6 +528,7 @@ void XMLCodeGen::writeStateList() out << ">\n"; writeStateActions( st ); + writeEofTrans( st ); writeStateConditions( st ); writeTransList( st ); @@ -620,6 +660,20 @@ void XMLCodeGen::writeXML() out << "\n"; } + /* PrePush expression. */ + if ( pd->prePushExpr != 0 ) { + out << " "; + writeInlineList( pd->prePushExpr ); + out << "\n"; + } + + /* PostPop expression. */ + if ( pd->postPopExpr != 0 ) { + out << " "; + writeInlineList( pd->postPopExpr ); + out << "\n"; + } + /* * Variable expressions. */ @@ -635,6 +689,12 @@ void XMLCodeGen::writeXML() writeInlineList( pd->peExpr ); out << "\n"; } + + if ( pd->eofExpr != 0 ) { + out << " "; + writeInlineList( pd->eofExpr ); + out << "\n"; + } if ( pd->csExpr != 0 ) { out << " "; @@ -672,6 +732,12 @@ void XMLCodeGen::writeXML() out << "\n"; } + if ( pd->dataExpr != 0 ) { + out << " "; + writeInlineList( pd->dataExpr ); + out << "\n"; + } + writeExports(); writeMachine();