summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2020-01-05 10:45:42 +0200
committerAdrian Thurston <thurston@colm.net>2020-01-05 10:45:42 +0200
commitce07bb4538ad2ddf0a3b7c62b0a04bbf0b687d21 (patch)
treebef13a7539d6f76cc85e7385a10c93844e79ce5b
parenta8b2047e0043649bbd3a33d7c7ba67b6af57594b (diff)
downloadcolm-ce07bb4538ad2ddf0a3b7c62b0a04bbf0b687d21.tar.gz
some function renaming and old code removal to elim warnings
refs #97
-rw-r--r--ragel/dot.h22
-rw-r--r--ragel/dotcodegen-orig.cc322
-rw-r--r--ragel/ipgoto.cc4
-rw-r--r--ragel/ipgoto.h2
4 files changed, 5 insertions, 345 deletions
diff --git a/ragel/dot.h b/ragel/dot.h
index 745636df..13f53532 100644
--- a/ragel/dot.h
+++ b/ragel/dot.h
@@ -26,30 +26,12 @@
#include <iostream>
#include "gendata.h"
-class GraphvizDotGenOrig : public CodeGenData
-{
-public:
- GraphvizDotGenOrig( const CodeGenArgs &args )
- : CodeGenData(args) { }
-
- /* Print an fsm to out stream. */
- void writeTransList( RedStateAp *state );
- void writeDotFile( );
-
- virtual void writeStatement( InputLoc &, int, std::string * );
-
-private:
- /* Writing labels and actions. */
- std::ostream &ONCHAR( Key lowKey, Key highKey );
- std::ostream &TRANS_ACTION( RedStateAp *fromState, RedTransAp *trans );
- std::ostream &ACTION( RedAction *action );
- std::ostream &KEY( Key key );
-};
class GraphvizDotGen : public RedBase
{
public:
- GraphvizDotGen( FsmGbl *id, FsmCtx *fsmCtx, FsmAp *fsm, std::string fsmName, int machineId, std::ostream &out )
+ GraphvizDotGen( FsmGbl *id, FsmCtx *fsmCtx, FsmAp *fsm,
+ std::string fsmName, int machineId, std::ostream &out )
:
RedBase(id, fsmCtx, fsm, fsmName, machineId),
out(out)
diff --git a/ragel/dotcodegen-orig.cc b/ragel/dotcodegen-orig.cc
deleted file mode 100644
index 145072dd..00000000
--- a/ragel/dotcodegen-orig.cc
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright 2001-2018 Adrian Thurston <thurston@colm.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "ragel.h"
-#include "dot.h"
-#include "gendata.h"
-#include "inputdata.h"
-#include "rlparse.h"
-#include "rlscan.h"
-
-using std::istream;
-using std::ifstream;
-using std::ostream;
-using std::ios;
-using std::cin;
-using std::endl;
-
-/* Override this so that write statement processing is ignored */
-void GraphvizDotGenOrig::writeStatement( InputLoc &, int, std::vector<std::string> & )
-{
-}
-
-std::ostream &GraphvizDotGenOrig::KEY( Key key )
-{
- if ( displayPrintables && key.isPrintable() ) {
- // Output values as characters, ensuring we escape the quote (") character
- char cVal = (char) key.getVal();
- switch ( cVal ) {
- case '"': case '\\':
- out << "'\\" << cVal << "'";
- break;
- case '\a':
- out << "'\\\\a'";
- break;
- case '\b':
- out << "'\\\\b'";
- break;
- case '\t':
- out << "'\\\\t'";
- break;
- case '\n':
- out << "'\\\\n'";
- break;
- case '\v':
- out << "'\\\\v'";
- break;
- case '\f':
- out << "'\\\\f'";
- break;
- case '\r':
- out << "'\\\\r'";
- break;
- case ' ':
- out << "SP";
- break;
- default:
- out << "'" << cVal << "'";
- break;
- }
- }
- else {
- if ( keyOps->isSigned )
- out << key.getVal();
- else
- out << (unsigned long) key.getVal();
- }
-
- return out;
-}
-
-std::ostream &GraphvizDotGenOrig::TRANS_ACTION( RedStateAp *fromState, RedTransAp *trans )
-{
- int n = 0;
- RedAction *actions[3];
-
- if ( fromState->fromStateAction != 0 )
- actions[n++] = fromState->fromStateAction;
- if ( trans->action != 0 )
- actions[n++] = trans->action;
- if ( trans->targ != 0 && trans->targ->toStateAction != 0 )
- actions[n++] = trans->targ->toStateAction;
-
- if ( n > 0 )
- out << " / ";
-
- /* Loop the existing actions and write out what's there. */
- for ( int a = 0; a < n; a++ ) {
- for ( GenActionTable::Iter actIt = actions[a]->key.first(); actIt.lte(); actIt++ ) {
- GenAction *action = actIt->value;
- out << action->nameOrLoc();
- if ( a < n-1 || !actIt.last() )
- out << ", ";
- }
- }
- return out;
-}
-
-std::ostream &GraphvizDotGenOrig::ACTION( RedAction *action )
-{
- /* The action. */
- out << " / ";
- for ( GenActionTable::Iter actIt = action->key.first(); actIt.lte(); actIt++ ) {
- GenAction *action = actIt->value;
- if ( action->name != 0 )
- out << action->name;
- else
- out << action->loc.line << ":" << action->loc.col;
- if ( !actIt.last() )
- out << ", ";
- }
- return out;
-}
-
-std::ostream &GraphvizDotGenOrig::ONCHAR( Key lowKey, Key highKey )
-{
- GenCondSpace *condSpace;
- if ( lowKey > keyOps->maxKey && (condSpace=findCondSpace(lowKey, highKey) ) ) {
- Key values = ( lowKey - condSpace->baseKey ) / keyOps->alphSize();
-
- lowKey = keyOps->minKey +
- (lowKey - condSpace->baseKey - keyOps->alphSize() * values.getVal());
- highKey = keyOps->minKey +
- (highKey - condSpace->baseKey - keyOps->alphSize() * values.getVal());
- KEY( lowKey );
- if ( lowKey != highKey ) {
- out << "..";
- KEY( highKey );
- }
- out << "(";
-
- for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- bool set = values & (1 << csi.pos());
- if ( !set )
- out << "!";
- out << (*csi)->nameOrLoc();
- if ( !csi.last() )
- out << ", ";
- }
- out << ")";
- }
- else {
- /* Output the key. Possibly a range. */
- KEY( lowKey );
- if ( highKey != lowKey ) {
- out << "..";
- KEY( highKey );
- }
- }
- return out;
-}
-
-void GraphvizDotGenOrig::writeTransList( RedStateAp *state )
-{
- /* Build the set of unique transitions out of this state. */
- RedTransSet stTransSet;
- for ( RedTransList::Iter tel = state->outRange; tel.lte(); tel++ ) {
- /* If we haven't seen the transitions before, the move forward
- * emitting all the transitions on the same character. */
- if ( stTransSet.insert( tel->value ) ) {
- /* Write out the from and to states. */
- out << "\t" << state->id << " -> ";
-
- if ( tel->value->targ == 0 )
- out << "err_" << state->id;
- else
- out << tel->value->targ->id;
-
- /* Begin the label. */
- out << " [ label = \"";
- ONCHAR( tel->lowKey, tel->highKey );
-
- /* Walk the transition list, finding the same. */
- for ( RedTransList::Iter mtel = tel.next(); mtel.lte(); mtel++ ) {
- if ( mtel->value == tel->value ) {
- out << ", ";
- ONCHAR( mtel->lowKey, mtel->highKey );
- }
- }
-
- /* Write the action and close the transition. */
- TRANS_ACTION( state, tel->value );
- out << "\" ];\n";
- }
- }
-
- /* Write the default transition. */
- if ( state->defTrans != 0 ) {
- /* Write out the from and to states. */
- out << "\t" << state->id << " -> ";
-
- if ( state->defTrans->targ == 0 )
- out << "err_" << state->id;
- else
- out << state->defTrans->targ->id;
-
- /* Begin the label. */
- out << " [ label = \"DEF";
-
- /* Write the action and close the transition. */
- TRANS_ACTION( state, state->defTrans );
- out << "\" ];\n";
- }
-}
-
-void GraphvizDotGenOrig::writeDotFile( )
-{
- out <<
- "digraph " << fsmName << " {\n"
- " rankdir=LR;\n";
-
- /* Define the psuedo states. Transitions will be done after the states
- * have been defined as either final or not final. */
- out << " node [ shape = point ];\n";
-
- if ( redFsm->startState != 0 )
- out << " ENTRY;\n";
-
- /* Psuedo states for entry points in the entry map. */
- for ( EntryIdVect::Iter en = entryPointIds; en.lte(); en++ ) {
- RedStateAp *state = allStates + *en;
- out << " en_" << state->id << ";\n";
- }
-
- /* Psuedo states for final states with eof actions. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->eofTrans != 0 && st->eofTrans->action != 0 )
- out << " eof_" << st->id << ";\n";
- if ( st->eofAction != 0 )
- out << " eof_" << st->id << ";\n";
- }
-
- out << " node [ shape = circle, height = 0.2 ];\n";
-
- /* Psuedo states for states whose default actions go to error. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- bool needsErr = false;
- if ( st->defTrans != 0 && st->defTrans->targ == 0 )
- needsErr = true;
- else {
- for ( RedTransList::Iter tel = st->outRange; tel.lte(); tel++ ) {
- if ( tel->value->targ == 0 ) {
- needsErr = true;
- break;
- }
- }
- }
-
- if ( needsErr )
- out << " err_" << st->id << " [ label=\"\"];\n";
- }
-
- /* Attributes common to all nodes, plus double circle for final states. */
- out << " node [ fixedsize = true, height = 0.65, shape = doublecircle ];\n";
-
- /* List Final states. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->isFinal )
- out << " " << st->id << ";\n";
- }
-
- /* List transitions. */
- out << " node [ shape = circle ];\n";
-
- /* Walk the states. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- writeTransList( st );
-
- /* Transitions into the start state. */
- if ( redFsm->startState != 0 )
- out << " ENTRY -> " << redFsm->startState->id << " [ label = \"IN\" ];\n";
-
- /* Transitions into the entry points. */
- for ( EntryIdVect::Iter en = entryPointIds; en.lte(); en++ ) {
- RedStateAp *state = allStates + *en;
- char *name = entryPointNames[en.pos()];
- out << " en_" << state->id << " -> " << state->id <<
- " [ label = \"" << name << "\" ];\n";
- }
-
- /* Out action transitions. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->eofTrans != 0 && st->eofTrans->action != 0 ) {
- out << " " << st->id << " -> eof_" <<
- st->id << " [ label = \"EOF";
- ACTION( st->eofTrans->action ) << "\" ];\n";
- }
- if ( st->eofAction != 0 ) {
- out << " " << st->id << " -> eof_" <<
- st->id << " [ label = \"EOF";
- ACTION( st->eofAction ) << "\" ];\n";
- }
- }
-
- out <<
- "}\n";
-}
-
-void GraphvizDotGenOrig::finishRagelDef()
-{
- /* For dot file generation we want to pick default transitions. */
- redFsm->chooseDefaultSpan();
-}
-
diff --git a/ragel/ipgoto.cc b/ragel/ipgoto.cc
index f6db530c..4b8af3d6 100644
--- a/ragel/ipgoto.cc
+++ b/ragel/ipgoto.cc
@@ -396,7 +396,7 @@ std::ostream &IpGoto::STATE_GOTO_CASES()
return out;
}
-void IpGoto::NFA_PUSH( RedStateAp *state )
+void IpGoto::NFA_PUSH_ST( RedStateAp *state )
{
std::stringstream ss;
ss << state->id;
@@ -516,7 +516,7 @@ std::ostream &IpGoto::STATE_GOTOS()
}
- NFA_PUSH( st );
+ NFA_PUSH_ST( st );
if ( st->fromStateAction != 0 ) {
/* Write every action in the list. */
diff --git a/ragel/ipgoto.h b/ragel/ipgoto.h
index c58eb57a..1ec51bbf 100644
--- a/ragel/ipgoto.h
+++ b/ragel/ipgoto.h
@@ -103,7 +103,7 @@ protected:
void NFA_POP_TEST( RedNfaTarg *targ );
virtual void NFA_FROM_STATE_ACTION_EXEC();
- void NFA_PUSH( RedStateAp *state );
+ void NFA_PUSH_ST( RedStateAp *state );
void tableDataPass();