summaryrefslogtreecommitdiff
path: root/ragel
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2010-10-11 17:46:51 +0000
committerAdrian Thurston <thurston@complang.org>2010-10-11 17:46:51 +0000
commitcdea8fd2332538dbb92bce0012d7b287e56ad228 (patch)
treed7d9558dc973023e2c3510e6fc20e8a9ae211694 /ragel
parent4a4c2f6d9d0729ba2d65eb55344073c59a272df3 (diff)
downloadragel-cdea8fd2332538dbb92bce0012d7b287e56ad228.tar.gz
A little bit more on the conditions revamp. Going to move this to a branch and
try something else ... a trans list in each transiion.
Diffstat (limited to 'ragel')
-rw-r--r--ragel/dotcodegen.cpp8
-rw-r--r--ragel/fsmap.cpp6
-rw-r--r--ragel/fsmgraph.cpp4
-rw-r--r--ragel/fsmgraph.h1
-rw-r--r--ragel/gendata.cpp10
-rw-r--r--ragel/gendata.h6
-rw-r--r--ragel/redfsm.h9
-rw-r--r--ragel/xmlcodegen.cpp2
8 files changed, 35 insertions, 11 deletions
diff --git a/ragel/dotcodegen.cpp b/ragel/dotcodegen.cpp
index f4126311..86804b41 100644
--- a/ragel/dotcodegen.cpp
+++ b/ragel/dotcodegen.cpp
@@ -131,13 +131,11 @@ std::ostream &GraphvizDotGen::ACTION( RedAction *action )
std::ostream &GraphvizDotGen::ONCHAR( Key lowKey, Key highKey )
{
GenCondSpace *condSpace;
- if ( false && lowKey > keyOps->maxKey && (condSpace=findCondSpace(lowKey, highKey) ) ) {
+ 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());
+ lowKey = lowKey & ~condSpace->bitField;
+ highKey = lowKey & ~condSpace->bitField;
KEY( lowKey );
if ( lowKey != highKey ) {
out << "..";
diff --git a/ragel/fsmap.cpp b/ragel/fsmap.cpp
index 7d3fd8e3..c66d3ec8 100644
--- a/ragel/fsmap.cpp
+++ b/ragel/fsmap.cpp
@@ -852,6 +852,12 @@ CondSpace *FsmAp::addCondSpace( const CondSet &condSet )
condSpace = new CondSpace( condSet );
condData->condSpaceMap.insert( condSpace );
+ condSpace->bitField = 0;
+ for ( CondSet::Iter csi = condSet; csi.lte(); csi++ ) {
+ CondBit *condBit = addCondBit( *csi );
+ condSpace->bitField |= ( 0x1 << condBit->bit );
+ }
+
#ifdef LOG_CONDS
cerr << "adding new condition space" << endl;
cerr << " condition set: ";
diff --git a/ragel/fsmgraph.cpp b/ragel/fsmgraph.cpp
index bee9b0cd..8b507c5b 100644
--- a/ragel/fsmgraph.cpp
+++ b/ragel/fsmgraph.cpp
@@ -1220,9 +1220,9 @@ void FsmAp::mergeStates( MergeData &md, StateAp *destState, StateAp *srcState )
ExpansionList expList1;
ExpansionList expList2;
-// findTransExpansions( expList1, destState, srcState );
+ findTransExpansions( expList1, destState, srcState );
findCondExpansions( expList1, destState, srcState );
-// findTransExpansions( expList2, srcState, destState );
+ findTransExpansions( expList2, srcState, destState );
findCondExpansions( expList2, srcState, destState );
mergeStateConds( destState, srcState );
diff --git a/ragel/fsmgraph.h b/ragel/fsmgraph.h
index ec5fc75c..cf9cef5e 100644
--- a/ragel/fsmgraph.h
+++ b/ragel/fsmgraph.h
@@ -582,6 +582,7 @@ struct CondSpace
CondSet condSet;
Key baseKey;
+ unsigned long bitField;
long condSpaceId;
};
diff --git a/ragel/gendata.cpp b/ragel/gendata.cpp
index 5e7ddfc0..c8db29ba 100644
--- a/ragel/gendata.cpp
+++ b/ragel/gendata.cpp
@@ -591,11 +591,19 @@ void CodeGenData::initCondSpaceList( ulong length )
condSpaceList.append( allCondSpaces + c );
}
-void CodeGenData::newCondSpace( int cnum, int condSpaceId, Key baseKey )
+void CodeGenData::newCondSpace( int cnum, int condSpaceId, Key baseKey, unsigned long bitField )
{
GenCondSpace *cond = allCondSpaces + cnum;
cond->condSpaceId = condSpaceId;
cond->baseKey = baseKey;
+ cond->bitField = bitField;
+}
+
+void CodeGenData::initCondBitList( ulong length )
+{
+ allCondBits = new GenCondBit[length];
+ for ( ulong c = 0; c < length; c++ )
+ condBitList.append( allCondBits + c );
}
void CodeGenData::condSpaceItem( int cnum, long condActionId )
diff --git a/ragel/gendata.h b/ragel/gendata.h
index 20c38e88..68ec8b39 100644
--- a/ragel/gendata.h
+++ b/ragel/gendata.h
@@ -92,6 +92,7 @@ struct CodeGenData
RedAction *allActionTables;
Condition *allConditions;
GenCondSpace *allCondSpaces;
+ GenCondBit *allCondBits;
RedStateAp *allStates;
NameInst **nameIndex;
int startState;
@@ -99,6 +100,7 @@ struct CodeGenData
GenActionList actionList;
ConditionList conditionList;
CondSpaceList condSpaceList;
+ CondBitList condBitList;
GenInlineList *getKeyExpr;
GenInlineList *accessExpr;
GenInlineList *prePushExpr;
@@ -150,10 +152,10 @@ struct CodeGenData
void setForcedErrorState()
{ redFsm->forcedErrorState = true; }
-
void initCondSpaceList( ulong length );
+ void initCondBitList( ulong length );
void condSpaceItem( int cnum, long condActionId );
- void newCondSpace( int cnum, int condSpaceId, Key baseKey );
+ void newCondSpace( int cnum, int condSpaceId, Key baseKey, unsigned long bitField );
void initStateCondList( int snum, ulong length );
void addStateCond( int snum, Key lowKey, Key highKey, long condNum );
diff --git a/ragel/redfsm.h b/ragel/redfsm.h
index 2e7ad7c1..03123898 100644
--- a/ragel/redfsm.h
+++ b/ragel/redfsm.h
@@ -299,6 +299,7 @@ typedef DList<Condition> ConditionList;
struct GenCondSpace
{
Key baseKey;
+ unsigned long bitField;
GenCondSet condSet;
int condSpaceId;
@@ -306,6 +307,14 @@ struct GenCondSpace
};
typedef DList<GenCondSpace> CondSpaceList;
+struct GenCondBit
+{
+ GenAction *condition;
+ int bit;
+ GenCondBit *next, *prev;
+};
+typedef DList<GenCondBit> CondBitList;
+
struct GenStateCond
{
Key lowKey;
diff --git a/ragel/xmlcodegen.cpp b/ragel/xmlcodegen.cpp
index 45f7e84b..8a5d659d 100644
--- a/ragel/xmlcodegen.cpp
+++ b/ragel/xmlcodegen.cpp
@@ -1097,7 +1097,7 @@ void BackendGen::makeConditions()
for ( CondSpaceMap::Iter cs = condData->condSpaceMap; cs.lte(); cs++ ) {
long id = cs->condSpaceId;
- cgd->newCondSpace( curCondSpace, id, cs->baseKey );
+ cgd->newCondSpace( curCondSpace, id, cs->baseKey, cs->bitField );
for ( CondSet::Iter csi = cs->condSet; csi.lte(); csi++ )
cgd->condSpaceItem( curCondSpace, (*csi)->actionId );
curCondSpace += 1;