outList->append( inlineItem );
}
outList->append( inlineItem );
}
-void XMLCodeGen::makeGoto( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeTargetItem( GenInlineList *outList, InlineItem *item, GenInlineItem::Type type )
{
long targetState;
if ( pd->generatingSectionSubset )
{
long targetState;
if ( pd->generatingSectionSubset )
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Goto );
+ GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), type );
inlineItem->targId = targetState;
outList->append( inlineItem );
}
inlineItem->targId = targetState;
outList->append( inlineItem );
}
-void XMLCodeGen::makeGotoExpr( GenInlineList *outList, InlineItem *item )
+/* Make a sublist item with a given type. */
+void XMLCodeGen::makeSubList( GenInlineList *outList,
+ InlineList *inlineList, GenInlineItem::Type type )
{
/* Fill the sub list. */
GenInlineList *subList = new GenInlineList;
{
/* Fill the sub list. */
GenInlineList *subList = new GenInlineList;
- makeGenInlineList( subList, item->children );
+ makeGenInlineList( subList, inlineList );
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::GotoExpr );
+ GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), type );
inlineItem->children = subList;
outList->append( inlineItem );
}
inlineItem->children = subList;
outList->append( inlineItem );
}
-void XMLCodeGen::makeCall( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeLmOnLast( GenInlineList *outList, InlineItem *item )
- long targetState;
- if ( pd->generatingSectionSubset )
- targetState = -1;
- else {
- EntryMapEl *targ = fsm->entryPoints.find( item->nameTarg->id );
- targetState = targ->value->alg.stateNum;
- }
+ makeSetTokend( outList, 1 );
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Call );
- inlineItem->targId = targetState;
- outList->append( inlineItem );
+ if ( item->longestMatchPart->action != 0 ) {
+ makeSubList( outList,
+ item->longestMatchPart->action->inlineList,
+ GenInlineItem::SubAction );
+ }
-void XMLCodeGen::makeCallExpr( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeLmOnNext( GenInlineList *outList, InlineItem *item )
- /* Fill the sub list. */
- GenInlineList *subList = new GenInlineList;
- makeGenInlineList( subList, item->children );
+ makeSetTokend( outList, 0 );
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Hold ) );
- /* Make the item. */
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::CallExpr );
- inlineItem->children = subList;
- outList->append( inlineItem );
-}
-
-void XMLCodeGen::makeNext( GenInlineList *outList, InlineItem *item )
-{
- long targetState;
- if ( pd->generatingSectionSubset )
- targetState = -1;
- else {
- EntryMapEl *targ = fsm->entryPoints.find( item->nameTarg->id );
- targetState = targ->value->alg.stateNum;
+ if ( item->longestMatchPart->action != 0 ) {
+ makeSubList( outList,
+ item->longestMatchPart->action->inlineList,
+ GenInlineItem::SubAction );
-
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Next );
- inlineItem->targId = targetState;
-void XMLCodeGen::makeNextExpr( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeLmOnLagBehind( GenInlineList *outList, InlineItem *item )
- /* Fill the sub list. */
+ /* Make the sublist containing a just get_tokend. */
+ GenInlineItem *getTokend = new GenInlineItem( GenInputLoc(), GenInlineItem::LmGetTokEnd );
GenInlineList *subList = new GenInlineList;
GenInlineList *subList = new GenInlineList;
- makeGenInlineList( subList, item->children );
+ subList->append( getTokend );
- /* Make the item. */
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::NextExpr );
+ /* Make the Exec item. */
+ GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Exec );
inlineItem->children = subList;
outList->append( inlineItem );
inlineItem->children = subList;
outList->append( inlineItem );
-void XMLCodeGen::makeEntry( GenInlineList *outList, InlineItem *item )
-{
- long entryState;
- if ( pd->generatingSectionSubset )
- entryState = -1;
- else {
- EntryMapEl *targ = fsm->entryPoints.find( item->nameTarg->id );
- entryState = targ->value->alg.stateNum;
+ if ( item->longestMatchPart->action != 0 ) {
+ makeSubList( outList,
+ item->longestMatchPart->action->inlineList,
+ GenInlineItem::SubAction );
-
- GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::Entry );
- inlineItem->targId = entryState;
-void XMLCodeGen::makeLmOnLast( GenInlineList *outList, InlineItem *item )
-{
-}
-void XMLCodeGen::makeLmOnNext( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeLmSwitch( GenInlineList *outList, InlineItem *item )
-void XMLCodeGen::makeLmOnLagBehind( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeSetTokend( GenInlineList *outList, long offset )
+ GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokEnd );
+ inlineItem->offset = offset;
+ outList->append( inlineItem );
-void XMLCodeGen::makeActionExec( GenInlineList *outList, InlineItem *item )
-{
-}
-
-void XMLCodeGen::makeLmSwitch( GenInlineList *outList, InlineItem *item )
+void XMLCodeGen::makeSetAct( GenInlineList *outList, long lmId )
+ GenInlineItem *inlineItem = new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetActId );
+ inlineItem->lmId = lmId;
+ outList->append( inlineItem );
}
void XMLCodeGen::makeGenInlineList( GenInlineList *outList, InlineList *inList )
}
void XMLCodeGen::makeGenInlineList( GenInlineList *outList, InlineList *inList )
makeText( outList, item );
break;
case InlineItem::Goto:
makeText( outList, item );
break;
case InlineItem::Goto:
- makeGoto( outList, item );
+ makeTargetItem( outList, item, GenInlineItem::Goto );
break;
case InlineItem::GotoExpr:
break;
case InlineItem::GotoExpr:
- makeGotoExpr( outList, item );
+ makeSubList( outList, item->children, GenInlineItem::GotoExpr );
break;
case InlineItem::Call:
break;
case InlineItem::Call:
- makeCall( outList, item );
+ makeTargetItem( outList, item, GenInlineItem::Call );
break;
case InlineItem::CallExpr:
break;
case InlineItem::CallExpr:
- makeCallExpr( outList, item );
+ makeSubList( outList, item->children, GenInlineItem::CallExpr );
break;
case InlineItem::Next:
break;
case InlineItem::Next:
- makeNext( outList, item );
+ makeTargetItem( outList, item, GenInlineItem::Next );
break;
case InlineItem::NextExpr:
break;
case InlineItem::NextExpr:
- makeNextExpr( outList, item );
+ makeSubList( outList, item->children, GenInlineItem::NextExpr );
break;
case InlineItem::Break:
break;
case InlineItem::Break:
- out << "<break></break>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Break ) );
break;
case InlineItem::Ret:
break;
case InlineItem::Ret:
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Ret ) );
break;
case InlineItem::PChar:
break;
case InlineItem::PChar:
- out << "<pchar></pchar>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::PChar ) );
break;
case InlineItem::Char:
break;
case InlineItem::Char:
- out << "<char></char>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Char ) );
break;
case InlineItem::Curs:
break;
case InlineItem::Curs:
- out << "<curs></curs>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Curs ) );
break;
case InlineItem::Targs:
break;
case InlineItem::Targs:
- out << "<targs></targs>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Targs ) );
break;
case InlineItem::Entry:
break;
case InlineItem::Entry:
- makeEntry( outList, item );
+ makeTargetItem( outList, item, GenInlineItem::Entry );
break;
case InlineItem::Hold:
break;
case InlineItem::Hold:
- out << "<hold></hold>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::Hold ) );
break;
case InlineItem::Exec:
break;
case InlineItem::Exec:
- makeActionExec( outList, item );
+ makeSubList( outList, item->children, GenInlineItem::Exec );
break;
case InlineItem::LmSetActId:
break;
case InlineItem::LmSetActId:
- out << "<set_act>" <<
- item->longestMatchPart->longestMatchId <<
- "</set_act>";
+ makeSetAct( outList, item->longestMatchPart->longestMatchId );
break;
case InlineItem::LmSetTokEnd:
break;
case InlineItem::LmSetTokEnd:
- out << "<set_tokend>1</set_tokend>";
+ makeSetTokend( outList, 1 );
break;
case InlineItem::LmOnLast:
break;
case InlineItem::LmOnLast:
break;
case InlineItem::LmInitAct:
break;
case InlineItem::LmInitAct:
- out << "<init_act></init_act>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitAct ) );
break;
case InlineItem::LmInitTokStart:
break;
case InlineItem::LmInitTokStart:
- out << "<init_tokstart></init_tokstart>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmInitTokStart ) );
break;
case InlineItem::LmSetTokStart:
break;
case InlineItem::LmSetTokStart:
- out << "<set_tokstart></set_tokstart>";
+ outList->append( new GenInlineItem( GenInputLoc(), GenInlineItem::LmSetTokStart ) );
+ xmlParser.cgd->hasLongestMatch = true;
#include "avltree.h"
#include "fsmgraph.h"
#include "parsedata.h"
#include "avltree.h"
#include "fsmgraph.h"
#include "parsedata.h"
/* Forwards. */
struct TransAp;
/* Forwards. */
struct TransAp;
void makeGenInlineList( GenInlineList *outList, InlineList *inList );
void makeKey( GenInlineList *outList, Key key );
void makeText( GenInlineList *outList, InlineItem *item );
void makeGenInlineList( GenInlineList *outList, InlineList *inList );
void makeKey( GenInlineList *outList, Key key );
void makeText( GenInlineList *outList, InlineItem *item );
- void makeGoto( GenInlineList *outList, InlineItem *item );
- void makeGotoExpr( GenInlineList *outList, InlineItem *item );
- void makeCall( GenInlineList *outList, InlineItem *item );
- void makeCallExpr( GenInlineList *outList, InlineItem *item );
- void makeNext( GenInlineList *outList, InlineItem *item );
- void makeNextExpr( GenInlineList *outList, InlineItem *item );
- void makeEntry( GenInlineList *outList, InlineItem *item );
void makeLmOnLast( GenInlineList *outList, InlineItem *item );
void makeLmOnNext( GenInlineList *outList, InlineItem *item );
void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
void makeActionExec( GenInlineList *outList, InlineItem *item );
void makeLmSwitch( GenInlineList *outList, InlineItem *item );
void makeLmOnLast( GenInlineList *outList, InlineItem *item );
void makeLmOnNext( GenInlineList *outList, InlineItem *item );
void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
void makeActionExec( GenInlineList *outList, InlineItem *item );
void makeLmSwitch( GenInlineList *outList, InlineItem *item );
+ void makeSetTokend( GenInlineList *outList, long offset );
+ void makeSetAct( GenInlineList *outList, long lmId );
+ void makeSubList( GenInlineList *outList, InlineList *inlineList, GenInlineItem::Type type );
+ void makeTargetItem( GenInlineList *outList, InlineItem *item, GenInlineItem::Type type );
char *fsmName;
ParseData *pd;
char *fsmName;
ParseData *pd;