summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-04-26 14:48:10 -0400
committerAdrian Thurston <thurston@complang.org>2015-04-26 14:48:10 -0400
commit313b51b53c749bc7f49d4b2b6fdd8b7a42cf7c80 (patch)
treee57bc31508b920cc5341238c80c6c45679837644
parentb1f60ec339cebdacae96de9f6e247cfa2331395a (diff)
downloadragel-313b51b53c749bc7f49d4b2b6fdd8b7a42cf7c80.tar.gz
testing a priority-interaction based solution for gen repeat failures
refs #38
-rw-r--r--src/fsmap.cc10
-rw-r--r--src/fsmgraph.h9
-rw-r--r--src/parsedata.cc3
-rw-r--r--src/parsetree.cc4
4 files changed, 21 insertions, 5 deletions
diff --git a/src/fsmap.cc b/src/fsmap.cc
index 680267dc..6ee2b7c5 100644
--- a/src/fsmap.cc
+++ b/src/fsmap.cc
@@ -845,10 +845,16 @@ int FsmAp::comparePrior( const PriorTable &priorTable1, const PriorTable &priorT
else if ( pd1->desc->key > pd2->desc->key )
pd2.increment();
/* Keys are the same, check priorities. */
- else if ( pd1->desc->priority < pd2->desc->priority )
+ else if ( pd1->desc->priority < pd2->desc->priority ) {
+ //if ( ctx->nfaTermCheck )
+ // throw PriorInteraction();
return -1;
- else if ( pd1->desc->priority > pd2->desc->priority )
+ }
+ else if ( pd1->desc->priority > pd2->desc->priority ) {
+ //if ( ctx->nfaTermCheck )
+ // throw PriorInteraction();
return 1;
+ }
else {
/* Keys and priorities are equal, advance both. */
pd1.increment();
diff --git a/src/fsmgraph.h b/src/fsmgraph.h
index d2cca3b4..fd596d67 100644
--- a/src/fsmgraph.h
+++ b/src/fsmgraph.h
@@ -61,6 +61,7 @@ struct CondSpace;
struct FsmCtx;
struct TooManyStates {};
+struct PriorInteraction {};
struct RepetitionError {};
struct TransDensity {};
@@ -792,7 +793,8 @@ struct CondData
struct FsmCtx
{
FsmCtx( const HostLang *hostLang, MinimizeLevel minimizeLevel,
- MinimizeOpt minimizeOpt, bool printStatistics )
+ MinimizeOpt minimizeOpt, bool printStatistics,
+ bool nfaTermCheck )
:
minimizeLevel(minimizeLevel),
minimizeOpt(minimizeOpt),
@@ -800,7 +802,9 @@ struct FsmCtx
/* No limit. */
stateLimit(-1),
- printStatistics(printStatistics)
+ printStatistics(printStatistics),
+
+ nfaTermCheck(nfaTermCheck)
{
keyOps = new KeyOps(hostLang);
condData = new CondData;
@@ -813,6 +817,7 @@ struct FsmCtx
long stateLimit;
bool printStatistics;
+ bool nfaTermCheck;
};
typedef InList<CondAp> CondInList;
diff --git a/src/parsedata.cc b/src/parsedata.cc
index d87705a2..402f38e1 100644
--- a/src/parsedata.cc
+++ b/src/parsedata.cc
@@ -468,7 +468,8 @@ ParseData::ParseData( InputData *id, std::string fileName, string sectionName,
* the builtins. */
initGraphDict();
- fsmCtx = new FsmCtx( hostLang, minimizeLevel, minimizeOpt, id->printStatistics );
+ fsmCtx = new FsmCtx( hostLang, minimizeLevel,
+ minimizeOpt, id->printStatistics, id->nfaTermCheck );
}
/* Clean up the data collected during a parse. */
diff --git a/src/parsetree.cc b/src/parsetree.cc
index 2b9f9172..409b3ada 100644
--- a/src/parsetree.cc
+++ b/src/parsetree.cc
@@ -857,6 +857,10 @@ void NfaUnion::nfaTermCheck( ParseData *pd )
cout << "too-many-states" << endl;
exit( 1 );
}
+ catch ( const PriorInteraction & ) {
+ cout << "prior-interaction" << endl;
+ exit( 8 );
+ }
catch ( const RepetitionError & ) {
cout << "rep-error" << endl;
exit( 2 );