removed unused function
[external/ragel.git] / ragel / xmlcodegen.h
1 /*
2  *  Copyright 2005-2007 Adrian Thurston <thurston@complang.org>
3  */
4
5 /*  This file is part of Ragel.
6  *
7  *  Ragel is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  * 
12  *  Ragel is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  * 
17  *  You should have received a copy of the GNU General Public License
18  *  along with Ragel; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
20  */
21
22 #ifndef _XMLDOTGEN_H
23 #define _XMLDOTGEN_H
24
25 #include <iostream>
26 #include "avltree.h"
27 #include "fsmgraph.h"
28 #include "parsedata.h"
29
30 /* Forwards. */
31 struct TransAp;
32 struct FsmAp;
33 struct ParseData;
34 struct GenInlineList;
35
36 struct RedActionTable
37 :
38         public AvlTreeEl<RedActionTable>
39 {
40         RedActionTable( const ActionTable &key )
41         :       
42                 key(key), 
43                 id(0)
44         { }
45
46         const ActionTable &getKey() 
47                 { return key; }
48
49         ActionTable key;
50         int id;
51 };
52
53 typedef AvlTree<RedActionTable, ActionTable, CmpActionTable> ActionTableMap;
54
55 struct NextRedTrans
56 {
57         Key lowKey, highKey;
58         TransAp *trans;
59         TransAp *next;
60
61         void load() {
62                 if ( trans != 0 ) {
63                         next = trans->next;
64                         lowKey = trans->lowKey;
65                         highKey = trans->highKey;
66                 }
67         }
68
69         NextRedTrans( TransAp *t ) {
70                 trans = t;
71                 load();
72         }
73
74         void increment() {
75                 trans = next;
76                 load();
77         }
78 };
79
80 class XMLCodeGen
81 {
82 public:
83         XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, 
84                         std::ostream &out, XmlParser &xmlParser );
85         void writeXML( );
86         void makeBackend( );
87
88 private:
89         void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
90         void writeStateActions( StateAp *state );
91         void writeStateList();
92         void writeStateConditions( StateAp *state );
93
94         void writeKey( Key key );
95         void writeText( InlineItem *item );
96         void writeGoto( InlineItem *item );
97         void writeGotoExpr( InlineItem *item );
98         void writeCall( InlineItem *item );
99         void writeCallExpr( InlineItem *item );
100         void writeNext( InlineItem *item );
101         void writeNextExpr( InlineItem *item );
102         void writeEntry( InlineItem *item );
103         void writeLmOnLast( InlineItem *item );
104         void writeLmOnNext( InlineItem *item );
105         void writeLmOnLagBehind( InlineItem *item );
106
107         void writeExports();
108         bool writeNameInst( NameInst *nameInst );
109         void writeEntryPoints();
110         void writeConditions();
111         void writeInlineList( InlineList *inlineList );
112         void writeActionList();
113         void writeActionTableList();
114         void reduceTrans( TransAp *trans );
115         void reduceActionTables();
116         void writeTransList( StateAp *state );
117         void writeEofTrans( StateAp *state );
118         void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
119         void writeAction( Action *action );
120         void writeLmSwitch( InlineItem *item );
121         void writeMachine();
122         void writeActionExec( InlineItem *item );
123
124         void makeGenInlineList( GenInlineList *outList, InlineList *inList );
125         void makeKey( GenInlineList *outList, Key key );
126         void makeText( GenInlineList *outList, InlineItem *item );
127         void makeGoto( GenInlineList *outList, InlineItem *item );
128         void makeGotoExpr( GenInlineList *outList, InlineItem *item );
129         void makeCall( GenInlineList *outList, InlineItem *item );
130         void makeCallExpr( GenInlineList *outList, InlineItem *item );
131         void makeNext( GenInlineList *outList, InlineItem *item );
132         void makeNextExpr( GenInlineList *outList, InlineItem *item );
133         void makeEntry( GenInlineList *outList, InlineItem *item );
134         void makeLmOnLast( GenInlineList *outList, InlineItem *item );
135         void makeLmOnNext( GenInlineList *outList, InlineItem *item );
136         void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
137         void makeActionExec( GenInlineList *outList, InlineItem *item );
138         void makeLmSwitch( GenInlineList *outList, InlineItem *item );
139
140         char *fsmName;
141         ParseData *pd;
142         FsmAp *fsm;
143         std::ostream &out;
144         XmlParser &xmlParser;
145
146         ActionTableMap actionTableMap;
147         int nextActionTableId;
148 };
149
150
151 #endif /* _XMLDOTGEN_H */