Просмотр исходного кода

Restoring authorship annotation for <smalov@yandex-team.ru>. Commit 1 of 2.

smalov 3 лет назад
Родитель
Сommit
f70d9720e1

+ 2 - 2
contrib/libs/libidn/idna.c

@@ -234,8 +234,8 @@ step3:
 	  out[i] = src[i];
 	  out[i] = src[i];
       }
       }
     if (i < IDNA_LABEL_MAX_LENGTH + 1)
     if (i < IDNA_LABEL_MAX_LENGTH + 1)
-      out[i] = '\0';
-    else
+      out[i] = '\0'; 
+    else 
       out[IDNA_LABEL_MAX_LENGTH] = 0;
       out[IDNA_LABEL_MAX_LENGTH] = 0;
     if (inasciirange)
     if (inasciirange)
       goto step8;
       goto step8;

Разница между файлами не показана из-за своего большого размера
+ 789 - 789
contrib/tools/ragel6/cdcodegen.cpp


+ 220 - 220
contrib/tools/ragel6/cdcodegen.h

@@ -1,234 +1,234 @@
-/*
- *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+/* 
+ *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#ifndef _CDCODEGEN_H
-#define _CDCODEGEN_H
-
-#include <iostream>
-#include <string>
-#include <stdio.h>
-#include "common.h"
-#include "gendata.h"
-
-using std::string;
-using std::ostream;
-
-/* Integer array line length. */
-#define IALL 8
-
-/* Forwards. */
-struct RedFsmAp;
-struct RedStateAp;
-struct CodeGenData;
-struct GenAction;
-struct NameInst;
-struct GenInlineItem;
-struct GenInlineList;
-struct RedAction;
-struct LongestMatch;
-struct LongestMatchPart;
-
-string itoa( int i );
-
-/*
- * class FsmCodeGen
- */
-class FsmCodeGen : public CodeGenData
-{
-public:
-	FsmCodeGen( ostream &out );
-	virtual ~FsmCodeGen() {}
-
-	virtual void finishRagelDef();
-	virtual void writeInit();
-	virtual void writeStart();
-	virtual void writeFirstFinal();
-	virtual void writeError();
-
-protected:
-	string FSM_NAME();
-	string START_STATE_ID();
-	ostream &ACTIONS_ARRAY();
-	string GET_WIDE_KEY();
-	string GET_WIDE_KEY( RedStateAp *state );
-	string TABS( int level );
-	string KEY( Key key );
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#ifndef _CDCODEGEN_H 
+#define _CDCODEGEN_H 
+ 
+#include <iostream> 
+#include <string> 
+#include <stdio.h> 
+#include "common.h" 
+#include "gendata.h" 
+ 
+using std::string; 
+using std::ostream; 
+ 
+/* Integer array line length. */ 
+#define IALL 8 
+ 
+/* Forwards. */ 
+struct RedFsmAp; 
+struct RedStateAp; 
+struct CodeGenData; 
+struct GenAction; 
+struct NameInst; 
+struct GenInlineItem; 
+struct GenInlineList; 
+struct RedAction; 
+struct LongestMatch; 
+struct LongestMatchPart; 
+ 
+string itoa( int i ); 
+ 
+/* 
+ * class FsmCodeGen 
+ */ 
+class FsmCodeGen : public CodeGenData 
+{ 
+public: 
+	FsmCodeGen( ostream &out ); 
+	virtual ~FsmCodeGen() {} 
+ 
+	virtual void finishRagelDef(); 
+	virtual void writeInit(); 
+	virtual void writeStart(); 
+	virtual void writeFirstFinal(); 
+	virtual void writeError(); 
+ 
+protected: 
+	string FSM_NAME(); 
+	string START_STATE_ID(); 
+	ostream &ACTIONS_ARRAY(); 
+	string GET_WIDE_KEY(); 
+	string GET_WIDE_KEY( RedStateAp *state ); 
+	string TABS( int level ); 
+	string KEY( Key key ); 
 	string WIDE_KEY( RedStateAp *state, Key key );
 	string WIDE_KEY( RedStateAp *state, Key key );
-	string LDIR_PATH( char *path );
+	string LDIR_PATH( char *path ); 
 	virtual void ACTION( ostream &ret, GenAction *action, int targState, 
 	virtual void ACTION( ostream &ret, GenAction *action, int targState, 
-			bool inFinish, bool csForced );
-	void CONDITION( ostream &ret, GenAction *condition );
-	string ALPH_TYPE();
-	string WIDE_ALPH_TYPE();
-	string ARRAY_TYPE( unsigned long maxVal );
-
+			bool inFinish, bool csForced ); 
+	void CONDITION( ostream &ret, GenAction *condition ); 
+	string ALPH_TYPE(); 
+	string WIDE_ALPH_TYPE(); 
+	string ARRAY_TYPE( unsigned long maxVal ); 
+ 
 	bool isAlphTypeSigned();
 	bool isAlphTypeSigned();
 	bool isWideAlphTypeSigned();
 	bool isWideAlphTypeSigned();
 
 
-	virtual string ARR_OFF( string ptr, string offset ) = 0;
-	virtual string CAST( string type ) = 0;
-	virtual string UINT() = 0;
-	virtual string NULL_ITEM() = 0;
-	virtual string POINTER() = 0;
-	virtual string GET_KEY();
-	virtual ostream &SWITCH_DEFAULT() = 0;
-
-	string P();
-	string PE();
-	string vEOF();
-
-	string ACCESS();
-	string vCS();
-	string STACK();
-	string TOP();
-	string TOKSTART();
-	string TOKEND();
-	string ACT();
-
-	string DATA_PREFIX();
-	string PM() { return "_" + DATA_PREFIX() + "partition_map"; }
-	string C() { return "_" + DATA_PREFIX() + "cond_spaces"; }
-	string CK() { return "_" + DATA_PREFIX() + "cond_keys"; }
-	string K() { return "_" + DATA_PREFIX() + "trans_keys"; }
-	string I() { return "_" + DATA_PREFIX() + "indicies"; }
-	string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; }
-	string KO() { return "_" + DATA_PREFIX() + "key_offsets"; }
-	string IO() { return "_" + DATA_PREFIX() + "index_offsets"; }
-	string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; }
-	string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
-	string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
-	string A() { return "_" + DATA_PREFIX() + "actions"; }
-	string TA() { return "_" + DATA_PREFIX() + "trans_actions"; }
-	string TT() { return "_" + DATA_PREFIX() + "trans_targs"; }
-	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"; }
-	string ERROR() { return DATA_PREFIX() + "error"; }
-	string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; }
-	string CTXDATA() { return DATA_PREFIX() + "ctxdata"; }
-
+	virtual string ARR_OFF( string ptr, string offset ) = 0; 
+	virtual string CAST( string type ) = 0; 
+	virtual string UINT() = 0; 
+	virtual string NULL_ITEM() = 0; 
+	virtual string POINTER() = 0; 
+	virtual string GET_KEY(); 
+	virtual ostream &SWITCH_DEFAULT() = 0; 
+ 
+	string P(); 
+	string PE(); 
+	string vEOF(); 
+ 
+	string ACCESS(); 
+	string vCS(); 
+	string STACK(); 
+	string TOP(); 
+	string TOKSTART(); 
+	string TOKEND(); 
+	string ACT(); 
+ 
+	string DATA_PREFIX(); 
+	string PM() { return "_" + DATA_PREFIX() + "partition_map"; } 
+	string C() { return "_" + DATA_PREFIX() + "cond_spaces"; } 
+	string CK() { return "_" + DATA_PREFIX() + "cond_keys"; } 
+	string K() { return "_" + DATA_PREFIX() + "trans_keys"; } 
+	string I() { return "_" + DATA_PREFIX() + "indicies"; } 
+	string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; } 
+	string KO() { return "_" + DATA_PREFIX() + "key_offsets"; } 
+	string IO() { return "_" + DATA_PREFIX() + "index_offsets"; } 
+	string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; } 
+	string SL() { return "_" + DATA_PREFIX() + "single_lengths"; } 
+	string RL() { return "_" + DATA_PREFIX() + "range_lengths"; } 
+	string A() { return "_" + DATA_PREFIX() + "actions"; } 
+	string TA() { return "_" + DATA_PREFIX() + "trans_actions"; } 
+	string TT() { return "_" + DATA_PREFIX() + "trans_targs"; } 
+	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"; } 
+	string ERROR() { return DATA_PREFIX() + "error"; } 
+	string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; } 
+	string CTXDATA() { return DATA_PREFIX() + "ctxdata"; } 
+ 
 	void EOF_CHECK( ostream &ret );
 	void EOF_CHECK( ostream &ret );
 
 
-	void INLINE_LIST( ostream &ret, GenInlineList *inlineList, 
-			int targState, bool inFinish, bool csForced );
-	virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0;
-	virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0;
-	virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0;
-	virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0;
-	virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0;
-	virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, 
-			int targState, bool inFinish ) = 0;
-	virtual void RET( ostream &ret, bool inFinish ) = 0;
-	virtual void BREAK( ostream &ret, int targState, bool csForced ) = 0;
-	virtual void CURS( ostream &ret, bool inFinish ) = 0;
-	virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0;
-	void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish );
-	void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, 
-			int inFinish, bool csForced );
-	void SET_ACT( ostream &ret, GenInlineItem *item );
-	void INIT_TOKSTART( ostream &ret, GenInlineItem *item );
-	void INIT_ACT( ostream &ret, GenInlineItem *item );
-	void SET_TOKSTART( ostream &ret, GenInlineItem *item );
-	void SET_TOKEND( ostream &ret, GenInlineItem *item );
-	void GET_TOKEND( ostream &ret, GenInlineItem *item );
+	void INLINE_LIST( ostream &ret, GenInlineList *inlineList,  
+			int targState, bool inFinish, bool csForced ); 
+	virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0; 
+	virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0; 
+	virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0; 
+	virtual void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; 
+	virtual void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ) = 0; 
+	virtual void CALL_EXPR( ostream &ret, GenInlineItem *ilItem,  
+			int targState, bool inFinish ) = 0; 
+	virtual void RET( ostream &ret, bool inFinish ) = 0; 
+	virtual void BREAK( ostream &ret, int targState, bool csForced ) = 0; 
+	virtual void CURS( ostream &ret, bool inFinish ) = 0; 
+	virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0; 
+	void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish ); 
+	void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState,  
+			int inFinish, bool csForced ); 
+	void SET_ACT( ostream &ret, GenInlineItem *item ); 
+	void INIT_TOKSTART( ostream &ret, GenInlineItem *item ); 
+	void INIT_ACT( ostream &ret, GenInlineItem *item ); 
+	void SET_TOKSTART( ostream &ret, GenInlineItem *item ); 
+	void SET_TOKEND( ostream &ret, GenInlineItem *item ); 
+	void GET_TOKEND( ostream &ret, GenInlineItem *item ); 
 	virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, 
 	virtual void SUB_ACTION( ostream &ret, GenInlineItem *item, 
-			int targState, bool inFinish, bool csForced );
-	void STATE_IDS();
-
-	string ERROR_STATE();
-	string FIRST_FINAL_STATE();
-
-	virtual string PTR_CONST() = 0;
+			int targState, bool inFinish, bool csForced ); 
+	void STATE_IDS(); 
+ 
+	string ERROR_STATE(); 
+	string FIRST_FINAL_STATE(); 
+ 
+	virtual string PTR_CONST() = 0; 
 	virtual string PTR_CONST_END() = 0;
 	virtual string PTR_CONST_END() = 0;
-	virtual ostream &OPEN_ARRAY( string type, string name ) = 0;
-	virtual ostream &CLOSE_ARRAY() = 0;
-	virtual ostream &STATIC_VAR( string type, string name ) = 0;
-
-	virtual string CTRL_FLOW() = 0;
-
-	ostream &source_warning(const InputLoc &loc);
-	ostream &source_error(const InputLoc &loc);
-
-	unsigned int arrayTypeSize( unsigned long maxVal );
-
-	bool outLabelUsed;
-	bool testEofUsed;
-	bool againLabelUsed;
-	bool useIndicies;
-
-	void genLineDirective( ostream &out );
-
-public:
-	/* Determine if we should use indicies. */
-	virtual void calcIndexSize() {}
-};
-
-class CCodeGen : virtual public FsmCodeGen
-{
-public:
-	CCodeGen( ostream &out ) : FsmCodeGen(out) {}
-
-	virtual string NULL_ITEM();
-	virtual string POINTER();
-	virtual ostream &SWITCH_DEFAULT();
-	virtual ostream &OPEN_ARRAY( string type, string name );
-	virtual ostream &CLOSE_ARRAY();
-	virtual ostream &STATIC_VAR( string type, string name );
-	virtual string ARR_OFF( string ptr, string offset );
-	virtual string CAST( string type );
-	virtual string UINT();
-	virtual string PTR_CONST();
+	virtual ostream &OPEN_ARRAY( string type, string name ) = 0; 
+	virtual ostream &CLOSE_ARRAY() = 0; 
+	virtual ostream &STATIC_VAR( string type, string name ) = 0; 
+ 
+	virtual string CTRL_FLOW() = 0; 
+ 
+	ostream &source_warning(const InputLoc &loc); 
+	ostream &source_error(const InputLoc &loc); 
+ 
+	unsigned int arrayTypeSize( unsigned long maxVal ); 
+ 
+	bool outLabelUsed; 
+	bool testEofUsed; 
+	bool againLabelUsed; 
+	bool useIndicies; 
+ 
+	void genLineDirective( ostream &out ); 
+ 
+public: 
+	/* Determine if we should use indicies. */ 
+	virtual void calcIndexSize() {} 
+}; 
+ 
+class CCodeGen : virtual public FsmCodeGen 
+{ 
+public: 
+	CCodeGen( ostream &out ) : FsmCodeGen(out) {} 
+ 
+	virtual string NULL_ITEM(); 
+	virtual string POINTER(); 
+	virtual ostream &SWITCH_DEFAULT(); 
+	virtual ostream &OPEN_ARRAY( string type, string name ); 
+	virtual ostream &CLOSE_ARRAY(); 
+	virtual ostream &STATIC_VAR( string type, string name ); 
+	virtual string ARR_OFF( string ptr, string offset ); 
+	virtual string CAST( string type ); 
+	virtual string UINT(); 
+	virtual string PTR_CONST(); 
 	virtual string PTR_CONST_END();
 	virtual string PTR_CONST_END();
-	virtual string CTRL_FLOW();
-
-	virtual void writeExports();
-};
-
-class DCodeGen : virtual public FsmCodeGen
-{
-public:
-	DCodeGen( ostream &out ) : FsmCodeGen(out) {}
-
-	virtual string NULL_ITEM();
-	virtual string POINTER();
-	virtual ostream &SWITCH_DEFAULT();
-	virtual ostream &OPEN_ARRAY( string type, string name );
-	virtual ostream &CLOSE_ARRAY();
-	virtual ostream &STATIC_VAR( string type, string name );
-	virtual string ARR_OFF( string ptr, string offset );
-	virtual string CAST( string type );
-	virtual string UINT();
-	virtual string PTR_CONST();
+	virtual string CTRL_FLOW(); 
+ 
+	virtual void writeExports(); 
+}; 
+ 
+class DCodeGen : virtual public FsmCodeGen 
+{ 
+public: 
+	DCodeGen( ostream &out ) : FsmCodeGen(out) {} 
+ 
+	virtual string NULL_ITEM(); 
+	virtual string POINTER(); 
+	virtual ostream &SWITCH_DEFAULT(); 
+	virtual ostream &OPEN_ARRAY( string type, string name ); 
+	virtual ostream &CLOSE_ARRAY(); 
+	virtual ostream &STATIC_VAR( string type, string name ); 
+	virtual string ARR_OFF( string ptr, string offset ); 
+	virtual string CAST( string type ); 
+	virtual string UINT(); 
+	virtual string PTR_CONST(); 
 	virtual string PTR_CONST_END();
 	virtual string PTR_CONST_END();
-	virtual string CTRL_FLOW();
-
-	virtual void writeExports();
-};
-
+	virtual string CTRL_FLOW(); 
+ 
+	virtual void writeExports(); 
+}; 
+ 
 class D2CodeGen : virtual public FsmCodeGen
 class D2CodeGen : virtual public FsmCodeGen
 {
 {
 public:
 public:
@@ -255,4 +255,4 @@ public:
 
 
 };
 };
 
 
-#endif
+#endif 

+ 375 - 375
contrib/tools/ragel6/cdfflat.cpp

@@ -1,384 +1,384 @@
-/*
- *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+/* 
+ *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#include "ragel.h"
-#include "cdfflat.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-std::ostream &FFlatCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->toStateAction != 0 )
-		act = state->toStateAction->actListId+1;
-	out << act;
-	return out;
-}
-
-std::ostream &FFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->fromStateAction != 0 )
-		act = state->fromStateAction->actListId+1;
-	out << act;
-	return out;
-}
-
-std::ostream &FFlatCodeGen::EOF_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->eofAction != 0 )
-		act = state->eofAction->actListId+1;
-	out << act;
-	return out;
-}
-
-/* Write out the function for a transition. */
-std::ostream &FFlatCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
-	int action = 0;
-	if ( trans->action != 0 )
-		action = trans->action->actListId+1;
-	out << action;
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::TO_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numToStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::FROM_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numFromStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-std::ostream &FFlatCodeGen::EOF_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numEofRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, true, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numTransRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-void FFlatCodeGen::writeData()
-{
-	if ( redFsm->anyConditions() ) {
-		OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
-		COND_KEYS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() );
-		COND_KEY_SPANS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() );
-		CONDS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() );
-		COND_INDEX_OFFSET();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
-	KEYS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() );
-	KEY_SPANS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() );
-	FLAT_INDEX_OFFSET();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
-	INDICIES();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
-	TRANS_TARGS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	if ( redFsm->anyActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() );
-		TRANS_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyToStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc),  TSA() );
-		TO_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyFromStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
-		FROM_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyEofActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() );
-		EOF_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyEofTrans() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() );
-		EOF_TRANS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	STATE_IDS();
-}
-
-void FFlatCodeGen::writeExec()
-{
-	testEofUsed = false;
-	outLabelUsed = false;
-
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#include "ragel.h" 
+#include "cdfflat.h" 
+#include "redfsm.h" 
+#include "gendata.h" 
+ 
+std::ostream &FFlatCodeGen::TO_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->toStateAction != 0 ) 
+		act = state->toStateAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+std::ostream &FFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->fromStateAction != 0 ) 
+		act = state->fromStateAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+std::ostream &FFlatCodeGen::EOF_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->eofAction != 0 ) 
+		act = state->eofAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+/* Write out the function for a transition. */ 
+std::ostream &FFlatCodeGen::TRANS_ACTION( RedTransAp *trans ) 
+{ 
+	int action = 0; 
+	if ( trans->action != 0 ) 
+		action = trans->action->actListId+1; 
+	out << action; 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FFlatCodeGen::TO_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numToStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FFlatCodeGen::FROM_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numFromStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+std::ostream &FFlatCodeGen::EOF_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numEofRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, true, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FFlatCodeGen::ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numTransRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+void FFlatCodeGen::writeData() 
+{ 
+	if ( redFsm->anyConditions() ) { 
+		OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); 
+		COND_KEYS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() ); 
+		COND_KEY_SPANS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() ); 
+		CONDS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() ); 
+		COND_INDEX_OFFSET(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); 
+	KEYS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() ); 
+	KEY_SPANS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() ); 
+	FLAT_INDEX_OFFSET(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); 
+	INDICIES(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); 
+	TRANS_TARGS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	if ( redFsm->anyActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); 
+		TRANS_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyToStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc),  TSA() ); 
+		TO_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); 
+		FROM_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyEofActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); 
+		EOF_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyEofTrans() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); 
+		EOF_TRANS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	STATE_IDS(); 
+} 
+ 
+void FFlatCodeGen::writeExec() 
+{ 
+	testEofUsed = false; 
+	outLabelUsed = false; 
+ 
+	out <<  
+		"	{\n" 
+		"	int _slen"; 
+ 
+	if ( redFsm->anyRegCurStateRef() ) 
+		out << ", _ps"; 
+	 
+	out << ";\n"; 
+	out << "	int _trans"; 
+ 
+	if ( redFsm->anyConditions() ) 
+		out << ", _cond"; 
+ 
+	out << ";\n"; 
+ 
 	out << 
 	out << 
-		"	{\n"
-		"	int _slen";
-
-	if ( redFsm->anyRegCurStateRef() )
-		out << ", _ps";
-	
-	out << ";\n";
-	out << "	int _trans";
-
-	if ( redFsm->anyConditions() )
-		out << ", _cond";
-
-	out << ";\n";
-
-	out <<
 		"	" << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n"
 		"	" << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n"
 		"	" << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n";
 		"	" << PTR_CONST() << ARRAY_TYPE(redFsm->maxIndex) << PTR_CONST_END() << POINTER() << "_inds;\n";
-
-	if ( redFsm->anyConditions() ) {
-		out << 
+ 
+	if ( redFsm->anyConditions() ) { 
+		out <<  
 			"	" << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n"
 			"	" << PTR_CONST() << ARRAY_TYPE(redFsm->maxCond) << PTR_CONST_END() << POINTER() << "_conds;\n"
-			"	" << WIDE_ALPH_TYPE() << " _widec;\n";
-	}
-
-	if ( !noEnd ) {
-		testEofUsed = true;
-		out << 
-			"	if ( " << P() << " == " << PE() << " )\n"
-			"		goto _test_eof;\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
-		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	out << "_resume:\n";
-
-	if ( redFsm->anyFromStateActions() ) {
-		out <<
-			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n";
-			FROM_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->anyConditions() )
-		COND_TRANSLATE();
-
-	LOCATE_TRANS();
-
-	if ( redFsm->anyEofTrans() )
-		out << "_eof_trans:\n";
-	
-	if ( redFsm->anyRegCurStateRef() )
-		out << "	_ps = " << vCS() << ";\n";
-
-	out << 
-		"	" << vCS() << " = " << TT() << "[_trans];\n\n";
-
-	if ( redFsm->anyRegActions() ) {
+			"	" << WIDE_ALPH_TYPE() << " _widec;\n"; 
+	} 
+ 
+	if ( !noEnd ) { 
+		testEofUsed = true; 
+		out <<  
+			"	if ( " << P() << " == " << PE() << " )\n" 
+			"		goto _test_eof;\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	out << "_resume:\n"; 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
 		out << 
 		out << 
-			"	if ( " << TA() << "[_trans] == 0 )\n"
-			"		goto _again;\n"
-			"\n"
-			"	switch ( " << TA() << "[_trans] ) {\n";
-			ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || 
-			redFsm->anyActionCalls() || redFsm->anyActionRets() )
-		out << "_again:\n";
-
-	if ( redFsm->anyToStateActions() ) {
-		out <<
-			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n";
-			TO_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
+			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n"; 
+			FROM_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->anyConditions() ) 
+		COND_TRANSLATE(); 
+ 
+	LOCATE_TRANS(); 
+ 
+	if ( redFsm->anyEofTrans() ) 
+		out << "_eof_trans:\n"; 
+	 
+	if ( redFsm->anyRegCurStateRef() ) 
+		out << "	_ps = " << vCS() << ";\n"; 
+ 
+	out <<  
+		"	" << vCS() << " = " << TT() << "[_trans];\n\n"; 
+ 
+	if ( redFsm->anyRegActions() ) { 
+		out <<  
+			"	if ( " << TA() << "[_trans] == 0 )\n" 
+			"		goto _again;\n" 
+			"\n" 
+			"	switch ( " << TA() << "[_trans] ) {\n"; 
+			ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->anyRegActions() || redFsm->anyActionGotos() ||  
+			redFsm->anyActionCalls() || redFsm->anyActionRets() ) 
+		out << "_again:\n"; 
+ 
+	if ( redFsm->anyToStateActions() ) { 
 		out << 
 		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	if ( !noEnd ) {
+			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n"; 
+			TO_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	if ( !noEnd ) { 
+		out <<  
+			"	if ( ++" << P() << " != " << PE() << " )\n" 
+			"		goto _resume;\n"; 
+	} 
+	else { 
+		out <<  
+			"	" << P() << " += 1;\n" 
+			"	goto _resume;\n"; 
+	} 
+ 
+	if ( testEofUsed ) 
+		out << "	_test_eof: {}\n"; 
+ 
+	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { 
 		out << 
 		out << 
-			"	if ( ++" << P() << " != " << PE() << " )\n"
-			"		goto _resume;\n";
-	}
-	else {
+			"	if ( " << P() << " == " << vEOF() << " )\n" 
+			"	{\n"; 
+ 
+		if ( redFsm->anyEofTrans() ) { 
+			out << 
+				"	if ( " << ET() << "[" << vCS() << "] > 0 ) {\n" 
+				"		_trans = " << ET() << "[" << vCS() << "] - 1;\n" 
+				"		goto _eof_trans;\n" 
+				"	}\n"; 
+		} 
+ 
+		if ( redFsm->anyEofActions() ) { 
+			out << 
+				"	switch ( " << EA() << "[" << vCS() << "] ) {\n"; 
+				EOF_ACTION_SWITCH(); 
+				SWITCH_DEFAULT() << 
+				"	}\n"; 
+		} 
+ 
 		out << 
 		out << 
-			"	" << P() << " += 1;\n"
-			"	goto _resume;\n";
-	}
-
-	if ( testEofUsed )
-		out << "	_test_eof: {}\n";
-
-	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
-		out <<
-			"	if ( " << P() << " == " << vEOF() << " )\n"
-			"	{\n";
-
-		if ( redFsm->anyEofTrans() ) {
-			out <<
-				"	if ( " << ET() << "[" << vCS() << "] > 0 ) {\n"
-				"		_trans = " << ET() << "[" << vCS() << "] - 1;\n"
-				"		goto _eof_trans;\n"
-				"	}\n";
-		}
-
-		if ( redFsm->anyEofActions() ) {
-			out <<
-				"	switch ( " << EA() << "[" << vCS() << "] ) {\n";
-				EOF_ACTION_SWITCH();
-				SWITCH_DEFAULT() <<
-				"	}\n";
-		}
-
-		out <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( outLabelUsed )
-		out << "	_out: {}\n";
-
-	out << "	}\n";
-}
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( outLabelUsed ) 
+		out << "	_out: {}\n"; 
+ 
+	out << "	}\n"; 
+} 

+ 74 - 74
contrib/tools/ragel6/cdfflat.h

@@ -1,77 +1,77 @@
-/*
- *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+/* 
+ *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#ifndef _CDFFLAT_H
-#define _CDFFLAT_H
-
-#include <iostream>
-#include "cdflat.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-/*
- * FFlatCodeGen
- */
-class FFlatCodeGen : public FlatCodeGen
-{
-protected:
-	FFlatCodeGen( ostream &out ) : FsmCodeGen(out), FlatCodeGen(out) {}
-
-	std::ostream &TO_STATE_ACTION_SWITCH();
-	std::ostream &FROM_STATE_ACTION_SWITCH();
-	std::ostream &EOF_ACTION_SWITCH();
-	std::ostream &ACTION_SWITCH();
-
-	virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
-	virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
-	virtual std::ostream &EOF_ACTION( RedStateAp *state );
-	virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
-
-	virtual void writeData();
-	virtual void writeExec();
-};
-
-/*
- * CFFlatCodeGen
- */
-struct CFFlatCodeGen
-	: public FFlatCodeGen, public CCodeGen
-{
-	CFFlatCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FFlatCodeGen(out), CCodeGen(out) {}
-};
-
-/*
- * DFFlatCodeGen
- */
-struct DFFlatCodeGen
-	: public FFlatCodeGen, public DCodeGen
-{
-	DFFlatCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FFlatCodeGen(out), DCodeGen(out) {}
-};
-
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#ifndef _CDFFLAT_H 
+#define _CDFFLAT_H 
+ 
+#include <iostream> 
+#include "cdflat.h" 
+ 
+/* Forwards. */ 
+struct CodeGenData; 
+ 
+/* 
+ * FFlatCodeGen 
+ */ 
+class FFlatCodeGen : public FlatCodeGen 
+{ 
+protected: 
+	FFlatCodeGen( ostream &out ) : FsmCodeGen(out), FlatCodeGen(out) {} 
+ 
+	std::ostream &TO_STATE_ACTION_SWITCH(); 
+	std::ostream &FROM_STATE_ACTION_SWITCH(); 
+	std::ostream &EOF_ACTION_SWITCH(); 
+	std::ostream &ACTION_SWITCH(); 
+ 
+	virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); 
+	virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); 
+	virtual std::ostream &EOF_ACTION( RedStateAp *state ); 
+	virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); 
+ 
+	virtual void writeData(); 
+	virtual void writeExec(); 
+}; 
+ 
+/* 
+ * CFFlatCodeGen 
+ */ 
+struct CFFlatCodeGen 
+	: public FFlatCodeGen, public CCodeGen 
+{ 
+	CFFlatCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FFlatCodeGen(out), CCodeGen(out) {} 
+}; 
+ 
+/* 
+ * DFFlatCodeGen 
+ */ 
+struct DFFlatCodeGen 
+	: public FFlatCodeGen, public DCodeGen 
+{ 
+	DFFlatCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FFlatCodeGen(out), DCodeGen(out) {} 
+}; 
+ 
 /*
 /*
  * D2FFlatCodeGen
  * D2FFlatCodeGen
  */
  */
@@ -82,4 +82,4 @@ struct D2FFlatCodeGen
 		FsmCodeGen(out), FFlatCodeGen(out), D2CodeGen(out) {}
 		FsmCodeGen(out), FFlatCodeGen(out), D2CodeGen(out) {}
 };
 };
 
 
-#endif
+#endif 

+ 291 - 291
contrib/tools/ragel6/cdfgoto.cpp

@@ -1,296 +1,296 @@
-/*
- *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+/* 
+ *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#include "ragel.h"
-#include "cdfgoto.h"
-#include "redfsm.h"
-#include "gendata.h"
-#include "bstmap.h"
-
-std::ostream &FGotoCodeGen::EXEC_ACTIONS()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numTransRefs > 0 ) {
-			/* 	We are at the start of a glob, write the case. */
-			out << "f" << redAct->actListId << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tgoto _again;\n";
-		}
-	}
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FGotoCodeGen::TO_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numToStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FGotoCodeGen::FROM_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numFromStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-std::ostream &FGotoCodeGen::EOF_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numEofRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, true, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-
-std::ostream &FGotoCodeGen::FINISH_CASES()
-{
-	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
-		/* States that are final and have an out action need a case. */
-		if ( st->eofAction != 0 ) {
-			/* Write the case label. */
-			out << "\t\tcase " << st->id << ": ";
-
-			/* Jump to the func. */
-			out << "goto f" << st->eofAction->actListId << ";\n";
-		}
-	}
-
-	return out;
-}
-
-unsigned int FGotoCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->toStateAction != 0 )
-		act = state->toStateAction->actListId+1;
-	return act;
-}
-
-unsigned int FGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->fromStateAction != 0 )
-		act = state->fromStateAction->actListId+1;
-	return act;
-}
-
-unsigned int FGotoCodeGen::EOF_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->eofAction != 0 )
-		act = state->eofAction->actListId+1;
-	return act;
-}
-
-void FGotoCodeGen::writeData()
-{
-	if ( redFsm->anyToStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
-		TO_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyFromStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
-		FROM_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyEofActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() );
-		EOF_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	STATE_IDS();
-}
-
-void FGotoCodeGen::writeExec()
-{
-	testEofUsed = false;
-	outLabelUsed = false;
-
-	out << "	{\n";
-
-	if ( redFsm->anyRegCurStateRef() )
-		out << "	int _ps = 0;\n";
-
-	if ( redFsm->anyConditions() )
-		out << "	" << WIDE_ALPH_TYPE() << " _widec;\n";
-
-	if ( !noEnd ) {
-		testEofUsed = true;
-		out << 
-			"	if ( " << P() << " == " << PE() << " )\n"
-			"		goto _test_eof;\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#include "ragel.h" 
+#include "cdfgoto.h" 
+#include "redfsm.h" 
+#include "gendata.h" 
+#include "bstmap.h" 
+ 
+std::ostream &FGotoCodeGen::EXEC_ACTIONS() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numTransRefs > 0 ) { 
+			/* 	We are at the start of a glob, write the case. */ 
+			out << "f" << redAct->actListId << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tgoto _again;\n"; 
+		} 
+	} 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FGotoCodeGen::TO_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numToStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FGotoCodeGen::FROM_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numFromStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+std::ostream &FGotoCodeGen::EOF_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numEofRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, true, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+ 
+std::ostream &FGotoCodeGen::FINISH_CASES() 
+{ 
+	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { 
+		/* States that are final and have an out action need a case. */ 
+		if ( st->eofAction != 0 ) { 
+			/* Write the case label. */ 
+			out << "\t\tcase " << st->id << ": "; 
+ 
+			/* Jump to the func. */ 
+			out << "goto f" << st->eofAction->actListId << ";\n"; 
+		} 
+	} 
+ 
+	return out; 
+} 
+ 
+unsigned int FGotoCodeGen::TO_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->toStateAction != 0 ) 
+		act = state->toStateAction->actListId+1; 
+	return act; 
+} 
+ 
+unsigned int FGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->fromStateAction != 0 ) 
+		act = state->fromStateAction->actListId+1; 
+	return act; 
+} 
+ 
+unsigned int FGotoCodeGen::EOF_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->eofAction != 0 ) 
+		act = state->eofAction->actListId+1; 
+	return act; 
+} 
+ 
+void FGotoCodeGen::writeData() 
+{ 
+	if ( redFsm->anyToStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); 
+		TO_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); 
+		FROM_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyEofActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); 
+		EOF_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	STATE_IDS(); 
+} 
+ 
+void FGotoCodeGen::writeExec() 
+{ 
+	testEofUsed = false; 
+	outLabelUsed = false; 
+ 
+	out << "	{\n"; 
+ 
+	if ( redFsm->anyRegCurStateRef() ) 
+		out << "	int _ps = 0;\n"; 
+ 
+	if ( redFsm->anyConditions() ) 
+		out << "	" << WIDE_ALPH_TYPE() << " _widec;\n"; 
+ 
+	if ( !noEnd ) { 
+		testEofUsed = true; 
+		out <<  
+			"	if ( " << P() << " == " << PE() << " )\n" 
+			"		goto _test_eof;\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	out << "_resume:\n"; 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
 		out << 
 		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	out << "_resume:\n";
-
-	if ( redFsm->anyFromStateActions() ) {
-		out <<
-			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n";
-			FROM_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	out << 
-		"	switch ( " << vCS() << " ) {\n";
-		STATE_GOTOS();
-		SWITCH_DEFAULT() <<
-		"	}\n"
-		"\n";
-		TRANSITIONS() << 
-		"\n";
-
-	if ( redFsm->anyRegActions() )
-		EXEC_ACTIONS() << "\n";
-
-	out << "_again:\n";
-
-	if ( redFsm->anyToStateActions() ) {
-		out <<
-			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n";
-			TO_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
+			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n"; 
+			FROM_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	out <<  
+		"	switch ( " << vCS() << " ) {\n"; 
+		STATE_GOTOS(); 
+		SWITCH_DEFAULT() << 
+		"	}\n" 
+		"\n"; 
+		TRANSITIONS() <<  
+		"\n"; 
+ 
+	if ( redFsm->anyRegActions() ) 
+		EXEC_ACTIONS() << "\n"; 
+ 
+	out << "_again:\n"; 
+ 
+	if ( redFsm->anyToStateActions() ) { 
 		out << 
 		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	if ( !noEnd ) {
+			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n"; 
+			TO_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	if ( !noEnd ) { 
+		out <<  
+			"	if ( ++" << P() << " != " << PE() << " )\n" 
+			"		goto _resume;\n"; 
+	} 
+	else { 
+		out <<  
+			"	" << P() << " += 1;\n" 
+			"	goto _resume;\n"; 
+	} 
+ 
+	if ( testEofUsed ) 
+		out << "	_test_eof: {}\n"; 
+ 
+	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { 
 		out << 
 		out << 
-			"	if ( ++" << P() << " != " << PE() << " )\n"
-			"		goto _resume;\n";
-	}
-	else {
+			"	if ( " << P() << " == " << vEOF() << " )\n" 
+			"	{\n"; 
+ 
+		if ( redFsm->anyEofTrans() ) { 
+			out << 
+				"	switch ( " << vCS() << " ) {\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"; 
+		} 
+ 
+		if ( redFsm->anyEofActions() ) { 
+			out << 
+				"	switch ( " << EA() << "[" << vCS() << "] ) {\n"; 
+				EOF_ACTION_SWITCH(); 
+				SWITCH_DEFAULT() << 
+				"	}\n"; 
+		} 
+ 
 		out << 
 		out << 
-			"	" << P() << " += 1;\n"
-			"	goto _resume;\n";
-	}
-
-	if ( testEofUsed )
-		out << "	_test_eof: {}\n";
-
-	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
-		out <<
-			"	if ( " << P() << " == " << vEOF() << " )\n"
-			"	{\n";
-
-		if ( redFsm->anyEofTrans() ) {
-			out <<
-				"	switch ( " << vCS() << " ) {\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";
-		}
-
-		if ( redFsm->anyEofActions() ) {
-			out <<
-				"	switch ( " << EA() << "[" << vCS() << "] ) {\n";
-				EOF_ACTION_SWITCH();
-				SWITCH_DEFAULT() <<
-				"	}\n";
-		}
-
-		out <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( outLabelUsed )
-		out << "	_out: {}\n";
-
-	out << "	}\n";
-}
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( outLabelUsed ) 
+		out << "	_out: {}\n"; 
+ 
+	out << "	}\n"; 
+} 

+ 74 - 74
contrib/tools/ragel6/cdfgoto.h

@@ -1,77 +1,77 @@
-/*
- *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+/* 
+ *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#ifndef _CDFGOTO_H
-#define _CDFGOTO_H
-
-#include <iostream>
-#include "cdgoto.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-
-/*
- * class FGotoCodeGen
- */
-class FGotoCodeGen : public GotoCodeGen
-{
-public:
-	FGotoCodeGen( ostream &out ) : FsmCodeGen(out), GotoCodeGen(out) {}
-
-	std::ostream &EXEC_ACTIONS();
-	std::ostream &TO_STATE_ACTION_SWITCH();
-	std::ostream &FROM_STATE_ACTION_SWITCH();
-	std::ostream &FINISH_CASES();
-	std::ostream &EOF_ACTION_SWITCH();
-	unsigned int TO_STATE_ACTION( RedStateAp *state );
-	unsigned int FROM_STATE_ACTION( RedStateAp *state );
-	unsigned int EOF_ACTION( RedStateAp *state );
-
-	virtual void writeData();
-	virtual void writeExec();
-};
-
-/*
- * class CFGotoCodeGen
- */
-struct CFGotoCodeGen
-	: public FGotoCodeGen, public CCodeGen
-{
-	CFGotoCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FGotoCodeGen(out), CCodeGen(out) {}
-};
-
-/*
- * class DFGotoCodeGen
- */
-struct DFGotoCodeGen
-	: public FGotoCodeGen, public DCodeGen
-{
-	DFGotoCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FGotoCodeGen(out), DCodeGen(out) {}
-};
-
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#ifndef _CDFGOTO_H 
+#define _CDFGOTO_H 
+ 
+#include <iostream> 
+#include "cdgoto.h" 
+ 
+/* Forwards. */ 
+struct CodeGenData; 
+ 
+ 
+/* 
+ * class FGotoCodeGen 
+ */ 
+class FGotoCodeGen : public GotoCodeGen 
+{ 
+public: 
+	FGotoCodeGen( ostream &out ) : FsmCodeGen(out), GotoCodeGen(out) {} 
+ 
+	std::ostream &EXEC_ACTIONS(); 
+	std::ostream &TO_STATE_ACTION_SWITCH(); 
+	std::ostream &FROM_STATE_ACTION_SWITCH(); 
+	std::ostream &FINISH_CASES(); 
+	std::ostream &EOF_ACTION_SWITCH(); 
+	unsigned int TO_STATE_ACTION( RedStateAp *state ); 
+	unsigned int FROM_STATE_ACTION( RedStateAp *state ); 
+	unsigned int EOF_ACTION( RedStateAp *state ); 
+ 
+	virtual void writeData(); 
+	virtual void writeExec(); 
+}; 
+ 
+/* 
+ * class CFGotoCodeGen 
+ */ 
+struct CFGotoCodeGen 
+	: public FGotoCodeGen, public CCodeGen 
+{ 
+	CFGotoCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FGotoCodeGen(out), CCodeGen(out) {} 
+}; 
+ 
+/* 
+ * class DFGotoCodeGen 
+ */ 
+struct DFGotoCodeGen 
+	: public FGotoCodeGen, public DCodeGen 
+{ 
+	DFGotoCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FGotoCodeGen(out), DCodeGen(out) {} 
+}; 
+ 
 /*
 /*
  * class DFGotoCodeGen
  * class DFGotoCodeGen
  */
  */
@@ -82,4 +82,4 @@ struct D2FGotoCodeGen
 		FsmCodeGen(out), FGotoCodeGen(out), D2CodeGen(out) {}
 		FsmCodeGen(out), FGotoCodeGen(out), D2CodeGen(out) {}
 };
 };
 
 
-#endif
+#endif 

Разница между файлами не показана из-за своего большого размера
+ 492 - 492
contrib/tools/ragel6/cdflat.cpp


+ 107 - 107
contrib/tools/ragel6/cdflat.h

@@ -1,110 +1,110 @@
-/*
- *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+/* 
+ *  Copyright 2004-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#ifndef _CDFLAT_H
-#define _CDFLAT_H
-
-#include <iostream>
-#include "cdcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-struct NameInst;
-struct RedTransAp;
-struct RedStateAp;
-
-/*
- * FlatCodeGen
- */
-class FlatCodeGen : virtual public FsmCodeGen
-{
-public:
-	FlatCodeGen( ostream &out ) : FsmCodeGen(out) {}
-	virtual ~FlatCodeGen() { }
-
-protected:
-	std::ostream &TO_STATE_ACTION_SWITCH();
-	std::ostream &FROM_STATE_ACTION_SWITCH();
-	std::ostream &EOF_ACTION_SWITCH();
-	std::ostream &ACTION_SWITCH();
-	std::ostream &KEYS();
-	std::ostream &INDICIES();
-	std::ostream &FLAT_INDEX_OFFSET();
-	std::ostream &KEY_SPANS();
-	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();
-
-	std::ostream &COND_INDEX_OFFSET();
-	void COND_TRANSLATE();
-	std::ostream &CONDS();
-	std::ostream &COND_KEYS();
-	std::ostream &COND_KEY_SPANS();
-
-	void GOTO( ostream &ret, int gotoDest, bool inFinish );
-	void CALL( ostream &ret, int callDest, int targState, bool inFinish );
-	void NEXT( ostream &ret, int nextDest, bool inFinish );
-	void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
-	void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
-	void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
-	void CURS( ostream &ret, bool inFinish );
-	void TARGS( ostream &ret, bool inFinish, int targState );
-	void RET( ostream &ret, bool inFinish );
-	void BREAK( ostream &ret, int targState, bool csForced );
-
-	virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
-	virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
-	virtual std::ostream &EOF_ACTION( RedStateAp *state );
-	virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
-
-	virtual void writeData();
-	virtual void writeExec();
-};
-
-/*
- * CFlatCodeGen
- */
-struct CFlatCodeGen
-	: public FlatCodeGen, public CCodeGen
-{
-	CFlatCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FlatCodeGen(out), CCodeGen(out) {}
-};
-
-/*
- * DFlatCodeGen
- */
-struct DFlatCodeGen
-	: public FlatCodeGen, public DCodeGen
-{
-	DFlatCodeGen( ostream &out ) : 
-		FsmCodeGen(out), FlatCodeGen(out), DCodeGen(out) {}
-};
-
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#ifndef _CDFLAT_H 
+#define _CDFLAT_H 
+ 
+#include <iostream> 
+#include "cdcodegen.h" 
+ 
+/* Forwards. */ 
+struct CodeGenData; 
+struct NameInst; 
+struct RedTransAp; 
+struct RedStateAp; 
+ 
+/* 
+ * FlatCodeGen 
+ */ 
+class FlatCodeGen : virtual public FsmCodeGen 
+{ 
+public: 
+	FlatCodeGen( ostream &out ) : FsmCodeGen(out) {} 
+	virtual ~FlatCodeGen() { } 
+ 
+protected: 
+	std::ostream &TO_STATE_ACTION_SWITCH(); 
+	std::ostream &FROM_STATE_ACTION_SWITCH(); 
+	std::ostream &EOF_ACTION_SWITCH(); 
+	std::ostream &ACTION_SWITCH(); 
+	std::ostream &KEYS(); 
+	std::ostream &INDICIES(); 
+	std::ostream &FLAT_INDEX_OFFSET(); 
+	std::ostream &KEY_SPANS(); 
+	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(); 
+ 
+	std::ostream &COND_INDEX_OFFSET(); 
+	void COND_TRANSLATE(); 
+	std::ostream &CONDS(); 
+	std::ostream &COND_KEYS(); 
+	std::ostream &COND_KEY_SPANS(); 
+ 
+	void GOTO( ostream &ret, int gotoDest, bool inFinish ); 
+	void CALL( ostream &ret, int callDest, int targState, bool inFinish ); 
+	void NEXT( ostream &ret, int nextDest, bool inFinish ); 
+	void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); 
+	void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); 
+	void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); 
+	void CURS( ostream &ret, bool inFinish ); 
+	void TARGS( ostream &ret, bool inFinish, int targState ); 
+	void RET( ostream &ret, bool inFinish ); 
+	void BREAK( ostream &ret, int targState, bool csForced ); 
+ 
+	virtual std::ostream &TO_STATE_ACTION( RedStateAp *state ); 
+	virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state ); 
+	virtual std::ostream &EOF_ACTION( RedStateAp *state ); 
+	virtual std::ostream &TRANS_ACTION( RedTransAp *trans ); 
+ 
+	virtual void writeData(); 
+	virtual void writeExec(); 
+}; 
+ 
+/* 
+ * CFlatCodeGen 
+ */ 
+struct CFlatCodeGen 
+	: public FlatCodeGen, public CCodeGen 
+{ 
+	CFlatCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FlatCodeGen(out), CCodeGen(out) {} 
+}; 
+ 
+/* 
+ * DFlatCodeGen 
+ */ 
+struct DFlatCodeGen 
+	: public FlatCodeGen, public DCodeGen 
+{ 
+	DFlatCodeGen( ostream &out ) :  
+		FsmCodeGen(out), FlatCodeGen(out), DCodeGen(out) {} 
+}; 
+ 
 /*
 /*
  * D2FlatCodeGen
  * D2FlatCodeGen
  */
  */
@@ -115,4 +115,4 @@ struct D2FlatCodeGen
 		FsmCodeGen(out), FlatCodeGen(out), D2CodeGen(out) {}
 		FsmCodeGen(out), FlatCodeGen(out), D2CodeGen(out) {}
 };
 };
 
 
-#endif
+#endif 

+ 429 - 429
contrib/tools/ragel6/cdftable.cpp

@@ -1,436 +1,436 @@
-/*
- *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
- *            2004 Erich Ocean <eric.ocean@ampede.com>
- *            2005 Alan West <alan@alanz.com>
- */
-
-/*  This file is part of Ragel.
- *
- *  Ragel is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+/* 
+ *  Copyright 2001-2006 Adrian Thurston <thurston@complang.org> 
+ *            2004 Erich Ocean <eric.ocean@ampede.com> 
+ *            2005 Alan West <alan@alanz.com> 
+ */ 
+ 
+/*  This file is part of Ragel. 
  * 
  * 
- *  Ragel is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- * 
- *  You should have received a copy of the GNU General Public License
- *  along with Ragel; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-
-#include "ragel.h"
-#include "cdftable.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-/* Determine if we should use indicies or not. */
-void FTabCodeGen::calcIndexSize()
-{
-	int sizeWithInds = 0, sizeWithoutInds = 0;
-
-	/* Calculate cost of using with indicies. */
-	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
-		int totalIndex = st->outSingle.length() + st->outRange.length() + 
-				(st->defTrans == 0 ? 0 : 1);
-		sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex;
-	}
-	sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length();
-	if ( redFsm->anyActions() )
-		sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length();
-
-	/* Calculate the cost of not using indicies. */
-	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
-		int totalIndex = st->outSingle.length() + st->outRange.length() + 
-				(st->defTrans == 0 ? 0 : 1);
-		sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex;
-		if ( redFsm->anyActions() )
-			sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex;
-	}
-
-	/* If using indicies reduces the size, use them. */
-	useIndicies = sizeWithInds < sizeWithoutInds;
-}
-
-std::ostream &FTabCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->toStateAction != 0 )
-		act = state->toStateAction->actListId+1;
-	out << act;
-	return out;
-}
-
-std::ostream &FTabCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->fromStateAction != 0 )
-		act = state->fromStateAction->actListId+1;
-	out << act;
-	return out;
-}
-
-std::ostream &FTabCodeGen::EOF_ACTION( RedStateAp *state )
-{
-	int act = 0;
-	if ( state->eofAction != 0 )
-		act = state->eofAction->actListId+1;
-	out << act;
-	return out;
-}
-
-
-/* Write out the function for a transition. */
-std::ostream &FTabCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
-	int action = 0;
-	if ( trans->action != 0 )
-		action = trans->action->actListId+1;
-	out << action;
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::TO_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numToStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::FROM_STATE_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numFromStateRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-std::ostream &FTabCodeGen::EOF_ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numEofRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, true, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::ACTION_SWITCH()
-{
-	/* Loop the actions. */
-	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
-		if ( redAct->numTransRefs > 0 ) {
-			/* Write the entry label. */
-			out << "\tcase " << redAct->actListId+1 << ":\n";
-
-			/* Write each action in the list of action items. */
-			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
-				ACTION( out, item->value, 0, false, false );
-
-			out << "\tbreak;\n";
-		}
-	}
-
-	genLineDirective( out );
-	return out;
-}
-
-void FTabCodeGen::writeData()
-{
-	if ( redFsm->anyConditions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() );
-		COND_OFFSETS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() );
-		COND_LENS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
-		COND_KEYS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() );
-		COND_SPACES();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() );
-	KEY_OFFSETS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
-	KEYS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() );
-	SINGLE_LENS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() );
-	RANGE_LENS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() );
-	INDEX_OFFSETS();
-	CLOSE_ARRAY() <<
-	"\n";
-
-	if ( useIndicies ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
-		INDICIES();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
-		TRANS_TARGS_WI();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		if ( redFsm->anyActions() ) {
-			OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() );
-			TRANS_ACTIONS_WI();
-			CLOSE_ARRAY() <<
-			"\n";
-		}
-	}
-	else {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
-		TRANS_TARGS();
-		CLOSE_ARRAY() <<
-		"\n";
-
-		if ( redFsm->anyActions() ) {
-			OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() );
-			TRANS_ACTIONS();
-			CLOSE_ARRAY() <<
-			"\n";
-		}
-	}
-
-	if ( redFsm->anyToStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
-		TO_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyFromStateActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
-		FROM_STATE_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyEofActions() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() );
-		EOF_ACTIONS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	if ( redFsm->anyEofTrans() ) {
-		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() );
-		EOF_TRANS();
-		CLOSE_ARRAY() <<
-		"\n";
-	}
-
-	STATE_IDS();
-}
-
-void FTabCodeGen::writeExec()
-{
-	testEofUsed = false;
-	outLabelUsed = false;
-
+ *  Ragel is free software; you can redistribute it and/or modify 
+ *  it under the terms of the GNU General Public License as published by 
+ *  the Free Software Foundation; either version 2 of the License, or 
+ *  (at your option) any later version. 
+ *  
+ *  Ragel is distributed in the hope that it will be useful, 
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *  GNU General Public License for more details. 
+ *  
+ *  You should have received a copy of the GNU General Public License 
+ *  along with Ragel; if not, write to the Free Software 
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
+ */ 
+ 
+#include "ragel.h" 
+#include "cdftable.h" 
+#include "redfsm.h" 
+#include "gendata.h" 
+ 
+/* Determine if we should use indicies or not. */ 
+void FTabCodeGen::calcIndexSize() 
+{ 
+	int sizeWithInds = 0, sizeWithoutInds = 0; 
+ 
+	/* Calculate cost of using with indicies. */ 
+	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { 
+		int totalIndex = st->outSingle.length() + st->outRange.length() +  
+				(st->defTrans == 0 ? 0 : 1); 
+		sizeWithInds += arrayTypeSize(redFsm->maxIndex) * totalIndex; 
+	} 
+	sizeWithInds += arrayTypeSize(redFsm->maxState) * redFsm->transSet.length(); 
+	if ( redFsm->anyActions() ) 
+		sizeWithInds += arrayTypeSize(redFsm->maxActListId) * redFsm->transSet.length(); 
+ 
+	/* Calculate the cost of not using indicies. */ 
+	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) { 
+		int totalIndex = st->outSingle.length() + st->outRange.length() +  
+				(st->defTrans == 0 ? 0 : 1); 
+		sizeWithoutInds += arrayTypeSize(redFsm->maxState) * totalIndex; 
+		if ( redFsm->anyActions() ) 
+			sizeWithoutInds += arrayTypeSize(redFsm->maxActListId) * totalIndex; 
+	} 
+ 
+	/* If using indicies reduces the size, use them. */ 
+	useIndicies = sizeWithInds < sizeWithoutInds; 
+} 
+ 
+std::ostream &FTabCodeGen::TO_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->toStateAction != 0 ) 
+		act = state->toStateAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+std::ostream &FTabCodeGen::FROM_STATE_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->fromStateAction != 0 ) 
+		act = state->fromStateAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+std::ostream &FTabCodeGen::EOF_ACTION( RedStateAp *state ) 
+{ 
+	int act = 0; 
+	if ( state->eofAction != 0 ) 
+		act = state->eofAction->actListId+1; 
+	out << act; 
+	return out; 
+} 
+ 
+ 
+/* Write out the function for a transition. */ 
+std::ostream &FTabCodeGen::TRANS_ACTION( RedTransAp *trans ) 
+{ 
+	int action = 0; 
+	if ( trans->action != 0 ) 
+		action = trans->action->actListId+1; 
+	out << action; 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FTabCodeGen::TO_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numToStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FTabCodeGen::FROM_STATE_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numFromStateRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+std::ostream &FTabCodeGen::EOF_ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numEofRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, true, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+/* Write out the function switch. This switch is keyed on the values 
+ * of the func index. */ 
+std::ostream &FTabCodeGen::ACTION_SWITCH() 
+{ 
+	/* Loop the actions. */ 
+	for ( GenActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) { 
+		if ( redAct->numTransRefs > 0 ) { 
+			/* Write the entry label. */ 
+			out << "\tcase " << redAct->actListId+1 << ":\n"; 
+ 
+			/* Write each action in the list of action items. */ 
+			for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ ) 
+				ACTION( out, item->value, 0, false, false ); 
+ 
+			out << "\tbreak;\n"; 
+		} 
+	} 
+ 
+	genLineDirective( out ); 
+	return out; 
+} 
+ 
+void FTabCodeGen::writeData() 
+{ 
+	if ( redFsm->anyConditions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() ); 
+		COND_OFFSETS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() ); 
+		COND_LENS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() ); 
+		COND_KEYS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() ); 
+		COND_SPACES(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() ); 
+	KEY_OFFSETS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( WIDE_ALPH_TYPE(), K() ); 
+	KEYS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() ); 
+	SINGLE_LENS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() ); 
+	RANGE_LENS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() ); 
+	INDEX_OFFSETS(); 
+	CLOSE_ARRAY() << 
+	"\n"; 
+ 
+	if ( useIndicies ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() ); 
+		INDICIES(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); 
+		TRANS_TARGS_WI(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		if ( redFsm->anyActions() ) { 
+			OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); 
+			TRANS_ACTIONS_WI(); 
+			CLOSE_ARRAY() << 
+			"\n"; 
+		} 
+	} 
+	else { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() ); 
+		TRANS_TARGS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+ 
+		if ( redFsm->anyActions() ) { 
+			OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() ); 
+			TRANS_ACTIONS(); 
+			CLOSE_ARRAY() << 
+			"\n"; 
+		} 
+	} 
+ 
+	if ( redFsm->anyToStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() ); 
+		TO_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() ); 
+		FROM_STATE_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyEofActions() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() ); 
+		EOF_ACTIONS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	if ( redFsm->anyEofTrans() ) { 
+		OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); 
+		EOF_TRANS(); 
+		CLOSE_ARRAY() << 
+		"\n"; 
+	} 
+ 
+	STATE_IDS(); 
+} 
+ 
+void FTabCodeGen::writeExec() 
+{ 
+	testEofUsed = false; 
+	outLabelUsed = false; 
+ 
+	out <<  
+		"	{\n" 
+		"	int _klen"; 
+ 
+	if ( redFsm->anyRegCurStateRef() ) 
+		out << ", _ps"; 
+ 
 	out << 
 	out << 
-		"	{\n"
-		"	int _klen";
-
-	if ( redFsm->anyRegCurStateRef() )
-		out << ", _ps";
-
-	out <<
-		";\n"
+		";\n" 
 		"	" << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n"
 		"	" << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_keys;\n"
-		"	int _trans;\n";
-
-	if ( redFsm->anyConditions() )
-		out << "	" << WIDE_ALPH_TYPE() << " _widec;\n";
-
-	out << "\n";
-
-	if ( !noEnd ) {
-		testEofUsed = true;
-		out <<
-			"	if ( " << P() << " == " << PE() << " )\n"
-			"		goto _test_eof;\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
-		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	out << "_resume:\n";
-
-	if ( redFsm->anyFromStateActions() ) {
-		out <<
-			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n";
-			FROM_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->anyConditions() )
-		COND_TRANSLATE();
-
-	LOCATE_TRANS();
-
-	out << "_match:\n";
-
-	if ( useIndicies )
-		out << "	_trans = " << I() << "[_trans];\n";
-
-	if ( redFsm->anyEofTrans() )
-		out << "_eof_trans:\n";
-
-	if ( redFsm->anyRegCurStateRef() )
-		out << "	_ps = " << vCS() << ";\n";
-
-	out <<
-		"	" << vCS() << " = " << TT() << "[_trans];\n"
-		"\n";
-
-	if ( redFsm->anyRegActions() ) {
+		"	int _trans;\n"; 
+ 
+	if ( redFsm->anyConditions() ) 
+		out << "	" << WIDE_ALPH_TYPE() << " _widec;\n"; 
+ 
+	out << "\n"; 
+ 
+	if ( !noEnd ) { 
+		testEofUsed = true; 
 		out << 
 		out << 
-			"	if ( " << TA() << "[_trans] == 0 )\n"
-			"		goto _again;\n"
-			"\n"
-			"	switch ( " << TA() << "[_trans] ) {\n";
-			ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->anyRegActions() || redFsm->anyActionGotos() || 
-			redFsm->anyActionCalls() || redFsm->anyActionRets() )
-		out << "_again:\n";
-
-	if ( redFsm->anyToStateActions() ) {
-		out <<
-			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n";
-			TO_STATE_ACTION_SWITCH();
-			SWITCH_DEFAULT() <<
-			"	}\n"
-			"\n";
-	}
-
-	if ( redFsm->errState != 0 ) {
-		outLabelUsed = true;
+			"	if ( " << P() << " == " << PE() << " )\n" 
+			"		goto _test_eof;\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	out << "_resume:\n"; 
+ 
+	if ( redFsm->anyFromStateActions() ) { 
 		out << 
 		out << 
-			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n"
-			"		goto _out;\n";
-	}
-
-	if ( !noEnd ) {
-		out << 
-			"	if ( ++" << P() << " != " << PE() << " )\n"
-			"		goto _resume;\n";
-	}
-	else {
+			"	switch ( " << FSA() << "[" << vCS() << "] ) {\n"; 
+			FROM_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->anyConditions() ) 
+		COND_TRANSLATE(); 
+ 
+	LOCATE_TRANS(); 
+ 
+	out << "_match:\n"; 
+ 
+	if ( useIndicies ) 
+		out << "	_trans = " << I() << "[_trans];\n"; 
+ 
+	if ( redFsm->anyEofTrans() ) 
+		out << "_eof_trans:\n"; 
+ 
+	if ( redFsm->anyRegCurStateRef() ) 
+		out << "	_ps = " << vCS() << ";\n"; 
+ 
+	out << 
+		"	" << vCS() << " = " << TT() << "[_trans];\n" 
+		"\n"; 
+ 
+	if ( redFsm->anyRegActions() ) { 
+		out <<  
+			"	if ( " << TA() << "[_trans] == 0 )\n" 
+			"		goto _again;\n" 
+			"\n" 
+			"	switch ( " << TA() << "[_trans] ) {\n"; 
+			ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->anyRegActions() || redFsm->anyActionGotos() ||  
+			redFsm->anyActionCalls() || redFsm->anyActionRets() ) 
+		out << "_again:\n"; 
+ 
+	if ( redFsm->anyToStateActions() ) { 
 		out << 
 		out << 
-			"	" << P() << " += 1;\n"
-			"	goto _resume;\n";
-	}
-
-	if ( testEofUsed )
-		out << "	_test_eof: {}\n";
-
-	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) {
-		out <<
-			"	if ( " << P() << " == " << vEOF() << " )\n"
-			"	{\n";
-
-		if ( redFsm->anyEofTrans() ) {
-			out <<
-				"	if ( " << ET() << "[" << vCS() << "] > 0 ) {\n"
-				"		_trans = " << ET() << "[" << vCS() << "] - 1;\n"
-				"		goto _eof_trans;\n"
-				"	}\n";
-		}
-
-		if ( redFsm->anyEofActions() ) {
-			out <<
-				"	switch ( " << EA() << "[" << vCS() << "] ) {\n";
-				EOF_ACTION_SWITCH();
-				SWITCH_DEFAULT() <<
-				"	}\n";
-		}
-
+			"	switch ( " << TSA() << "[" << vCS() << "] ) {\n"; 
+			TO_STATE_ACTION_SWITCH(); 
+			SWITCH_DEFAULT() << 
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( redFsm->errState != 0 ) { 
+		outLabelUsed = true; 
+		out <<  
+			"	if ( " << vCS() << " == " << redFsm->errState->id << " )\n" 
+			"		goto _out;\n"; 
+	} 
+ 
+	if ( !noEnd ) { 
+		out <<  
+			"	if ( ++" << P() << " != " << PE() << " )\n" 
+			"		goto _resume;\n"; 
+	} 
+	else { 
+		out <<  
+			"	" << P() << " += 1;\n" 
+			"	goto _resume;\n"; 
+	} 
+ 
+	if ( testEofUsed ) 
+		out << "	_test_eof: {}\n"; 
+ 
+	if ( redFsm->anyEofTrans() || redFsm->anyEofActions() ) { 
 		out << 
 		out << 
-			"	}\n"
-			"\n";
-	}
-
-	if ( outLabelUsed )
-		out << "	_out: {}\n";
-
-	out << "	}\n";
-}
+			"	if ( " << P() << " == " << vEOF() << " )\n" 
+			"	{\n"; 
+ 
+		if ( redFsm->anyEofTrans() ) { 
+			out << 
+				"	if ( " << ET() << "[" << vCS() << "] > 0 ) {\n" 
+				"		_trans = " << ET() << "[" << vCS() << "] - 1;\n" 
+				"		goto _eof_trans;\n" 
+				"	}\n"; 
+		} 
+ 
+		if ( redFsm->anyEofActions() ) { 
+			out << 
+				"	switch ( " << EA() << "[" << vCS() << "] ) {\n"; 
+				EOF_ACTION_SWITCH(); 
+				SWITCH_DEFAULT() << 
+				"	}\n"; 
+		} 
+ 
+		out <<  
+			"	}\n" 
+			"\n"; 
+	} 
+ 
+	if ( outLabelUsed ) 
+		out << "	_out: {}\n"; 
+ 
+	out << "	}\n"; 
+} 

Некоторые файлы не были показаны из-за большого количества измененных файлов