From 313b51b53c749bc7f49d4b2b6fdd8b7a42cf7c80 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sun, 26 Apr 2015 14:48:10 -0400 Subject: testing a priority-interaction based solution for gen repeat failures refs #38 --- src/fsmap.cc | 10 ++++++++-- src/fsmgraph.h | 9 +++++++-- src/parsedata.cc | 3 ++- src/parsetree.cc | 4 ++++ 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 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 ); -- cgit v1.2.1