2 * Copyright 2005-2007 Adrian Thurston <thurston@complang.org>
5 /* This file is part of Ragel.
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.
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.
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
28 #include "parsedata.h"
39 public AvlTreeEl<RedActionTable>
41 RedActionTable( const ActionTable &key )
47 const ActionTable &getKey()
54 typedef AvlTree<RedActionTable, ActionTable, CmpActionTable> ActionTableMap;
65 lowKey = trans->lowKey;
66 highKey = trans->highKey;
70 NextRedTrans( TransAp *t ) {
83 GenBase( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
85 void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
86 void reduceActionTables();
93 ActionTableMap actionTableMap;
94 int nextActionTableId;
97 class XMLCodeGen : protected GenBase
100 XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm,
101 std::ostream &out, XmlParser &xmlParser );
106 void writeStateActions( StateAp *state );
107 void writeStateList();
108 void writeStateConditions( StateAp *state );
110 void writeKey( Key key );
111 void writeText( InlineItem *item );
112 void writeGoto( InlineItem *item );
113 void writeGotoExpr( InlineItem *item );
114 void writeCall( InlineItem *item );
115 void writeCallExpr( InlineItem *item );
116 void writeNext( InlineItem *item );
117 void writeNextExpr( InlineItem *item );
118 void writeEntry( InlineItem *item );
119 void writeLmOnLast( InlineItem *item );
120 void writeLmOnNext( InlineItem *item );
121 void writeLmOnLagBehind( InlineItem *item );
124 bool writeNameInst( NameInst *nameInst );
125 void writeEntryPoints();
126 void writeConditions();
127 void writeInlineList( InlineList *inlineList );
128 void writeActionList();
129 void writeActionTableList();
130 void reduceTrans( TransAp *trans );
131 void writeTransList( StateAp *state );
132 void writeEofTrans( StateAp *state );
133 void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
134 void writeAction( Action *action );
135 void writeLmSwitch( InlineItem *item );
137 void writeActionExec( InlineItem *item );
142 class BackendGen : protected GenBase
145 BackendGen( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
149 void makeGenInlineList( GenInlineList *outList, InlineList *inList );
150 void makeKey( GenInlineList *outList, Key key );
151 void makeText( GenInlineList *outList, InlineItem *item );
152 void makeLmOnLast( GenInlineList *outList, InlineItem *item );
153 void makeLmOnNext( GenInlineList *outList, InlineItem *item );
154 void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
155 void makeActionExec( GenInlineList *outList, InlineItem *item );
156 void makeLmSwitch( GenInlineList *outList, InlineItem *item );
157 void makeSetTokend( GenInlineList *outList, long offset );
158 void makeSetAct( GenInlineList *outList, long lmId );
159 void makeSubList( GenInlineList *outList, InlineList *inlineList,
160 GenInlineItem::Type type );
161 void makeTargetItem( GenInlineList *outList, long targetId, GenInlineItem::Type type );
162 void makeExecGetTokend( GenInlineList *outList );
165 void makeActionList();
166 void makeAction( Action *action );
167 void makeActionTableList();
168 void makeConditions();
169 void makeEntryPoints();
170 bool makeNameInst( std::string &out, NameInst *nameInst );
171 void makeStateList();
173 void makeStateActions( StateAp *state );
174 void makeEofTrans( StateAp *state );
175 void makeStateConditions( StateAp *state );
176 void makeTransList( StateAp *state );
177 void makeTrans( Key lowKey, Key highKey, TransAp *trans );
179 void open_ragel_def( char *fsmName );
180 void close_ragel_def();
184 #endif /* _XMLDOTGEN_H */