public AvlTreeEl<RedTransAp>
{
RedTransAp( RedStateAp *targ, RedAction *action, int id )
- : targ(targ), action(action), id(id), labelNeeded(true) { }
+ : targ(targ), action(action), id(id), pos(-1), labelNeeded(true) { }
RedStateAp *targ;
RedAction *action;
int id;
+ int pos;
bool partitionBoundary;
bool labelNeeded;
};
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
out << trans;
if ( !st.last() ) {
out << '\t';
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Save the position. Needed for eofTargs. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
out << trans->targ->id;
if ( t < redFsm->transSet.length()-1 ) {
out << ", ";
string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
string A() { return "_" + DATA_PREFIX() + "actions"; }
- string TA() { return "_" + DATA_PREFIX() + "trans_actions_wi"; }
- string TT() { return "_" + DATA_PREFIX() + "trans_targs_wi"; }
+ string TA() { return "_" + DATA_PREFIX() + "trans_actions"; }
+ string TT() { return "_" + DATA_PREFIX() + "trans_targs"; }
string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; }
string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; }
string EA() { return "_" + DATA_PREFIX() + "eof_actions"; }
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
out << trans;
if ( !st.last() ) {
}
}
+ /* Add any eof transitions that have not yet been written out above. */
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ trans->pos = totalTrans;
+ out << trans->targ->id << ", ";
+ if ( ++totalTrans % IALL == 0 )
+ out << "\n\t";
+ }
+ }
+
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
out << 0 << "\n";
}
}
+ /* Add any eof transitions that have not yet been written out above. */
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ TRANS_ACTION( trans ) << ", ";
+ if ( ++totalTrans % IALL == 0 )
+ out << "\n\t";
+ }
+ }
+
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
out << 0 << "\n";
out << '\t';
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Record the position, need this for eofTrans. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
out << trans->targ->id;
if ( t < redFsm->transSet.length()-1 ) {
out << ", ";
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
out << trans;
if ( !st.last() ) {
out << '\t';
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Record the position, need this for eofTrans. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
out << trans->targ->id;
if ( t < redFsm->transSet.length()-1 ) {
out << ", ";
string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
string A() { return "_" + DATA_PREFIX() + "actions"; }
- string TA() { return "_" + DATA_PREFIX() + "trans_actions_wi"; }
- string TT() { return "_" + DATA_PREFIX() + "trans_targs_wi"; }
+ string TA() { return "_" + DATA_PREFIX() + "trans_actions"; }
+ string TT() { return "_" + DATA_PREFIX() + "trans_targs"; }
string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; }
string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; }
string EA() { return "_" + DATA_PREFIX() + "eof_actions"; }
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
out << trans;
if ( !st.last() ) {
}
}
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ trans->pos = totalTrans;
+ out << trans->targ->id << ", ";
+ if ( ++totalTrans % IALL == 0 )
+ out << "\n\t";
+ }
+ }
+
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
out << 0 << "\n";
}
}
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ TRANS_ACTION( trans ) << ", ";
+ if ( ++totalTrans % IALL == 0 )
+ out << "\n\t";
+ }
+ }
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
out << 0 << "\n";
out << '\t';
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Record the position, need this for eofTrans. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
out << trans->targ->id;
if ( t < redFsm->transSet.length()-1 ) {
out << ", ";
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
/* Write any eof action. */
ARRAY_ITEM( INT(trans), st.last() );
std::ostream &JavaTabCodeGen::TRANS_TARGS()
{
+ int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Walk the singles. */
for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
RedTransAp *trans = stel->value;
ARRAY_ITEM( KEY( trans->targ->id ), false );
+ totalTrans++;
}
/* Walk the ranges. */
for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
RedTransAp *trans = rtel->value;
ARRAY_ITEM( KEY( trans->targ->id ), false );
+ totalTrans++;
}
/* The state's default target state. */
if ( st->defTrans != 0 ) {
RedTransAp *trans = st->defTrans;
ARRAY_ITEM( KEY( trans->targ->id ), false );
+ totalTrans++;
+ }
+ }
+
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ trans->pos = totalTrans++;
+ ARRAY_ITEM( KEY( trans->targ->id ), false );
}
}
}
}
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ ARRAY_ITEM( INT(TRANS_ACTION( trans )), false );
+ }
+ }
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
ARRAY_ITEM( INT(0), true );
/* Keep a count of the num of items in the array written. */
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Save the position. Needed for eofTargs. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
ARRAY_ITEM( INT(trans->targ->id), ( t >= redFsm->transSet.length()-1 ) );
}
delete[] transPtrs;
string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
string A() { return "_" + DATA_PREFIX() + "actions"; }
- string TA() { return "_" + DATA_PREFIX() + "trans_actions_wi"; }
- string TT() { return "_" + DATA_PREFIX() + "trans_targs_wi"; }
+ string TA() { return "_" + DATA_PREFIX() + "trans_actions"; }
+ string TT() { return "_" + DATA_PREFIX() + "trans_targs"; }
string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; }
string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; }
string EA() { return "_" + DATA_PREFIX() + "eof_actions"; }
string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
string A() { return "_" + DATA_PREFIX() + "actions"; }
- string TA() { return "_" + DATA_PREFIX() + "trans_actions_wi"; }
- string TT() { return "_" + DATA_PREFIX() + "trans_targs_wi"; }
+ string TA() { return "_" + DATA_PREFIX() + "trans_actions"; }
+ string TT() { return "_" + DATA_PREFIX() + "trans_targs"; }
string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; }
string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; }
string EA() { return "_" + DATA_PREFIX() + "eof_actions"; }
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
/* Write any eof action. */
ARRAY_ITEM( INT(trans), ++totalStateNum, st.last() );
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Save the position. Needed for eofTargs. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
ARRAY_ITEM( INT( trans->targ->id ), ++totalStates, t >= redFsm->transSet.length()-1 );
}
END_ARRAY_LINE();
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
long trans = 0;
- if ( st->eofTrans != 0 )
- trans = st->eofTrans->id+1;
+ if ( st->eofTrans != 0 ) {
+ assert( st->eofTrans->pos >= 0 );
+ trans = st->eofTrans->pos+1;
+ }
/* Write any eof action. */
ARRAY_ITEM( INT(trans), ++totalStateNum, st.last() );
}
}
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ trans->pos = totalTrans;
+ ARRAY_ITEM( KEY( trans->targ->id ), ++totalTrans, false );
+ }
+ }
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
ARRAY_ITEM( INT(0), ++totalTrans, true );
}
}
+ for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
+ if ( st->eofTrans != 0 ) {
+ RedTransAp *trans = st->eofTrans;
+ ARRAY_ITEM( INT(TRANS_ACTION( trans )), ++totalTrans, false );
+ }
+ }
+
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
ARRAY_ITEM( INT(0), ++totalTrans, true );
START_ARRAY_LINE();
int totalStates = 0;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
+ /* Save the position. Needed for eofTargs. */
RedTransAp *trans = transPtrs[t];
+ trans->pos = t;
+
+ /* Write out the target state. */
ARRAY_ITEM( INT(trans->targ->id), ++totalStates, ( t >= redFsm->transSet.length()-1 ) );
}
END_ARRAY_LINE();
--- /dev/null
+/*
+ * @LANG: indep
+ */
+ptr ts;
+ptr te;
+int act;
+int token;
+%%
+%%{
+ machine scanner;
+
+ # Warning: changing the patterns or the input string will affect the
+ # coverage of the scanner action types.
+ main := |*
+ 'a' => {
+ prints "pat1\n";
+ };
+
+ [ab]+ . 'c' => {
+ prints "pat2\n";
+ };
+
+ any => {
+ prints "any\n";
+ };
+ *|;
+}%%
+/* _____INPUT_____
+"a"
+_____INPUT_____ */
+/* _____OUTPUT_____
+pat1
+ACCEPT
+_____OUTPUT_____ */
--- /dev/null
+/*
+ * @LANG: indep
+ */
+ptr ts;
+ptr te;
+int act;
+int token;
+%%
+%%{
+ machine scanner;
+
+ # Warning: changing the patterns or the input string will affect the
+ # coverage of the scanner action types.
+ main := |*
+ 'a' => {
+ prints "pat1\n";
+ };
+ 'b' => {
+ prints "pat2\n";
+ };
+ [ab] any* => {
+ prints "pat3\n";
+ };
+ *|;
+}%%
+/* _____INPUT_____
+"ab89"
+_____INPUT_____ */
+/* _____OUTPUT_____
+pat3
+ACCEPT
+_____OUTPUT_____ */