Can cleanup the xml code generation and remove the holdte and execte tags
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 10 Jun 2007 17:21:26 +0000 (17:21 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 10 Jun 2007 17:21:26 +0000 (17:21 +0000)
following the previous commit.

git-svn-id: http://svn.complang.org/ragel/trunk@239 052ea7fc-9027-0410-9066-f65837a77df0

ragel/xmlcodegen.cpp
ragel/xmlcodegen.h
redfsm/redfsm.h
redfsm/xmlparse.kh
redfsm/xmlparse.kl
redfsm/xmltags.gperf
rlgen-cd/fsmcodegen.cpp
rlgen-cd/fsmcodegen.h
rlgen-java/javacodegen.cpp
rlgen-ruby/rubycodegen.cpp

index f5d210a..f4570a9 100644 (file)
@@ -184,61 +184,7 @@ void XMLCodeGen::writeText( InlineItem *item )
                out << "</text>";
 }
 
-bool isLmItem( InlineItem *context )
-{
-       return context != 0 && (
-               context->type == InlineItem::LmOnLast ||
-               context->type == InlineItem::LmOnNext ||
-               context->type == InlineItem::LmOnLagBehind ||
-               context->type == InlineItem::LmSwitch );
-}
-
-void XMLCodeGen::writeCtrlFlow( InlineItem *item, InlineItem *context )
-{
-       switch ( item->type ) {
-       case InlineItem::Goto:
-               writeGoto( item, context );
-               break;
-       case InlineItem::GotoExpr:
-               writeGotoExpr( item, context );
-               break;
-       case InlineItem::Call:
-               writeCall( item, context );
-               break;
-       case InlineItem::CallExpr:
-               writeCallExpr( item, context );
-               break;
-       case InlineItem::Next:
-               writeNext( item, context );
-               break;
-       case InlineItem::NextExpr:
-               writeNextExpr( item, context );
-               break;
-       case InlineItem::Break:
-               out << "<break></break>";
-               break;
-       case InlineItem::Ret: 
-               out << "<ret></ret>";
-               break;
-       default: break;
-       }
-}
-
-void XMLCodeGen::writePtrMod( InlineItem *item, InlineItem * )
-{
-       switch ( item->type ) {
-       case InlineItem::Hold:
-               out << "<hold></hold>";
-               break;
-       case InlineItem::Exec:
-               writeActionExec( item );
-               break;
-       default: break;
-       }
-}
-
-
-void XMLCodeGen::writeGoto( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeGoto( InlineItem *item )
 {
        if ( pd->generatingSectionSubset )
                out << "<goto>-1</goto>";
@@ -248,7 +194,7 @@ void XMLCodeGen::writeGoto( InlineItem *item, InlineItem *context )
        }
 }
 
-void XMLCodeGen::writeCall( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeCall( InlineItem *item )
 {
        if ( pd->generatingSectionSubset )
                out << "<call>-1</call>";
@@ -258,7 +204,7 @@ void XMLCodeGen::writeCall( InlineItem *item, InlineItem *context )
        }
 }
 
-void XMLCodeGen::writeNext( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeNext( InlineItem *item )
 {
        if ( pd->generatingSectionSubset )
                out << "<next>-1</next>";
@@ -268,28 +214,28 @@ void XMLCodeGen::writeNext( InlineItem *item, InlineItem *context )
        }
 }
 
-void XMLCodeGen::writeGotoExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeGotoExpr( InlineItem *item )
 {
        out << "<goto_expr>";
-       writeInlineList( item->children, 0 );
+       writeInlineList( item->children );
        out << "</goto_expr>";
 }
 
-void XMLCodeGen::writeCallExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeCallExpr( InlineItem *item )
 {
        out << "<call_expr>";
-       writeInlineList( item->children, 0 );
+       writeInlineList( item->children );
        out << "</call_expr>";
 }
 
-void XMLCodeGen::writeNextExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeNextExpr( InlineItem *item )
 {
        out << "<next_expr>";
-       writeInlineList( item->children, 0 );
+       writeInlineList( item->children );
        out << "</next_expr>";
 }
 
-void XMLCodeGen::writeEntry( InlineItem * item )
+void XMLCodeGen::writeEntry( InlineItem *item )
 {
        if ( pd->generatingSectionSubset )
                out << "<entry>-1</entry>";
@@ -302,24 +248,17 @@ void XMLCodeGen::writeEntry( InlineItem * item )
 void XMLCodeGen::writeActionExec( InlineItem *item )
 {
        out << "<exec>";
-       writeInlineList( item->children, 0 );
+       writeInlineList( item->children );
        out << "</exec>";
 }
 
-void XMLCodeGen::writeActionExecTE( InlineItem *item )
-{
-       out << "<execte>";
-       writeInlineList( item->children, 0 );
-       out << "</execte>";
-}
-
 void XMLCodeGen::writeLmOnLast( InlineItem *item )
 {
        out << "<set_tokend>1</set_tokend>";
 
        if ( item->longestMatchPart->action != 0 ) {
                out << "<sub_action>";
-               writeInlineList( item->longestMatchPart->action->inlineList, item );
+               writeInlineList( item->longestMatchPart->action->inlineList );
                out << "</sub_action>";
        }
 }
@@ -331,7 +270,7 @@ void XMLCodeGen::writeLmOnNext( InlineItem *item )
 
        if ( item->longestMatchPart->action != 0 ) {
                out << "<sub_action>";
-               writeInlineList( item->longestMatchPart->action->inlineList, item );
+               writeInlineList( item->longestMatchPart->action->inlineList );
                out << "</sub_action>";
        }
 }
@@ -342,7 +281,7 @@ void XMLCodeGen::writeLmOnLagBehind( InlineItem *item )
 
        if ( item->longestMatchPart->action != 0 ) {
                out << "<sub_action>";
-               writeInlineList( item->longestMatchPart->action->inlineList, item );
+               writeInlineList( item->longestMatchPart->action->inlineList );
                out << "</sub_action>";
        }
 }
@@ -369,7 +308,7 @@ void XMLCodeGen::writeLmSwitch( InlineItem *item )
                         * when doing control flow changes from inside the machine. */
                        out << "      <sub_action id=\"" << lmi->longestMatchId << "\">";
                        out << "<exec><get_tokend></get_tokend></exec>";
-                       writeInlineList( lmi->action->inlineList, item );
+                       writeInlineList( lmi->action->inlineList );
                        out << "</sub_action>\n";
                }
        }
@@ -377,18 +316,36 @@ void XMLCodeGen::writeLmSwitch( InlineItem *item )
        out << "    </lm_switch>";
 }
 
-void XMLCodeGen::writeInlineList( InlineList *inlineList, InlineItem *context )
+void XMLCodeGen::writeInlineList( InlineList *inlineList )
 {
        for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
                switch ( item->type ) {
                case InlineItem::Text:
                        writeText( item );
                        break;
-               case InlineItem::Goto: case InlineItem::GotoExpr:
-               case InlineItem::Call: case InlineItem::CallExpr:
-               case InlineItem::Next: case InlineItem::NextExpr:
-               case InlineItem::Break: case InlineItem::Ret: 
-                       writeCtrlFlow( item, context );
+               case InlineItem::Goto:
+                       writeGoto( item );
+                       break;
+               case InlineItem::GotoExpr:
+                       writeGotoExpr( item );
+                       break;
+               case InlineItem::Call:
+                       writeCall( item );
+                       break;
+               case InlineItem::CallExpr:
+                       writeCallExpr( item );
+                       break;
+               case InlineItem::Next:
+                       writeNext( item );
+                       break;
+               case InlineItem::NextExpr:
+                       writeNextExpr( item );
+                       break;
+               case InlineItem::Break:
+                       out << "<break></break>";
+                       break;
+               case InlineItem::Ret: 
+                       out << "<ret></ret>";
                        break;
                case InlineItem::PChar:
                        out << "<pchar></pchar>";
@@ -407,8 +364,10 @@ void XMLCodeGen::writeInlineList( InlineList *inlineList, InlineItem *context )
                        break;
 
                case InlineItem::Hold:
+                       out << "<hold></hold>";
+                       break;
                case InlineItem::Exec:
-                       writePtrMod( item, context );
+                       writeActionExec( item );
                        break;
 
                case InlineItem::LmSetActId:
@@ -452,7 +411,7 @@ void XMLCodeGen::writeAction( Action *action )
        if ( action->name != 0 ) 
                out << " name=\"" << action->name << "\"";
        out << " line=\"" << action->loc.line << "\" col=\"" << action->loc.col << "\">";
-       writeInlineList( action->inlineList, 0 );
+       writeInlineList( action->inlineList );
        out << "</action>\n";
 }
 
@@ -651,14 +610,14 @@ void XMLCodeGen::writeXML()
        /* Getkey expression. */
        if ( pd->getKeyExpr != 0 ) {
                out << "  <getkey>";
-               writeInlineList( pd->getKeyExpr, 0 );
+               writeInlineList( pd->getKeyExpr );
                out << "</getkey>\n";
        }
 
        /* Access expression. */
        if ( pd->accessExpr != 0 ) {
                out << "  <access>";
-               writeInlineList( pd->accessExpr, 0 );
+               writeInlineList( pd->accessExpr );
                out << "</access>\n";
        }
 
@@ -668,49 +627,49 @@ void XMLCodeGen::writeXML()
 
        if ( pd->pExpr != 0 ) {
                out << "  <p_expr>";
-               writeInlineList( pd->pExpr, 0 );
+               writeInlineList( pd->pExpr );
                out << "</p_expr>\n";
        }
        
        if ( pd->peExpr != 0 ) {
                out << "  <pe_expr>";
-               writeInlineList( pd->peExpr, 0 );
+               writeInlineList( pd->peExpr );
                out << "</pe_expr>\n";
        }
        
        if ( pd->csExpr != 0 ) {
                out << "  <cs_expr>";
-               writeInlineList( pd->csExpr, 0 );
+               writeInlineList( pd->csExpr );
                out << "</cs_expr>\n";
        }
        
        if ( pd->topExpr != 0 ) {
                out << "  <top_expr>";
-               writeInlineList( pd->topExpr, 0 );
+               writeInlineList( pd->topExpr );
                out << "</top_expr>\n";
        }
        
        if ( pd->stackExpr != 0 ) {
                out << "  <stack_expr>";
-               writeInlineList( pd->stackExpr, 0 );
+               writeInlineList( pd->stackExpr );
                out << "</stack_expr>\n";
        }
        
        if ( pd->actExpr != 0 ) {
                out << "  <act_expr>";
-               writeInlineList( pd->actExpr, 0 );
+               writeInlineList( pd->actExpr );
                out << "</act_expr>\n";
        }
        
        if ( pd->tokstartExpr != 0 ) {
                out << "  <tokstart_expr>";
-               writeInlineList( pd->tokstartExpr, 0 );
+               writeInlineList( pd->tokstartExpr );
                out << "</tokstart_expr>\n";
        }
        
        if ( pd->tokendExpr != 0 ) {
                out << "  <tokend_expr>";
-               writeInlineList( pd->tokendExpr, 0 );
+               writeInlineList( pd->tokendExpr );
                out << "</tokend_expr>\n";
        }
        
index 6f4823b..f366029 100644 (file)
@@ -90,14 +90,12 @@ private:
 
        void writeKey( Key key );
        void writeText( InlineItem *item );
-       void writeCtrlFlow( InlineItem *item, InlineItem *context );
-       void writePtrMod( InlineItem *item, InlineItem *context );
-       void writeGoto( InlineItem *item, InlineItem *context );
-       void writeGotoExpr( InlineItem *item, InlineItem *context );
-       void writeCall( InlineItem *item, InlineItem *context );
-       void writeCallExpr( InlineItem *item, InlineItem *context );
-       void writeNext( InlineItem *item, InlineItem *context );
-       void writeNextExpr( InlineItem *item, InlineItem *context );
+       void writeGoto( InlineItem *item );
+       void writeGotoExpr( InlineItem *item );
+       void writeCall( InlineItem *item );
+       void writeCallExpr( InlineItem *item );
+       void writeNext( InlineItem *item );
+       void writeNextExpr( InlineItem *item );
        void writeEntry( InlineItem *item );
        void writeLmSetActId( InlineItem *item );
        void writeLmOnLast( InlineItem *item );
@@ -108,7 +106,7 @@ private:
        bool writeNameInst( NameInst *nameInst );
        void writeEntryPoints();
        void writeConditions();
-       void writeInlineList( InlineList *inlineList, InlineItem *context );
+       void writeInlineList( InlineList *inlineList );
        void writeActionList();
        void writeActionTableList();
        void reduceTrans( TransAp *trans );
@@ -119,7 +117,6 @@ private:
        void writeLmSwitch( InlineItem *item );
        void writeMachine();
        void writeActionExec( InlineItem *item );
-       void writeActionExecTE( InlineItem *item );
 
        char *fsmName;
        ParseData *pd;
index 85e49f4..64d73e7 100644 (file)
@@ -65,7 +65,7 @@ struct InlineItem
        enum Type 
        {
                Text, Goto, Call, Next, GotoExpr, CallExpr, NextExpr, Ret, 
-               PChar, Char, Hold, Exec, HoldTE, ExecTE, Curs, Targs, Entry,
+               PChar, Char, Hold, Exec, Curs, Targs, Entry,
                LmSwitch, LmSetActId, LmSetTokEnd, LmGetTokEnd, LmInitTokStart,
                LmInitAct, LmSetTokStart, SubAction, Break
        };
index 7b1d2a1..2e29db5 100644 (file)
@@ -109,10 +109,9 @@ struct Parser
                # Inline block tokens.
                token TAG_text, TAG_goto, TAG_call, TAG_next, TAG_goto_expr,
                        TAG_call_expr, TAG_next_expr, TAG_ret, TAG_pchar, TAG_char,
-                       TAG_hold, TAG_exec, TAG_holdte, TAG_execte, TAG_curs, TAG_targs,
-                       TAG_entry, TAG_data, TAG_lm_switch, TAG_init_act, TAG_set_act,
-                       TAG_set_tokend, TAG_get_tokend, TAG_init_tokstart,
-                       TAG_set_tokstart;
+                       TAG_hold, TAG_exec, TAG_curs, TAG_targs, TAG_entry, TAG_data, 
+                       TAG_lm_switch, TAG_init_act, TAG_set_act, TAG_set_tokend, 
+                       TAG_get_tokend, TAG_init_tokstart, TAG_set_tokstart;
 
                token TAG_write, TAG_access, TAG_break, TAG_arg, TAG_cs_expr;
 
index cf3be17..3f4d926 100644 (file)
@@ -530,8 +530,6 @@ inline_item: tag_pchar final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_char final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_hold final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_exec final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_holdte final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_execte final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_curs final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_targs final { $$->inlineItem = $1->inlineItem; };
 inline_item: tag_il_entry final { $$->inlineItem = $1->inlineItem; };
@@ -557,8 +555,6 @@ nonterm tag_pchar uses inline_item_type;
 nonterm tag_char uses inline_item_type;
 nonterm tag_hold uses inline_item_type;
 nonterm tag_exec uses inline_item_type;
-nonterm tag_holdte uses inline_item_type;
-nonterm tag_execte uses inline_item_type;
 nonterm tag_curs uses inline_item_type;
 nonterm tag_targs uses inline_item_type;
 nonterm tag_il_entry uses inline_item_type;
@@ -647,17 +643,6 @@ tag_exec: TAG_exec inline_list '/' TAG_exec
                $$->inlineItem->children = $2->inlineList;
        };
 
-tag_holdte: TAG_holdte '/' TAG_holdte
-       final {
-               $$->inlineItem = new InlineItem( InputLoc(), InlineItem::HoldTE );
-       };
-
-tag_execte: TAG_execte inline_list '/' TAG_execte
-       final {
-               $$->inlineItem = new InlineItem( InputLoc(), InlineItem::ExecTE );
-               $$->inlineItem->children = $2->inlineList;
-       };
-
 tag_curs: TAG_curs '/' TAG_curs
        final {
                $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Curs );
index be4374e..85ad4be 100644 (file)
@@ -57,8 +57,6 @@ pchar, TAG_pchar
 char, TAG_char
 hold, TAG_hold
 exec, TAG_exec
-holdte, TAG_holdte
-execte, TAG_execte
 curs, TAG_curs
 targs, TAG_targs
 entry, TAG_entry
index 93a5150..1fbeba5 100644 (file)
@@ -314,19 +314,6 @@ void FsmCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int inFini
        ret << "))-1;}";
 }
 
-void FsmCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
-       /* Tokend version of exec. */
-
-       /* The parser gives fexec two children. The double brackets are for D
-        * code. If the inline list is a single word it will get interpreted as a
-        * C-style cast by the D compiler. */
-       ret << "{" << TOKEND() << " = ((";
-       INLINE_LIST( ret, item->children, targState, inFinish );
-       ret << "));}";
-}
-
-
 void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item, 
                int targState, int inFinish )
 {
@@ -431,12 +418,6 @@ void FsmCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
                case InlineItem::Exec:
                        EXEC( ret, item, targState, inFinish );
                        break;
-               case InlineItem::HoldTE:
-                       ret << TOKEND() << "--;";
-                       break;
-               case InlineItem::ExecTE:
-                       EXECTE( ret, item, targState, inFinish );
-                       break;
                case InlineItem::Curs:
                        CURS( ret, inFinish );
                        break;
index e0834fc..1bd0a24 100644 (file)
@@ -139,7 +139,6 @@ protected:
        virtual void CURS( ostream &ret, bool inFinish ) = 0;
        virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0;
        void EXEC( ostream &ret, InlineItem *item, int targState, int inFinish );
-       void EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish );
        void LM_SWITCH( ostream &ret, InlineItem *item, int targState, int inFinish );
        void SET_ACT( ostream &ret, InlineItem *item );
        void INIT_TOKSTART( ostream &ret, InlineItem *item );
index c941ea7..8dc4dca 100644 (file)
@@ -119,18 +119,6 @@ void JavaTabCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int in
        ret << "))-1;}";
 }
 
-void JavaTabCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
-       /* Tokend version of exec. */
-
-       /* The parser gives fexec two children. The double brackets are for D
-        * code. If the inline list is a single word it will get interpreted as a
-        * C-style cast by the D compiler. */
-       ret << "{" << TOKEND() << " = ((";
-       INLINE_LIST( ret, item->children, targState, inFinish );
-       ret << "));}";
-}
-
 /* Write out an inline tree structure. Walks the list and possibly calls out
  * to virtual functions than handle language specific items in the tree. */
 void JavaTabCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList, 
@@ -165,12 +153,6 @@ void JavaTabCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
                case InlineItem::Exec:
                        EXEC( ret, item, targState, inFinish );
                        break;
-               case InlineItem::HoldTE:
-                       ret << TOKEND() << "--;";
-                       break;
-               case InlineItem::ExecTE:
-                       EXECTE( ret, item, targState, inFinish );
-                       break;
                case InlineItem::Curs:
                        ret << "(_ps)";
                        break;
index 1f68925..e91e63f 100644 (file)
@@ -502,18 +502,6 @@ void RubyCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int inFin
        ret << "))-1; end\n";
 }
 
-void RubyCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
-       /* Tokend version of exec. */
-
-       /* The parser gives fexec two children. The double brackets are for D
-        * code. If the inline list is a single word it will get interpreted as a
-        * C-style cast by the D compiler. */
-       ret << " begin " << TOKEND() << " = ((";
-       INLINE_LIST( ret, item->children, targState, inFinish );
-       ret << ")); end\n";
-}
-
 /* Write out an inline tree structure. Walks the list and possibly calls out
  * to virtual functions than handle language specific items in the tree. */
 void RubyCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList, 
@@ -548,12 +536,6 @@ void RubyCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
                case InlineItem::Exec:
                        EXEC( ret, item, targState, inFinish );
                        break;
-               case InlineItem::HoldTE:
-                       ret << TOKEND() << " = " << TOKEND() << " - 1;";
-                       break;
-               case InlineItem::ExecTE:
-                       EXECTE( ret, item, targState, inFinish );
-                       break;
                case InlineItem::Curs:
                        ret << "(_ps)";
                        break;