Exemple #1
0
std::ostream &CSharpTabCodeGen::KEYS()
{
    out << '\t';
    int totalTrans = 0;
    for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
        /* Loop the singles. */
        for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
            out << ALPHA_KEY( stel->lowKey ) << ", ";
            if ( ++totalTrans % IALL == 0 )
                out << "\n\t";
        }

        /* Loop the state's transitions. */
        for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
            /* Lower key. */
            out << ALPHA_KEY( rtel->lowKey ) << ", ";
            if ( ++totalTrans % IALL == 0 )
                out << "\n\t";

            /* Upper key. */
            out << ALPHA_KEY( rtel->highKey ) << ", ";
            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 << "(char) " << 0 << "\n";
    return out;
}
Exemple #2
0
std::wostream &CSharpTabCodeGen::COND_KEYS()
{
	out << L'\t';
	int totalTrans = 0;
	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
		/* Loop the state's transitions. */
		for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
			/* Lower key. */
			out << ALPHA_KEY( sc->lowKey ) << L", ";
			if ( ++totalTrans % IALL == 0 )
				out << L"\n\t";

			/* Upper key. */
			out << ALPHA_KEY( sc->highKey ) << L", ";
			if ( ++totalTrans % IALL == 0 )
				out << L"\n\t";
		}
	}

	/* Output one last number so we don't have to figure out when the last
	 * entry is and avoid writing a comma. */
	if ( keyOps->alphType->isChar )
		out << L"(char) " << 0 << L"\n";
	else
		out << 0 << L"\n";

	return out;
}
Exemple #3
0
void CSharpGotoCodeGen::emitSingleSwitch( RedStateAp *state )
{
	/* Load up the singles. */
	int numSingles = state->outSingle.length();
	RedTransEl *data = state->outSingle.data;

	if ( numSingles == 1 ) {
		/* If there is a single single key then write it out as an if. */
		out << L"\tif ( " << GET_WIDE_KEY(state) << L" == " << 
				KEY(data[0].lowKey) << L" )\n\t\t"; 

		/* Virtual function for writing the target of the transition. */
		TRANS_GOTO(data[0].value, 0) << L"\n";
	}
	else if ( numSingles > 1 ) {
		/* Write out single keys in a switch if there is more than one. */
		out << L"\tswitch( " << GET_WIDE_KEY(state) << L" ) {\n";

		/* Write out the single indicies. */
		for ( int j = 0; j < numSingles; j++ ) {
			out << L"\t\tcase " << ALPHA_KEY(data[j].lowKey) << L": ";
			TRANS_GOTO(data[j].value, 0) << L"\n";
		}
		
		/* Emits a default case for D code. */
		SWITCH_DEFAULT();

		/* Close off the transition switch. */
		out << L"\t}\n";
	}
}
Exemple #4
0
std::ostream &CSharpFlatCodeGen::KEYS()
{
	out << '\t';
	int totalTrans = 0;
	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
		/* Emit just low key and high key. */
		out << ALPHA_KEY( st->lowKey ) << ", ";
		out << ALPHA_KEY( st->highKey ) << ", ";
		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 << "(char) " << 0 << "\n";
	return out;
}
Exemple #5
0
std::ostream &OCamlTabCodeGen::COND_KEYS()
{
	out << '\t';
	int totalTrans = 0;
	for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
		/* Loop the state's transitions. */
		for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
			/* Lower key. */
			out << ALPHA_KEY( sc->lowKey ) << ARR_SEP();
			if ( ++totalTrans % IALL == 0 )
				out << "\n\t";

			/* Upper key. */
			out << ALPHA_KEY( sc->highKey ) << ARR_SEP();
			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";
	return out;
}