Notes on version 6.3.
[ragel.git] / ragel / xmlcodegen.h
blobb82a8da99a3bfcf3ac5a67146f00890395178e5f
1 /*
2 * Copyright 2005-2007 Adrian Thurston <thurston@cs.queensu.ca>
3 */
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
22 #ifndef _XMLDOTGEN_H
23 #define _XMLDOTGEN_H
25 #include <iostream>
26 #include "avltree.h"
27 #include "fsmgraph.h"
28 #include "parsedata.h"
30 /* Forwards. */
31 struct TransAp;
32 struct FsmAp;
33 struct ParseData;
35 struct RedActionTable
37 public AvlTreeEl<RedActionTable>
39 RedActionTable( const ActionTable &key )
41 key(key),
42 id(0)
43 { }
45 const ActionTable &getKey()
46 { return key; }
48 ActionTable key;
49 int id;
52 typedef AvlTree<RedActionTable, ActionTable, CmpActionTable> ActionTableMap;
54 struct NextRedTrans
56 Key lowKey, highKey;
57 TransAp *trans;
58 TransAp *next;
60 void load() {
61 if ( trans != 0 ) {
62 next = trans->next;
63 lowKey = trans->lowKey;
64 highKey = trans->highKey;
68 NextRedTrans( TransAp *t ) {
69 trans = t;
70 load();
73 void increment() {
74 trans = next;
75 load();
79 class XMLCodeGen
81 public:
82 XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, std::ostream &out );
83 void writeXML( );
85 private:
86 void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
87 void writeStateActions( StateAp *state );
88 void writeStateList();
89 void writeStateConditions( StateAp *state );
91 void writeKey( Key key );
92 void writeText( InlineItem *item );
93 void writeGoto( InlineItem *item );
94 void writeGotoExpr( InlineItem *item );
95 void writeCall( InlineItem *item );
96 void writeCallExpr( InlineItem *item );
97 void writeNext( InlineItem *item );
98 void writeNextExpr( InlineItem *item );
99 void writeEntry( InlineItem *item );
100 void writeLmSetActId( InlineItem *item );
101 void writeLmOnLast( InlineItem *item );
102 void writeLmOnNext( InlineItem *item );
103 void writeLmOnLagBehind( InlineItem *item );
105 void writeExports();
106 bool writeNameInst( NameInst *nameInst );
107 void writeEntryPoints();
108 void writeConditions();
109 void writeInlineList( InlineList *inlineList );
110 void writeActionList();
111 void writeActionTableList();
112 void reduceTrans( TransAp *trans );
113 void reduceActionTables();
114 void writeTransList( StateAp *state );
115 void writeEofTrans( StateAp *state );
116 void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
117 void writeAction( Action *action );
118 void writeLmSwitch( InlineItem *item );
119 void writeMachine();
120 void writeActionExec( InlineItem *item );
122 char *fsmName;
123 ParseData *pd;
124 FsmAp *fsm;
125 std::ostream &out;
126 ActionTableMap actionTableMap;
127 int nextActionTableId;
131 #endif /* _XMLDOTGEN_H */