out << "</text>";
}
-bool isLmItem( InlineItem *context )
-{
- return context != 0 && (
- context->type == InlineItem::LmOnLast ||
- context->type == InlineItem::LmOnNext ||
- context->type == InlineItem::LmOnLagBehind ||
- context->type == InlineItem::LmSwitch );
-}
-
-void XMLCodeGen::writeCtrlFlow( InlineItem *item, InlineItem *context )
-{
- switch ( item->type ) {
- case InlineItem::Goto:
- writeGoto( item, context );
- break;
- case InlineItem::GotoExpr:
- writeGotoExpr( item, context );
- break;
- case InlineItem::Call:
- writeCall( item, context );
- break;
- case InlineItem::CallExpr:
- writeCallExpr( item, context );
- break;
- case InlineItem::Next:
- writeNext( item, context );
- break;
- case InlineItem::NextExpr:
- writeNextExpr( item, context );
- break;
- case InlineItem::Break:
- out << "<break></break>";
- break;
- case InlineItem::Ret:
- out << "<ret></ret>";
- break;
- default: break;
- }
-}
-
-void XMLCodeGen::writePtrMod( InlineItem *item, InlineItem * )
-{
- switch ( item->type ) {
- case InlineItem::Hold:
- out << "<hold></hold>";
- break;
- case InlineItem::Exec:
- writeActionExec( item );
- break;
- default: break;
- }
-}
-
-
-void XMLCodeGen::writeGoto( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeGoto( InlineItem *item )
{
if ( pd->generatingSectionSubset )
out << "<goto>-1</goto>";
}
}
-void XMLCodeGen::writeCall( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeCall( InlineItem *item )
{
if ( pd->generatingSectionSubset )
out << "<call>-1</call>";
}
}
-void XMLCodeGen::writeNext( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeNext( InlineItem *item )
{
if ( pd->generatingSectionSubset )
out << "<next>-1</next>";
}
}
-void XMLCodeGen::writeGotoExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeGotoExpr( InlineItem *item )
{
out << "<goto_expr>";
- writeInlineList( item->children, 0 );
+ writeInlineList( item->children );
out << "</goto_expr>";
}
-void XMLCodeGen::writeCallExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeCallExpr( InlineItem *item )
{
out << "<call_expr>";
- writeInlineList( item->children, 0 );
+ writeInlineList( item->children );
out << "</call_expr>";
}
-void XMLCodeGen::writeNextExpr( InlineItem *item, InlineItem *context )
+void XMLCodeGen::writeNextExpr( InlineItem *item )
{
out << "<next_expr>";
- writeInlineList( item->children, 0 );
+ writeInlineList( item->children );
out << "</next_expr>";
}
-void XMLCodeGen::writeEntry( InlineItem * item )
+void XMLCodeGen::writeEntry( InlineItem *item )
{
if ( pd->generatingSectionSubset )
out << "<entry>-1</entry>";
void XMLCodeGen::writeActionExec( InlineItem *item )
{
out << "<exec>";
- writeInlineList( item->children, 0 );
+ writeInlineList( item->children );
out << "</exec>";
}
-void XMLCodeGen::writeActionExecTE( InlineItem *item )
-{
- out << "<execte>";
- writeInlineList( item->children, 0 );
- out << "</execte>";
-}
-
void XMLCodeGen::writeLmOnLast( InlineItem *item )
{
out << "<set_tokend>1</set_tokend>";
if ( item->longestMatchPart->action != 0 ) {
out << "<sub_action>";
- writeInlineList( item->longestMatchPart->action->inlineList, item );
+ writeInlineList( item->longestMatchPart->action->inlineList );
out << "</sub_action>";
}
}
if ( item->longestMatchPart->action != 0 ) {
out << "<sub_action>";
- writeInlineList( item->longestMatchPart->action->inlineList, item );
+ writeInlineList( item->longestMatchPart->action->inlineList );
out << "</sub_action>";
}
}
if ( item->longestMatchPart->action != 0 ) {
out << "<sub_action>";
- writeInlineList( item->longestMatchPart->action->inlineList, item );
+ writeInlineList( item->longestMatchPart->action->inlineList );
out << "</sub_action>";
}
}
* when doing control flow changes from inside the machine. */
out << " <sub_action id=\"" << lmi->longestMatchId << "\">";
out << "<exec><get_tokend></get_tokend></exec>";
- writeInlineList( lmi->action->inlineList, item );
+ writeInlineList( lmi->action->inlineList );
out << "</sub_action>\n";
}
}
out << " </lm_switch>";
}
-void XMLCodeGen::writeInlineList( InlineList *inlineList, InlineItem *context )
+void XMLCodeGen::writeInlineList( InlineList *inlineList )
{
for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
switch ( item->type ) {
case InlineItem::Text:
writeText( item );
break;
- case InlineItem::Goto: case InlineItem::GotoExpr:
- case InlineItem::Call: case InlineItem::CallExpr:
- case InlineItem::Next: case InlineItem::NextExpr:
- case InlineItem::Break: case InlineItem::Ret:
- writeCtrlFlow( item, context );
+ case InlineItem::Goto:
+ writeGoto( item );
+ break;
+ case InlineItem::GotoExpr:
+ writeGotoExpr( item );
+ break;
+ case InlineItem::Call:
+ writeCall( item );
+ break;
+ case InlineItem::CallExpr:
+ writeCallExpr( item );
+ break;
+ case InlineItem::Next:
+ writeNext( item );
+ break;
+ case InlineItem::NextExpr:
+ writeNextExpr( item );
+ break;
+ case InlineItem::Break:
+ out << "<break></break>";
+ break;
+ case InlineItem::Ret:
+ out << "<ret></ret>";
break;
case InlineItem::PChar:
out << "<pchar></pchar>";
break;
case InlineItem::Hold:
+ out << "<hold></hold>";
+ break;
case InlineItem::Exec:
- writePtrMod( item, context );
+ writeActionExec( item );
break;
case InlineItem::LmSetActId:
if ( action->name != 0 )
out << " name=\"" << action->name << "\"";
out << " line=\"" << action->loc.line << "\" col=\"" << action->loc.col << "\">";
- writeInlineList( action->inlineList, 0 );
+ writeInlineList( action->inlineList );
out << "</action>\n";
}
/* Getkey expression. */
if ( pd->getKeyExpr != 0 ) {
out << " <getkey>";
- writeInlineList( pd->getKeyExpr, 0 );
+ writeInlineList( pd->getKeyExpr );
out << "</getkey>\n";
}
/* Access expression. */
if ( pd->accessExpr != 0 ) {
out << " <access>";
- writeInlineList( pd->accessExpr, 0 );
+ writeInlineList( pd->accessExpr );
out << "</access>\n";
}
if ( pd->pExpr != 0 ) {
out << " <p_expr>";
- writeInlineList( pd->pExpr, 0 );
+ writeInlineList( pd->pExpr );
out << "</p_expr>\n";
}
if ( pd->peExpr != 0 ) {
out << " <pe_expr>";
- writeInlineList( pd->peExpr, 0 );
+ writeInlineList( pd->peExpr );
out << "</pe_expr>\n";
}
if ( pd->csExpr != 0 ) {
out << " <cs_expr>";
- writeInlineList( pd->csExpr, 0 );
+ writeInlineList( pd->csExpr );
out << "</cs_expr>\n";
}
if ( pd->topExpr != 0 ) {
out << " <top_expr>";
- writeInlineList( pd->topExpr, 0 );
+ writeInlineList( pd->topExpr );
out << "</top_expr>\n";
}
if ( pd->stackExpr != 0 ) {
out << " <stack_expr>";
- writeInlineList( pd->stackExpr, 0 );
+ writeInlineList( pd->stackExpr );
out << "</stack_expr>\n";
}
if ( pd->actExpr != 0 ) {
out << " <act_expr>";
- writeInlineList( pd->actExpr, 0 );
+ writeInlineList( pd->actExpr );
out << "</act_expr>\n";
}
if ( pd->tokstartExpr != 0 ) {
out << " <tokstart_expr>";
- writeInlineList( pd->tokstartExpr, 0 );
+ writeInlineList( pd->tokstartExpr );
out << "</tokstart_expr>\n";
}
if ( pd->tokendExpr != 0 ) {
out << " <tokend_expr>";
- writeInlineList( pd->tokendExpr, 0 );
+ writeInlineList( pd->tokendExpr );
out << "</tokend_expr>\n";
}
void writeKey( Key key );
void writeText( InlineItem *item );
- void writeCtrlFlow( InlineItem *item, InlineItem *context );
- void writePtrMod( InlineItem *item, InlineItem *context );
- void writeGoto( InlineItem *item, InlineItem *context );
- void writeGotoExpr( InlineItem *item, InlineItem *context );
- void writeCall( InlineItem *item, InlineItem *context );
- void writeCallExpr( InlineItem *item, InlineItem *context );
- void writeNext( InlineItem *item, InlineItem *context );
- void writeNextExpr( InlineItem *item, InlineItem *context );
+ void writeGoto( InlineItem *item );
+ void writeGotoExpr( InlineItem *item );
+ void writeCall( InlineItem *item );
+ void writeCallExpr( InlineItem *item );
+ void writeNext( InlineItem *item );
+ void writeNextExpr( InlineItem *item );
void writeEntry( InlineItem *item );
void writeLmSetActId( InlineItem *item );
void writeLmOnLast( InlineItem *item );
bool writeNameInst( NameInst *nameInst );
void writeEntryPoints();
void writeConditions();
- void writeInlineList( InlineList *inlineList, InlineItem *context );
+ void writeInlineList( InlineList *inlineList );
void writeActionList();
void writeActionTableList();
void reduceTrans( TransAp *trans );
void writeLmSwitch( InlineItem *item );
void writeMachine();
void writeActionExec( InlineItem *item );
- void writeActionExecTE( InlineItem *item );
char *fsmName;
ParseData *pd;
enum Type
{
Text, Goto, Call, Next, GotoExpr, CallExpr, NextExpr, Ret,
- PChar, Char, Hold, Exec, HoldTE, ExecTE, Curs, Targs, Entry,
+ PChar, Char, Hold, Exec, Curs, Targs, Entry,
LmSwitch, LmSetActId, LmSetTokEnd, LmGetTokEnd, LmInitTokStart,
LmInitAct, LmSetTokStart, SubAction, Break
};
# Inline block tokens.
token TAG_text, TAG_goto, TAG_call, TAG_next, TAG_goto_expr,
TAG_call_expr, TAG_next_expr, TAG_ret, TAG_pchar, TAG_char,
- TAG_hold, TAG_exec, TAG_holdte, TAG_execte, TAG_curs, TAG_targs,
- TAG_entry, TAG_data, TAG_lm_switch, TAG_init_act, TAG_set_act,
- TAG_set_tokend, TAG_get_tokend, TAG_init_tokstart,
- TAG_set_tokstart;
+ TAG_hold, TAG_exec, TAG_curs, TAG_targs, TAG_entry, TAG_data,
+ TAG_lm_switch, TAG_init_act, TAG_set_act, TAG_set_tokend,
+ TAG_get_tokend, TAG_init_tokstart, TAG_set_tokstart;
token TAG_write, TAG_access, TAG_break, TAG_arg, TAG_cs_expr;
inline_item: tag_char final { $$->inlineItem = $1->inlineItem; };
inline_item: tag_hold final { $$->inlineItem = $1->inlineItem; };
inline_item: tag_exec final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_holdte final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_execte final { $$->inlineItem = $1->inlineItem; };
inline_item: tag_curs final { $$->inlineItem = $1->inlineItem; };
inline_item: tag_targs final { $$->inlineItem = $1->inlineItem; };
inline_item: tag_il_entry final { $$->inlineItem = $1->inlineItem; };
nonterm tag_char uses inline_item_type;
nonterm tag_hold uses inline_item_type;
nonterm tag_exec uses inline_item_type;
-nonterm tag_holdte uses inline_item_type;
-nonterm tag_execte uses inline_item_type;
nonterm tag_curs uses inline_item_type;
nonterm tag_targs uses inline_item_type;
nonterm tag_il_entry uses inline_item_type;
$$->inlineItem->children = $2->inlineList;
};
-tag_holdte: TAG_holdte '/' TAG_holdte
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::HoldTE );
- };
-
-tag_execte: TAG_execte inline_list '/' TAG_execte
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::ExecTE );
- $$->inlineItem->children = $2->inlineList;
- };
-
tag_curs: TAG_curs '/' TAG_curs
final {
$$->inlineItem = new InlineItem( InputLoc(), InlineItem::Curs );
char, TAG_char
hold, TAG_hold
exec, TAG_exec
-holdte, TAG_holdte
-execte, TAG_execte
curs, TAG_curs
targs, TAG_targs
entry, TAG_entry
ret << "))-1;}";
}
-void FsmCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
- /* Tokend version of exec. */
-
- /* The parser gives fexec two children. The double brackets are for D
- * code. If the inline list is a single word it will get interpreted as a
- * C-style cast by the D compiler. */
- ret << "{" << TOKEND() << " = ((";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << "));}";
-}
-
-
void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item,
int targState, int inFinish )
{
case InlineItem::Exec:
EXEC( ret, item, targState, inFinish );
break;
- case InlineItem::HoldTE:
- ret << TOKEND() << "--;";
- break;
- case InlineItem::ExecTE:
- EXECTE( ret, item, targState, inFinish );
- break;
case InlineItem::Curs:
CURS( ret, inFinish );
break;
virtual void CURS( ostream &ret, bool inFinish ) = 0;
virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0;
void EXEC( ostream &ret, InlineItem *item, int targState, int inFinish );
- void EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish );
void LM_SWITCH( ostream &ret, InlineItem *item, int targState, int inFinish );
void SET_ACT( ostream &ret, InlineItem *item );
void INIT_TOKSTART( ostream &ret, InlineItem *item );
ret << "))-1;}";
}
-void JavaTabCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
- /* Tokend version of exec. */
-
- /* The parser gives fexec two children. The double brackets are for D
- * code. If the inline list is a single word it will get interpreted as a
- * C-style cast by the D compiler. */
- ret << "{" << TOKEND() << " = ((";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << "));}";
-}
-
/* Write out an inline tree structure. Walks the list and possibly calls out
* to virtual functions than handle language specific items in the tree. */
void JavaTabCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
case InlineItem::Exec:
EXEC( ret, item, targState, inFinish );
break;
- case InlineItem::HoldTE:
- ret << TOKEND() << "--;";
- break;
- case InlineItem::ExecTE:
- EXECTE( ret, item, targState, inFinish );
- break;
case InlineItem::Curs:
ret << "(_ps)";
break;
ret << "))-1; end\n";
}
-void RubyCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
- /* Tokend version of exec. */
-
- /* The parser gives fexec two children. The double brackets are for D
- * code. If the inline list is a single word it will get interpreted as a
- * C-style cast by the D compiler. */
- ret << " begin " << TOKEND() << " = ((";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << ")); end\n";
-}
-
/* Write out an inline tree structure. Walks the list and possibly calls out
* to virtual functions than handle language specific items in the tree. */
void RubyCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
case InlineItem::Exec:
EXEC( ret, item, targState, inFinish );
break;
- case InlineItem::HoldTE:
- ret << TOKEND() << " = " << TOKEND() << " - 1;";
- break;
- case InlineItem::ExecTE:
- EXECTE( ret, item, targState, inFinish );
- break;
case InlineItem::Curs:
ret << "(_ps)";
break;