Initialize Tizen 2.3
[external/ragel.git] / ragel / rbxgoto.h
1 /*
2  *  Copyright 2007 Victor Hugo Borja <vic@rubyforge.org>
3  *            2006-2007 Adrian Thurston <thurston@complang.org>
4  */
5
6 /*  This file is part of Ragel.
7  *
8  *  Ragel is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  * 
13  *  Ragel is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  * 
18  *  You should have received a copy of the GNU General Public License
19  *  along with Ragel; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
21  */
22
23 #ifndef _RBX_GOTOCODEGEN_H
24 #define _RBX_GOTOCODEGEN_H
25
26 #include <iostream>
27 #include <string>
28 #include "rubycodegen.h"
29
30 using std::string;
31
32 class RbxGotoCodeGen : public RubyCodeGen
33 {
34 public:
35         RbxGotoCodeGen( ostream &out ) : RubyCodeGen(out) {}
36         virtual ~RbxGotoCodeGen() {}
37
38         std::ostream &TO_STATE_ACTION_SWITCH();
39         std::ostream &FROM_STATE_ACTION_SWITCH();
40         std::ostream &EOF_ACTION_SWITCH();
41         std::ostream &ACTION_SWITCH();
42         std::ostream &STATE_GOTOS();
43         std::ostream &TRANSITIONS();
44         std::ostream &EXEC_FUNCS();
45         std::ostream &FINISH_CASES();
46
47         void GOTO( ostream &ret, int gotoDest, bool inFinish );
48         void CALL( ostream &ret, int callDest, int targState, bool inFinish );
49         void NEXT( ostream &ret, int nextDest, bool inFinish );
50         void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
51         void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
52         void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
53         void CURS( ostream &ret, bool inFinish );
54         void TARGS( ostream &ret, bool inFinish, int targState );
55         void RET( ostream &ret, bool inFinish );
56         void BREAK( ostream &ret, int targState );
57
58         int TO_STATE_ACTION( RedStateAp *state );
59         int FROM_STATE_ACTION( RedStateAp *state );
60         int EOF_ACTION( RedStateAp *state );
61
62         void COND_TRANSLATE( GenStateCond *stateCond, int level );
63         void emitCondBSearch( RedStateAp *state, int level, int low, int high );
64         void STATE_CONDS( RedStateAp *state, bool genDefault ); 
65
66         virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
67
68         void emitSingleSwitch( RedStateAp *state );
69         void emitRangeBSearch( RedStateAp *state, int level, int low, int high );
70
71         /* Called from STATE_GOTOS just before writing the gotos */
72         virtual void GOTO_HEADER( RedStateAp *state );
73         virtual void STATE_GOTO_ERROR();
74
75         virtual void writeData();
76         virtual void writeEOF();
77         virtual void writeExec();
78
79         
80         std::ostream &TO_STATE_ACTIONS();
81         std::ostream &FROM_STATE_ACTIONS();
82         std::ostream &EOF_ACTIONS();
83
84 private:
85         ostream &rbxGoto(ostream &out, string label);
86         ostream &rbxLabel(ostream &out, string label);  
87 };
88
89 /*
90  * Local Variables:
91  * mode: c++
92  * indent-tabs-mode: 1
93  * c-file-style: "bsd"
94  * End:
95  */
96
97 #endif