int curKeyOffset = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write the key offset. */
- ARRAY_ITEM( curKeyOffset, st.last() );
+ ARRAY_ITEM( INT(curKeyOffset), st.last() );
/* Move the key offset ahead. */
curKeyOffset += st->stateCondList.length();
int curKeyOffset = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write the key offset. */
- ARRAY_ITEM( curKeyOffset, st.last() );
+ ARRAY_ITEM( INT(curKeyOffset), st.last() );
/* Move the key offset ahead. */
curKeyOffset += st->outSingle.length() + st->outRange.length()*2;
int curIndOffset = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write the index offset. */
- ARRAY_ITEM( curIndOffset, st.last() );
+ ARRAY_ITEM( INT(curIndOffset), st.last() );
/* Move the index offset ahead. */
curIndOffset += st->outSingle.length() + st->outRange.length();
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write singles length. */
- ARRAY_ITEM( st->stateCondList.length(), st.last() );
+ ARRAY_ITEM( INT(st->stateCondList.length()), st.last() );
}
return out;
}
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write singles length. */
- ARRAY_ITEM( st->outSingle.length(), st.last() );
+ ARRAY_ITEM( INT(st->outSingle.length()), st.last() );
}
return out;
}
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Emit length of range index. */
- ARRAY_ITEM( st->outRange.length(), st.last() );
+ ARRAY_ITEM( INT(st->outRange.length()), st.last() );
}
return out;
}
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
- ARRAY_ITEM( TO_STATE_ACTION(st), st.last() );
+ ARRAY_ITEM( INT(TO_STATE_ACTION(st)), st.last() );
}
return out;
}
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
- ARRAY_ITEM( FROM_STATE_ACTION(st), st.last() );
+ ARRAY_ITEM( INT(FROM_STATE_ACTION(st)), st.last() );
}
return out;
}
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Write any eof action. */
- ARRAY_ITEM( EOF_ACTION(st), st.last() );
+ ARRAY_ITEM( INT(EOF_ACTION(st)), st.last() );
}
return out;
}
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
- ARRAY_ITEM( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
- ARRAY_ITEM( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
- ARRAY_ITEM( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
- ARRAY_ITEM( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
/* Output one last number so we don't have to figure out when the last
* entry is and avoid writing a comma. */
- ARRAY_ITEM( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
/* Walk the singles. */
for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
RedTransAp *trans = stel->value;
- ARRAY_ITEM( TRANS_ACTION( trans ), false );
+ ARRAY_ITEM( INT(TRANS_ACTION( trans )), false );
}
/* Walk the ranges. */
for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
RedTransAp *trans = rtel->value;
- ARRAY_ITEM( TRANS_ACTION( trans ), false );
+ ARRAY_ITEM( INT(TRANS_ACTION( trans )), false );
}
/* The state's default index goes next. */
if ( st->defTrans != 0 ) {
RedTransAp *trans = st->defTrans;
- ARRAY_ITEM( TRANS_ACTION( trans ), false );
+ 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( 0, true );
+ ARRAY_ITEM( INT(0), true );
return out;
}
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
/* Write out the target state. */
RedTransAp *trans = transPtrs[t];
- ARRAY_ITEM( trans->targ->id, ( t >= redFsm->transSet.length()-1 ) );
+ ARRAY_ITEM( INT(trans->targ->id), ( t >= redFsm->transSet.length()-1 ) );
}
delete[] transPtrs;
return out;
for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
/* Write the function for the transition. */
RedTransAp *trans = transPtrs[t];
- ARRAY_ITEM( TRANS_ACTION( trans ), ( t >= redFsm->transSet.length()-1 ) );
+ ARRAY_ITEM( INT(TRANS_ACTION( trans )), ( t >= redFsm->transSet.length()-1 ) );
}
delete[] transPtrs;
return out;
return out;
}
-std::ostream &JavaTabCodeGen::ARRAY_ITEM( int item, bool last )
+std::ostream &JavaTabCodeGen::ARRAY_ITEM( string item, bool last )
{
out << "r[" << item_count << "]=" << item << "; ";
/* Write out the array of actions. */
std::ostream &JavaTabCodeGen::ACTIONS_ARRAY()
{
- ARRAY_ITEM( 0, false );
+ ARRAY_ITEM( INT(0), false );
for ( ActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) {
/* Write out the length, which will never be the last character. */
- ARRAY_ITEM( act->key.length(), false );
+ ARRAY_ITEM( INT(act->key.length()), false );
for ( ActionTable::Iter item = act->key; item.lte(); item++ )
- ARRAY_ITEM( item->value->actionId, (act.last() && item.last()) );
+ ARRAY_ITEM( INT(item->value->actionId), (act.last() && item.last()) );
}
return out;
}
return result;
}
-int JavaTabCodeGen::KEY( Key key )
+string JavaTabCodeGen::KEY( Key key )
{
- return key.getVal();
+ ostringstream ret;
+ if ( keyOps->isSigned || !hostLang->explicitUnsigned )
+ ret << key.getVal();
+ else
+ ret << (unsigned long) key.getVal();
+ return ret.str();
}
+string JavaTabCodeGen::INT( int i )
+{
+ ostringstream ret;
+ ret << i;
+ return ret.str();
+}
void JavaTabCodeGen::LM_SWITCH( ostream &ret, InlineItem *item,
int targState, int inFinish )