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"
40 public AvlTreeEl<RedActionTable>
42 RedActionTable( const ActionTable &key )
48 const ActionTable &getKey()
55 typedef AvlTree<RedActionTable, ActionTable, CmpActionTable> ActionTableMap;
66 lowKey = trans->lowKey;
67 highKey = trans->highKey;
71 NextRedTrans( TransAp *t ) {
84 GenBase( char *fsmName, ParseData *pd, FsmAp *fsm );
86 void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
87 void reduceActionTables();
93 ActionTableMap actionTableMap;
94 int nextActionTableId;
97 class XMLCodeGen : protected GenBase
100 XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, std::ostream &out );
105 void writeStateActions( StateAp *state );
106 void writeStateList();
107 void writeStateConditions( StateAp *state );
109 void writeKey( Key key );
110 void writeText( InlineItem *item );
111 void writeGoto( InlineItem *item );
112 void writeGotoExpr( InlineItem *item );
113 void writeCall( InlineItem *item );
114 void writeCallExpr( InlineItem *item );
115 void writeNext( InlineItem *item );
116 void writeNextExpr( InlineItem *item );
117 void writeEntry( InlineItem *item );
118 void writeLmOnLast( InlineItem *item );
119 void writeLmOnNext( InlineItem *item );
120 void writeLmOnLagBehind( InlineItem *item );
123 bool writeNameInst( NameInst *nameInst );
124 void writeEntryPoints();
125 void writeConditions();
126 void writeInlineList( InlineList *inlineList );
127 void writeActionList();
128 void writeActionTableList();
129 void reduceTrans( TransAp *trans );
130 void writeTransList( StateAp *state );
131 void writeEofTrans( StateAp *state );
132 void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
133 void writeAction( Action *action );
134 void writeLmSwitch( InlineItem *item );
136 void writeActionExec( InlineItem *item );
141 class BackendGen : protected GenBase
144 BackendGen( char *fsmName, ParseData *pd, FsmAp *fsm, CodeGenData *cgd );
148 void makeGenInlineList( GenInlineList *outList, InlineList *inList );
149 void makeKey( GenInlineList *outList, Key key );
150 void makeText( GenInlineList *outList, InlineItem *item );
151 void makeLmOnLast( GenInlineList *outList, InlineItem *item );
152 void makeLmOnNext( GenInlineList *outList, InlineItem *item );
153 void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
154 void makeActionExec( GenInlineList *outList, InlineItem *item );
155 void makeLmSwitch( GenInlineList *outList, InlineItem *item );
156 void makeSetTokend( GenInlineList *outList, long offset );
157 void makeSetAct( GenInlineList *outList, long lmId );
158 void makeSubList( GenInlineList *outList, InlineList *inlineList,
159 GenInlineItem::Type type );
160 void makeTargetItem( GenInlineList *outList, long targetId, GenInlineItem::Type type );
161 void makeExecGetTokend( GenInlineList *outList );
164 void makeActionList();
165 void makeAction( Action *action );
166 void makeActionTableList();
167 void makeConditions();
168 void makeEntryPoints();
169 bool makeNameInst( std::string &out, NameInst *nameInst );
170 void makeStateList();
172 void makeStateActions( StateAp *state );
173 void makeEofTrans( StateAp *state );
174 void makeStateConditions( StateAp *state );
175 void makeTransList( StateAp *state );
176 void makeTrans( Key lowKey, Key highKey, TransAp *trans );
178 void close_ragel_def();
182 /* Collected during parsing. */
193 #endif /* _XMLDOTGEN_H */