- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Solvers/SAT/GATSAT/TestSuiteParser.cpp

    00001 /* $ANTLR 2.7.5 (20050128): "TestSuite.g" -> "TestSuiteParser.cpp"$ */
    00002 #include "TestSuiteParser.hpp"
    00003 #include <antlr/NoViableAltException.hpp>
    00004 #include <antlr/SemanticException.hpp>
    00005 #include <antlr/ASTFactory.hpp>
    00006 #line 47 "TestSuite.g"
    00007
    00009
    00010 #include <Mers/Models/Base/BaseModel.h>
    00011 #include <Mers/Models/Base/BaseModelValue.h>
    00012 #include <Mers/Models/Base/BaseModelValueArray.h>
    00013 #include <Mers/Models/Base/BaseModelVariable.h>
    00014 #include <Mers/Models/Base/BaseModelVariableArray.h>
    00015 #include <Mers/Models/Base/BaseModelSentence.h>
    00016 #include <Mers/Models/Base/BaseModelClause.h>
    00017 #include <Mers/Models/Base/BaseModelAssignment.h>
    00018 #include <Mers/Utils/Containers/IntegerArray.h>
    00019 #include <Mers/Solvers/SAT/GATSAT/GatsatFactory.h>
    00020 #include <Mers/Solvers/SAT/GATSAT/NUGatsatFactory.h>
    00021 #include <Mers/Solvers/SAT/GATSAT/GATSAT.h>
    00022 #include <Mers/Solvers/SAT/AssignmentTesterInterface.h>
    00023 #include <Mers/Generators/AssignmentGeneratorInterface.h>
    00024
    00026
    00027 using Mers::Solvers::SAT::GATSAT::GatsatFactory;
    00028 using Mers::Solvers::SAT::GATSAT::GATSAT;
    00029 using Mers::Solvers::SAT::GATSAT::NUGatsatFactory;
    00030 using Mers::Solvers::SAT::AssignmentTesterInterface;
    00031 using Mers::Generators::AssignmentGeneratorInterface;
    00032 using Mers::Models::Base::BaseModel;
    00033 using Mers::Models::Base::BaseModelValue;
    00034 using Mers::Models::Base::BaseModelValueArray;
    00035 using Mers::Models::Base::BaseModelVariable;
    00036 using Mers::Models::Base::BaseModelVariableArray;
    00037 using Mers::Models::Base::BaseModelSentence;
    00038 using Mers::Models::Base::BaseModelClause;
    00039 using Mers::Models::Base::BaseModelClauseArray;
    00040 using Mers::Models::Base::BaseModelAssignment;
    00041 using Mers::Utils::Containers::IntegerArray;
    00042 using std::vector;
    00043 using std::string;
    00044 using std::cerr;
    00045 using std::cout;
    00046 using std::endl;
    00047
    00049
    00050 // Extract the characters from the object that ANTLR uses.
    00051 #define CHARS_OF(T) ((T)->getText().c_str())
    00052
    00054
    00055 #line 56 "TestSuiteParser.cpp"
    00056 ANTLR_BEGIN_NAMESPACE(Mers)
    00057 ANTLR_BEGIN_NAMESPACE(Solvers)
    00058 ANTLR_BEGIN_NAMESPACE(SAT)
    00059 ANTLR_BEGIN_NAMESPACE(GATSAT)
    00060 #line 110 "TestSuite.g"
    00061
    00063 void testGSUnsat(GATSAT * gSat,
    00064 clock_t cConstructStart, unsigned int numSVars, unsigned int numVars,
    00065 unsigned int numClause)
    00066 {
    00067 // Some constants we're using for now.  These should eventually
    00068 // be setup as parameters.
    00069 int numResults = 100000;
    00070 int maxStatesTime = 2000000;
    00071 int maxStatesSize = 1500000;
    00072
    00073 // We want to also time the amount of time it takes to solve.
    00074 clock_t cSolveStart = clock();
    00075
    00076 // Find all solutions.
    00077 BaseModelClauseArray * results =
    00078 gSat->findUnsatisfyingSolutions(numResults, maxStatesTime, maxStatesSize);
    00079
    00080 // End our timing.
    00081 clock_t cEnd = clock();
    00082
    00083 // Print our search data.
    00084 cout << numSVars << '\t' << numVars << '\t' << numClause;
    00085 if(results != NULL) {
    00086 // Print out the number of results.
    00087 cout << '\t' << results->size();
    00088
    00089 // Cleanup our results memory.
    00090 delete results;
    00091 } else {
    00092 cout << "\t0";
    00093 }
    00094
    00095 // Amount of time elapsed during construction.
    00096 double dSetupTime =
    00097 (cSolveStart - cConstructStart) / (double) CLOCKS_PER_SEC;
    00098 // Amount of time elapsed during solving.
    00099 double dSolveTime =
    00100 (cEnd - cSolveStart) / (double) CLOCKS_PER_SEC;
    00101
    00102 // Print out the total time taken.
    00103 cout << '\t' << dSetupTime << '\t' << dSolveTime;
    00104
    00105 // Extract the data on the number of steps taken.
    00106 AssignmentGeneratorInterface * iAGen = gSat->getGenerator();
    00107 AssignmentTesterInterface * iATest = gSat->getTester();
    00108
    00109 cout << '\t' << iAGen->getNumberOfSteps() <<
    00110 '\t' << iATest->getNumberOfSteps() << endl;
    00111 }
    00113
    00114 #line 111 "TestSuiteParser.cpp"
    00115 TestSuiteParser::TestSuiteParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k)
    00116 : ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,k)
    00117 {
    00118 }
    00119
    00120 TestSuiteParser::TestSuiteParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf)
    00121 : ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,1)
    00122 {
    00123 }
    00124
    00125 TestSuiteParser::TestSuiteParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k)
    00126 : ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,k)
    00127 {
    00128 }
    00129
    00130 TestSuiteParser::TestSuiteParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer)
    00131 : ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,1)
    00132 {
    00133 }
    00134
    00135 TestSuiteParser::TestSuiteParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state)
    00136 : ANTLR_USE_NAMESPACE(antlr)LLkParser(state,1)
    00137 {
    00138 }
    00139
    00140 void TestSuiteParser::startProbTests(
    00141         Mers::Solvers::SAT::GATSAT::NUGatsatFactory &gtFactory
    00142 ) {
    00143
    00144         try {      // for error handling
    00145 #line 169 "TestSuite.g"
    00146
    00147                 // Save the initial set of headers.
    00148                 cout << "Test\tSVars\tTVars\tClauses\tRes\tSetup\tSolve\tGStep\tTStep" << endl;
    00149
    00150 #line 147 "TestSuiteParser.cpp"
    00151                 { // ( ... )*
    00152                 for (;;) {
    00153                         if ((LA(1) == NAME || LA(1) == VALUE)) {
    00154                                 probTest(gtFactory);
    00155                         }
    00156                         else {
    00157                                 goto _loop3;
    00158                         }
    00159
    00160                 }
    00161                 _loop3:;
    00162                 } // ( ... )*
    00163                 match(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
    00164         }
    00165         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00166                 reportError(ex);
    00167                 recover(ex,_tokenSet_0);
    00168         }
    00169 }
    00170
    00171 void TestSuiteParser::probTest(
    00172         Mers::Solvers::SAT::GATSAT::NUGatsatFactory &gtFactory
    00173 ) {
    00174
    00175         try {      // for error handling
    00176 #line 182 "TestSuite.g"
    00177
    00178                 // We load all of our model data into this object.
    00179                 BaseModel bm;
    00180                 // This map maps variable UIDs to a start index in the probs list.
    00181                 IntegerArray probMap;
    00182                 // A list of all probabilities used by this engine.
    00183                 vector<double> probs;
    00184                 // A theory of constraints are loaded here.
    00185                 BaseModelSentence * bmTheory;
    00186                 // The name of the test.
    00187                 string testName;
    00188
    00189 #line 186 "TestSuiteParser.cpp"
    00190                 testName=testHeader();
    00191                 search();
    00192                 variablesWithProbs(bm, probMap, probs);
    00193                 nonSearch();
    00194                 variables(bm);
    00195                 cons();
    00196                 bmTheory=constraints(bm);
    00197 #line 202 "TestSuite.g"
    00198
    00199                 cout << testName << '\t';
    00200                 // A set of search variables for this problem.
    00201                 BaseModelVariableArray searchVars(false);
    00202                 // A set of all variables associated with this problem.
    00203                 BaseModelVariableArray &allVars = *(bm.getVariables());
    00204                 // Copy the relevant variables over to the searchVariables list
    00205                 // - notably one per probability map.
    00206                 for(unsigned int i = 0; i < probMap.size(); ++i) {
    00207                 // Add this element
    00208                 searchVars.pushBack(allVars[i]);
    00209                 }
    00210
    00211                 // We want to time the amount of time it takes to construct GATSAT
    00212                 clock_t cConstructStart = clock();
    00213
    00214                 // Construct our GATSAT object.
    00215                 GATSAT * gSat = gtFactory.createGatsat(searchVars, allVars, *bmTheory,
    00216                 probMap, probs);
    00217
    00218                 // Test GATSAT.
    00219                 testGSUnsat(gSat, cConstructStart, searchVars.size(), allVars.size(),
    00220                 bmTheory->size());
    00221
    00222                 //cerr << bm;
    00223                 //cerr << bmTheory;
    00224                 //cerr << searchVars << endl;
    00225                 //cerr << allVars << endl;
    00226                 // Cleanup our engine.
    00227                 delete gSat;
    00228                 // Cleanup our theory
    00229                 delete bmTheory;
    00230
    00231 #line 228 "TestSuiteParser.cpp"
    00232         }
    00233         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00234                 reportError(ex);
    00235                 recover(ex,_tokenSet_1);
    00236         }
    00237 }
    00238
    00239 std::string  TestSuiteParser::testHeader() {
    00240 #line 308 "TestSuite.g"
    00241         std::string str;
    00242 #line 239 "TestSuiteParser.cpp"
    00243         ANTLR_USE_NAMESPACE(antlr)RefToken  hName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00244         ANTLR_USE_NAMESPACE(antlr)RefToken  hNum = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00245
    00246         try {      // for error handling
    00247                 {
    00248                 switch ( LA(1)) {
    00249                 case NAME:
    00250                 {
    00251                         hName = LT(1);
    00252                         match(NAME);
    00253 #line 311 "TestSuite.g"
    00254                         str = CHARS_OF(hName);
    00255 #line 252 "TestSuiteParser.cpp"
    00256                         break;
    00257                 }
    00258                 case VALUE:
    00259                 {
    00260                         hNum = LT(1);
    00261                         match(VALUE);
    00262 #line 313 "TestSuite.g"
    00263                         str = CHARS_OF(hNum);
    00264 #line 261 "TestSuiteParser.cpp"
    00265                         break;
    00266                 }
    00267                 default:
    00268                 {
    00269                         throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
    00270                 }
    00271                 }
    00272                 }
    00273                 { // ( ... )+
    00274                 int _cnt12=0;
    00275                 for (;;) {
    00276                         if ((LA(1) == NEWLINE)) {
    00277                                 match(NEWLINE);
    00278                         }
    00279                         else {
    00280                                 if ( _cnt12>=1 ) { goto _loop12; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00281                         }
    00282
    00283                         _cnt12++;
    00284                 }
    00285                 _loop12:;
    00286                 }  // ( ... )+
    00287         }
    00288         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00289                 reportError(ex);
    00290                 recover(ex,_tokenSet_2);
    00291         }
    00292         return str;
    00293 }
    00294
    00295 void TestSuiteParser::search() {
    00296
    00297         try {      // for error handling
    00298                 match(SEARCH);
    00299                 { // ( ... )+
    00300                 int _cnt15=0;
    00301                 for (;;) {
    00302                         if ((LA(1) == NEWLINE)) {
    00303                                 match(NEWLINE);
    00304                         }
    00305                         else {
    00306                                 if ( _cnt15>=1 ) { goto _loop15; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00307                         }
    00308
    00309                         _cnt15++;
    00310                 }
    00311                 _loop15:;
    00312                 }  // ( ... )+
    00313         }
    00314         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00315                 reportError(ex);
    00316                 recover(ex,_tokenSet_3);
    00317         }
    00318 }
    00319
    00320 void TestSuiteParser::variablesWithProbs(
    00321         Mers::Models::Base::BaseModel &bm,
    00322                   Mers::Utils::Containers::IntegerArray &probMap,
    00323                   std::vector<double> &probs
    00324 ) {
    00325
    00326         try {      // for error handling
    00327                 { // ( ... )*
    00328                 for (;;) {
    00329                         if ((LA(1) == NAME)) {
    00330                                 variableWithProbs(bm, probMap, probs);
    00331                         }
    00332                         else {
    00333                                 goto _loop24;
    00334                         }
    00335
    00336                 }
    00337                 _loop24:;
    00338                 } // ( ... )*
    00339         }
    00340         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00341                 reportError(ex);
    00342                 recover(ex,_tokenSet_4);
    00343         }
    00344 }
    00345
    00346 void TestSuiteParser::nonSearch() {
    00347
    00348         try {      // for error handling
    00349                 match(NON_SEARCH);
    00350                 { // ( ... )+
    00351                 int _cnt18=0;
    00352                 for (;;) {
    00353                         if ((LA(1) == NEWLINE)) {
    00354                                 match(NEWLINE);
    00355                         }
    00356                         else {
    00357                                 if ( _cnt18>=1 ) { goto _loop18; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00358                         }
    00359
    00360                         _cnt18++;
    00361                 }
    00362                 _loop18:;
    00363                 }  // ( ... )+
    00364         }
    00365         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00366                 reportError(ex);
    00367                 recover(ex,_tokenSet_5);
    00368         }
    00369 }
    00370
    00371 void TestSuiteParser::variables(
    00372         Mers::Models::Base::BaseModel &bm
    00373 ) {
    00374
    00375         try {      // for error handling
    00376                 { // ( ... )*
    00377                 for (;;) {
    00378                         if ((LA(1) == NAME)) {
    00379                                 variable(bm);
    00380                         }
    00381                         else {
    00382                                 goto _loop32;
    00383                         }
    00384
    00385                 }
    00386                 _loop32:;
    00387                 } // ( ... )*
    00388         }
    00389         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00390                 reportError(ex);
    00391                 recover(ex,_tokenSet_6);
    00392         }
    00393 }
    00394
    00395 void TestSuiteParser::cons() {
    00396
    00397         try {      // for error handling
    00398                 match(CONSTRAINT);
    00399                 { // ( ... )+
    00400                 int _cnt21=0;
    00401                 for (;;) {
    00402                         if ((LA(1) == NEWLINE)) {
    00403                                 match(NEWLINE);
    00404                         }
    00405                         else {
    00406                                 if ( _cnt21>=1 ) { goto _loop21; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00407                         }
    00408
    00409                         _cnt21++;
    00410                 }
    00411                 _loop21:;
    00412                 }  // ( ... )+
    00413         }
    00414         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00415                 reportError(ex);
    00416                 recover(ex,_tokenSet_7);
    00417         }
    00418 }
    00419
    00420 Mers::Models::Base::BaseModelSentence *  TestSuiteParser::constraints(
    00421         Mers::Models::Base::BaseModel &bm
    00422 ) {
    00423 #line 423 "TestSuite.g"
    00424         Mers::Models::Base::BaseModelSentence * bmTheory;
    00425 #line 422 "TestSuiteParser.cpp"
    00426
    00427         try {      // for error handling
    00428 #line 426 "TestSuite.g"
    00429
    00430                 // Initialize our return value.
    00431                 bmTheory = new BaseModelSentence(BaseModelSentence::CNF, true);
    00432                 // We store the return value of "constraint" here.
    00433                 BaseModelClause * bmClause;
    00434
    00435 #line 432 "TestSuiteParser.cpp"
    00436                 { // ( ... )*
    00437                 for (;;) {
    00438                         if ((LA(1) == NOT || LA(1) == LBRACKET)) {
    00439                                 bmClause=constraint(bm);
    00440 #line 435 "TestSuite.g"
    00441
    00442                                 // Store this clause in the theory.
    00443                                 bmTheory->pushBack(bmClause);
    00444
    00445 #line 442 "TestSuiteParser.cpp"
    00446                         }
    00447                         else {
    00448                                 goto _loop41;
    00449                         }
    00450
    00451                 }
    00452                 _loop41:;
    00453                 } // ( ... )*
    00454         }
    00455         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00456                 reportError(ex);
    00457                 recover(ex,_tokenSet_1);
    00458         }
    00459         return bmTheory;
    00460 }
    00461
    00462 void TestSuiteParser::startTests(
    00463         Mers::Solvers::SAT::GATSAT::GatsatFactory &gtFactory
    00464 ) {
    00465
    00466         try {      // for error handling
    00467 #line 240 "TestSuite.g"
    00468
    00469                 // Save the initial set of headers.
    00470                 cout << "Test\tSVars\tTVars\tClauses\tRes\tSetup\tSolve\tGStep\tTStep" << endl;
    00471
    00472 #line 469 "TestSuiteParser.cpp"
    00473                 { // ( ... )*
    00474                 for (;;) {
    00475                         if ((LA(1) == NAME || LA(1) == VALUE)) {
    00476                                 test(gtFactory);
    00477                         }
    00478                         else {
    00479                                 goto _loop7;
    00480                         }
    00481
    00482                 }
    00483                 _loop7:;
    00484                 } // ( ... )*
    00485                 match(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
    00486         }
    00487         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00488                 reportError(ex);
    00489                 recover(ex,_tokenSet_0);
    00490         }
    00491 }
    00492
    00493 void TestSuiteParser::test(
    00494         Mers::Solvers::SAT::GATSAT::GatsatFactory &gtFactory
    00495 ) {
    00496
    00497         try {      // for error handling
    00498 #line 253 "TestSuite.g"
    00499
    00500                 // We load all of our model data into this object.
    00501                 BaseModel bm;
    00502                 // A theory of constraints are loaded here.
    00503                 BaseModelSentence * bmTheory;
    00504                 // The name of the test.
    00505                 string testName;
    00506                 // The number of search variables.
    00507                 unsigned int numSVars;
    00508
    00509 #line 506 "TestSuiteParser.cpp"
    00510                 testName=testHeader();
    00511                 search();
    00512                 variables(bm);
    00513 #line 268 "TestSuite.g"
    00514                 numSVars = bm.getVariables()->size();
    00515 #line 512 "TestSuiteParser.cpp"
    00516                 nonSearch();
    00517                 variables(bm);
    00518                 cons();
    00519                 bmTheory=constraints(bm);
    00520 #line 273 "TestSuite.g"
    00521
    00522                 cout << testName << '\t';
    00523                 // A set of search variables for this problem.
    00524                 BaseModelVariableArray searchVars(false);
    00525                 // A set of all variables associated with this problem.
    00526                 BaseModelVariableArray &allVars = *(bm.getVariables());
    00527                 // Copy the relevant variables over to the searchVariables list
    00528                 // - notably one per probability map.
    00529                 for(unsigned int i = 0; i < numSVars; ++i) {
    00530                 // Add this element
    00531                 searchVars.pushBack(allVars[i]);
    00532                 }
    00533
    00534                 // We want to time the amount of time it takes to construct GATSAT
    00535                 clock_t cConstructStart = clock();
    00536
    00537                 // Construct our GATSAT object.
    00538                 GATSAT * gSat = gtFactory.createGatsat(searchVars, allVars, *bmTheory);
    00539
    00540                 // Test GATSAT.
    00541                 testGSUnsat(gSat, cConstructStart, searchVars.size(), allVars.size(),
    00542                 bmTheory->size());
    00543
    00544                 //cerr << bm;
    00545                 //cerr << bmTheory;
    00546                 //cerr << searchVars << endl;
    00547                 //cerr << allVars << endl;
    00548                 // Cleanup our engine.
    00549                 delete gSat;
    00550                 // Cleanup our theory
    00551                 delete bmTheory;
    00552
    00553 #line 550 "TestSuiteParser.cpp"
    00554         }
    00555         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00556                 reportError(ex);
    00557                 recover(ex,_tokenSet_1);
    00558         }
    00559 }
    00560
    00561 void TestSuiteParser::variableWithProbs(
    00562         Mers::Models::Base::BaseModel &bm,
    00563                  Mers::Utils::Containers::IntegerArray &probMap,
    00564                  std::vector<double> &probs
    00565 ) {
    00566         ANTLR_USE_NAMESPACE(antlr)RefToken  varName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00567         ANTLR_USE_NAMESPACE(antlr)RefToken  valName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00568         ANTLR_USE_NAMESPACE(antlr)RefToken  prob = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00569
    00570         try {      // for error handling
    00571 #line 351 "TestSuite.g"
    00572
    00573                 // The domain of values is loaded into this object.
    00574                 BaseModelValueArray domain(true);
    00575                 // Record where we start loading probabilities into the
    00576                 // probs list.
    00577                 probMap.pushBack(probs.size());
    00578
    00579 #line 576 "TestSuiteParser.cpp"
    00580                 varName = LT(1);
    00581                 match(NAME);
    00582                 { // ( ... )+
    00583                 int _cnt27=0;
    00584                 for (;;) {
    00585                         if ((LA(1) == NAME)) {
    00586                                 valName = LT(1);
    00587                                 match(NAME);
    00588                                 prob = LT(1);
    00589                                 match(FLOAT);
    00590 #line 363 "TestSuite.g"
    00591
    00592                                 // Create a new value object for this value.
    00593                                 domain.pushBack(new BaseModelValue(CHARS_OF(valName)));
    00594                                 // Store the probability of this value.
    00595                                 probs.push_back(atof(CHARS_OF(prob)));
    00596
    00597 #line 594 "TestSuiteParser.cpp"
    00598                         }
    00599                         else {
    00600                                 if ( _cnt27>=1 ) { goto _loop27; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00601                         }
    00602
    00603                         _cnt27++;
    00604                 }
    00605                 _loop27:;
    00606                 }  // ( ... )+
    00607                 { // ( ... )+
    00608                 int _cnt29=0;
    00609                 for (;;) {
    00610                         if ((LA(1) == NEWLINE)) {
    00611                                 match(NEWLINE);
    00612                         }
    00613                         else {
    00614                                 if ( _cnt29>=1 ) { goto _loop29; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00615                         }
    00616
    00617                         _cnt29++;
    00618                 }
    00619                 _loop29:;
    00620                 }  // ( ... )+
    00621 #line 373 "TestSuite.g"
    00622
    00623                 // Get the name of the variable.
    00624                 const char * ccVarName = CHARS_OF(varName);
    00625                 // Create a domain for this variable.
    00626                 bm.addDomain(ccVarName, domain);
    00627                 // Create a variable for this variable.
    00628                 bm.addVariable(ccVarName, BaseModelVariable::State,
    00629                 bm.getDomain(ccVarName));
    00630
    00631 #line 628 "TestSuiteParser.cpp"
    00632         }
    00633         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00634                 reportError(ex);
    00635                 recover(ex,_tokenSet_3);
    00636         }
    00637 }
    00638
    00639 void TestSuiteParser::variable(
    00640         Mers::Models::Base::BaseModel &bm
    00641 ) {
    00642         ANTLR_USE_NAMESPACE(antlr)RefToken  varName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00643         ANTLR_USE_NAMESPACE(antlr)RefToken  valName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00644
    00645         try {      // for error handling
    00646 #line 395 "TestSuite.g"
    00647
    00648                 // The domain of values is loaded into this object.
    00649                 BaseModelValueArray domain(true);
    00650
    00651 #line 648 "TestSuiteParser.cpp"
    00652                 varName = LT(1);
    00653                 match(NAME);
    00654                 { // ( ... )+
    00655                 int _cnt36=0;
    00656                 for (;;) {
    00657                         if ((LA(1) == NAME)) {
    00658                                 valName = LT(1);
    00659                                 match(NAME);
    00660                                 {
    00661                                 switch ( LA(1)) {
    00662                                 case FLOAT:
    00663                                 {
    00664                                         match(FLOAT);
    00665                                         break;
    00666                                 }
    00667                                 case NAME:
    00668                                 case NEWLINE:
    00669                                 {
    00670                                         break;
    00671                                 }
    00672                                 default:
    00673                                 {
    00674                                         throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
    00675                                 }
    00676                                 }
    00677                                 }
    00678 #line 403 "TestSuite.g"
    00679
    00680                                 // Create a new value object for this value.
    00681                                 domain.pushBack(new BaseModelValue(CHARS_OF(valName)));
    00682
    00683 #line 680 "TestSuiteParser.cpp"
    00684                         }
    00685                         else {
    00686                                 if ( _cnt36>=1 ) { goto _loop36; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00687                         }
    00688
    00689                         _cnt36++;
    00690                 }
    00691                 _loop36:;
    00692                 }  // ( ... )+
    00693                 { // ( ... )+
    00694                 int _cnt38=0;
    00695                 for (;;) {
    00696                         if ((LA(1) == NEWLINE)) {
    00697                                 match(NEWLINE);
    00698                         }
    00699                         else {
    00700                                 if ( _cnt38>=1 ) { goto _loop38; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00701                         }
    00702
    00703                         _cnt38++;
    00704                 }
    00705                 _loop38:;
    00706                 }  // ( ... )+
    00707 #line 410 "TestSuite.g"
    00708
    00709                 // Get the name of the variable.
    00710                 const char * ccVarName = CHARS_OF(varName);
    00711                 // Create a domain for this variable.
    00712                 bm.addDomain(ccVarName, domain);
    00713                 // Create a variable for this variable.
    00714                 bm.addVariable(ccVarName, BaseModelVariable::State,
    00715                 bm.getDomain(ccVarName));
    00716
    00717 #line 714 "TestSuiteParser.cpp"
    00718         }
    00719         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00720                 reportError(ex);
    00721                 recover(ex,_tokenSet_8);
    00722         }
    00723 }
    00724
    00725 Mers::Models::Base::BaseModelClause *  TestSuiteParser::constraint(
    00726         Mers::Models::Base::BaseModel &bm
    00727 ) {
    00728 #line 444 "TestSuite.g"
    00729         Mers::Models::Base::BaseModelClause * bmClause;
    00730 #line 727 "TestSuiteParser.cpp"
    00731
    00732         try {      // for error handling
    00733 #line 447 "TestSuite.g"
    00734
    00735                 // Initialize our return value.
    00736                 bmClause = new BaseModelClause(BaseModelClause::DISJUNCTIVE, true);
    00737                 // We store the return value of "literal" here.
    00738                 BaseModelAssignment * bmAsg;
    00739
    00740 #line 737 "TestSuiteParser.cpp"
    00741                 { // ( ... )+
    00742                 int _cnt44=0;
    00743                 for (;;) {
    00744                         if ((LA(1) == NOT || LA(1) == LBRACKET)) {
    00745                                 bmAsg=literal(bm);
    00746 #line 456 "TestSuite.g"
    00747
    00748                                 // Store the literal in our clause
    00749                                 bmClause->pushBack(bmAsg);
    00750
    00751 #line 748 "TestSuiteParser.cpp"
    00752                         }
    00753                         else {
    00754                                 if ( _cnt44>=1 ) { goto _loop44; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00755                         }
    00756
    00757                         _cnt44++;
    00758                 }
    00759                 _loop44:;
    00760                 }  // ( ... )+
    00761                 { // ( ... )+
    00762                 int _cnt46=0;
    00763                 for (;;) {
    00764                         if ((LA(1) == NEWLINE)) {
    00765                                 match(NEWLINE);
    00766                         }
    00767                         else {
    00768                                 if ( _cnt46>=1 ) { goto _loop46; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());}
    00769                         }
    00770
    00771                         _cnt46++;
    00772                 }
    00773                 _loop46:;
    00774                 }  // ( ... )+
    00775         }
    00776         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00777                 reportError(ex);
    00778                 recover(ex,_tokenSet_7);
    00779         }
    00780         return bmClause;
    00781 }
    00782
    00783 Mers::Models::Base::BaseModelAssignment *  TestSuiteParser::literal(
    00784         Mers::Models::Base::BaseModel &bm
    00785 ) {
    00786 #line 467 "TestSuite.g"
    00787         Mers::Models::Base::BaseModelAssignment * bmAsg;
    00788 #line 785 "TestSuiteParser.cpp"
    00789         ANTLR_USE_NAMESPACE(antlr)RefToken  varName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00790         ANTLR_USE_NAMESPACE(antlr)RefToken  valName = ANTLR_USE_NAMESPACE(antlr)nullToken;
    00791
    00792         try {      // for error handling
    00793 #line 470 "TestSuite.g"
    00794
    00795                 // The operator type of our assignment.  Defaults to positive.
    00796                 BaseModelAssignment::OperatorType bmaOp = BaseModelAssignment::Positive;
    00797
    00798 #line 795 "TestSuiteParser.cpp"
    00799                 {
    00800                 switch ( LA(1)) {
    00801                 case NOT:
    00802                 {
    00803                         match(NOT);
    00804 #line 477 "TestSuite.g"
    00805
    00806                         // Update our operator.
    00807                         bmaOp = BaseModelAssignment::Negative;
    00808
    00809 #line 806 "TestSuiteParser.cpp"
    00810                         break;
    00811                 }
    00812                 case LBRACKET:
    00813                 {
    00814                         break;
    00815                 }
    00816                 default:
    00817                 {
    00818                         throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
    00819                 }
    00820                 }
    00821                 }
    00822                 match(LBRACKET);
    00823                 varName = LT(1);
    00824                 match(NAME);
    00825                 match(EQUALS);
    00826                 valName = LT(1);
    00827                 match(NAME);
    00828                 match(RBRACKET);
    00829 #line 484 "TestSuite.g"
    00830
    00831                 // Construct our assignment.
    00832                 bmAsg = bm.getAssignment(CHARS_OF(varName), CHARS_OF(valName), bmaOp);
    00833
    00834 #line 831 "TestSuiteParser.cpp"
    00835         }
    00836         catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
    00837                 reportError(ex);
    00838                 recover(ex,_tokenSet_9);
    00839         }
    00840         return bmAsg;
    00841 }
    00842
    00843 void TestSuiteParser::initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& )
    00844 {
    00845 }
    00846 const char* TestSuiteParser::tokenNames[] = {
    00847         "<0>",
    00848         "EOF",
    00849         "<2>",
    00850         "NULL_TREE_LOOKAHEAD",
    00851         "NAME",
    00852         "VALUE",
    00853         "NEWLINE",
    00854         "\"Search\"",
    00855         "\"NonSearch\"",
    00856         "\"Constraints\"",
    00857         "FLOAT",
    00858         "NOT",
    00859         "LBRACKET",
    00860         "EQUALS",
    00861         "RBRACKET",
    00862         "NUMBER",
    00863         "WHITESPACE",
    00864         "WS",
    00865         0
    00866 };
    00867
    00868 const unsigned long TestSuiteParser::_tokenSet_0_data_[] = { 2UL, 0UL, 0UL, 0UL };
    00869 // EOF
    00870 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_0(_tokenSet_0_data_,4);
    00871 const unsigned long TestSuiteParser::_tokenSet_1_data_[] = { 50UL, 0UL, 0UL, 0UL };
    00872 // EOF NAME VALUE
    00873 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_1(_tokenSet_1_data_,4);
    00874 const unsigned long TestSuiteParser::_tokenSet_2_data_[] = { 128UL, 0UL, 0UL, 0UL };
    00875 // "Search"
    00876 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_2(_tokenSet_2_data_,4);
    00877 const unsigned long TestSuiteParser::_tokenSet_3_data_[] = { 272UL, 0UL, 0UL, 0UL };
    00878 // NAME "NonSearch"
    00879 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_3(_tokenSet_3_data_,4);
    00880 const unsigned long TestSuiteParser::_tokenSet_4_data_[] = { 256UL, 0UL, 0UL, 0UL };
    00881 // "NonSearch"
    00882 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_4(_tokenSet_4_data_,4);
    00883 const unsigned long TestSuiteParser::_tokenSet_5_data_[] = { 528UL, 0UL, 0UL, 0UL };
    00884 // NAME "Constraints"
    00885 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_5(_tokenSet_5_data_,4);
    00886 const unsigned long TestSuiteParser::_tokenSet_6_data_[] = { 768UL, 0UL, 0UL, 0UL };
    00887 // "NonSearch" "Constraints"
    00888 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_6(_tokenSet_6_data_,4);
    00889 const unsigned long TestSuiteParser::_tokenSet_7_data_[] = { 6194UL, 0UL, 0UL, 0UL };
    00890 // EOF NAME VALUE NOT LBRACKET
    00891 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_7(_tokenSet_7_data_,4);
    00892 const unsigned long TestSuiteParser::_tokenSet_8_data_[] = { 784UL, 0UL, 0UL, 0UL };
    00893 // NAME "NonSearch" "Constraints"
    00894 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_8(_tokenSet_8_data_,4);
    00895 const unsigned long TestSuiteParser::_tokenSet_9_data_[] = { 6208UL, 0UL, 0UL, 0UL };
    00896 // NEWLINE NOT LBRACKET
    00897 const ANTLR_USE_NAMESPACE(antlr)BitSet TestSuiteParser::_tokenSet_9(_tokenSet_9_data_,4);
    00898
    00899
    00900 ANTLR_END_NAMESPACE
    00901 ANTLR_END_NAMESPACE
    00902 ANTLR_END_NAMESPACE
    00903 ANTLR_END_NAMESPACE