#include "ragel.h"
#include "xmlcodegen.h"
-#include "xmlparse.h"
#include "parsedata.h"
#include "fsmgraph.h"
#include "gendata.h"
#include "inputdata.h"
#include <string.h>
+#include "rlparse.h"
+#include "version.h"
using namespace std;
outList->append( inlineItem );
}
-void BackendGen::makeTargetItem( GenInlineList *outList, long entryId, GenInlineItem::Type type )
+void BackendGen::makeTargetItem( GenInlineList *outList, NameInst *nameTarg,
+ GenInlineItem::Type type )
{
long targetState;
if ( pd->generatingSectionSubset )
targetState = -1;
else {
- EntryMapEl *targ = fsm->entryPoints.find( entryId );
+ EntryMapEl *targ = fsm->entryPoints.find( nameTarg->id );
targetState = targ->value->alg.stateNum;
}
makeText( outList, item );
break;
case InlineItem::Goto:
- makeTargetItem( outList, item->nameTarg->id, GenInlineItem::Goto );
+ makeTargetItem( outList, item->nameTarg, GenInlineItem::Goto );
break;
case InlineItem::GotoExpr:
makeSubList( outList, item->children, GenInlineItem::GotoExpr );
break;
case InlineItem::Call:
- makeTargetItem( outList, item->nameTarg->id, GenInlineItem::Call );
+ makeTargetItem( outList, item->nameTarg, GenInlineItem::Call );
break;
case InlineItem::CallExpr:
makeSubList( outList, item->children, GenInlineItem::CallExpr );
break;
case InlineItem::Next:
- makeTargetItem( outList, item->nameTarg->id, GenInlineItem::Next );
+ makeTargetItem( outList, item->nameTarg, GenInlineItem::Next );
break;
case InlineItem::NextExpr:
makeSubList( outList, item->children, GenInlineItem::NextExpr );
outList->append( new GenInlineItem( InputLoc(), GenInlineItem::Targs ) );
break;
case InlineItem::Entry:
- makeTargetItem( outList, item->nameTarg->id, GenInlineItem::Entry );
+ makeTargetItem( outList, item->nameTarg, GenInlineItem::Entry );
break;
case InlineItem::Hold:
GenInlineList *genList = new GenInlineList;
makeGenInlineList( genList, action->inlineList );
- cgd->newAction( curAction++, action->name,
- action->loc.line, action->loc.col, genList );
+ cgd->newAction( curAction++, action->name, action->loc, genList );
}
close_ragel_def();
}
+void InputData::writeLanguage( std::ostream &out )
+{
+ out << " lang=\"";
+ switch ( hostLang->lang ) {
+ case HostLang::C: out << "C"; break;
+ case HostLang::D: out << "D"; break;
+ case HostLang::Java: out << "Java"; break;
+ case HostLang::Ruby: out << "Ruby"; break;
+ case HostLang::CSharp: out << "C#"; break;
+ }
+ out << "\"";
+}
+
+void InputData::writeXML( std::ostream &out )
+{
+ out << "<ragel version=\"" VERSION "\" filename=\"" << inputFileName << "\"";
+ writeLanguage( out );
+ out << ">\n";
+ for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) {
+ ParseData *pd = parser->value->pd;
+ if ( pd->instanceList.length() > 0 )
+ pd->generateXML( *outStream );
+ }
+
+ out << "</ragel>\n";
+}