00001
00002 #include "CPTensorConfParser.hpp"
00003 #include <antlr/NoViableAltException.hpp>
00004 #include <antlr/SemanticException.hpp>
00005 #include <antlr/ASTFactory.hpp>
00006 #line 1 "CPTensorConf.g"
00007 #line 8 "CPTensorConfParser.cpp"
00008 CPTensorConfParser::CPTensorConfParser(antlr::TokenBuffer& tokenBuf, int k)
00009 : antlr::LLkParser(tokenBuf,k)
00010 {
00011 }
00012
00013 CPTensorConfParser::CPTensorConfParser(antlr::TokenBuffer& tokenBuf)
00014 : antlr::LLkParser(tokenBuf,10)
00015 {
00016 }
00017
00018 CPTensorConfParser::CPTensorConfParser(antlr::TokenStream& lexer, int k)
00019 : antlr::LLkParser(lexer,k)
00020 {
00021 }
00022
00023 CPTensorConfParser::CPTensorConfParser(antlr::TokenStream& lexer)
00024 : antlr::LLkParser(lexer,10)
00025 {
00026 }
00027
00028 CPTensorConfParser::CPTensorConfParser(const antlr::ParserSharedInputState& state)
00029 : antlr::LLkParser(state,10)
00030 {
00031 }
00032
00033 void CPTensorConfParser::configentry() {
00034
00035 try {
00036 {
00037 switch ( LA(1)) {
00038 case SCALEFACTORT:
00039 {
00040 match(SCALEFACTORT);
00041 match(EQUAL);
00042 scalefactor=numvalue();
00043 break;
00044 }
00045 case NORMALIZET:
00046 {
00047 match(NORMALIZET);
00048 match(EQUAL);
00049 normalize=boolvalue();
00050 break;
00051 }
00052 case WRITETENSORT:
00053 {
00054 match(WRITETENSORT);
00055 match(EQUAL);
00056 writetensor=boolvalue();
00057 break;
00058 }
00059 case WRITESERIALPARALLELT:
00060 {
00061 match(WRITESERIALPARALLELT);
00062 match(EQUAL);
00063 writeserialparallel=boolvalue();
00064 break;
00065 }
00066 case CALCERRT:
00067 {
00068 match(CALCERRT);
00069 match(EQUAL);
00070 calcerr=boolvalue();
00071 break;
00072 }
00073 default:
00074 {
00075 throw antlr::NoViableAltException(LT(1), getFilename());
00076 }
00077 }
00078 }
00079 }
00080 catch (antlr::RecognitionException& ex) {
00081 if( inputState->guessing == 0 ) {
00082 reportError(ex);
00083 recover(ex,_tokenSet_0);
00084 } else {
00085 throw;
00086 }
00087 }
00088 }
00089
00090 double CPTensorConfParser::numvalue() {
00091 #line 48 "CPTensorConf.g"
00092 double r;
00093 #line 94 "CPTensorConfParser.cpp"
00094 antlr::RefToken currvalue = antlr::nullToken;
00095
00096 try {
00097 currvalue = LT(1);
00098 match(NUMBER);
00099 if ( inputState->guessing==0 ) {
00100 #line 49 "CPTensorConf.g"
00101 r = atof(currvalue->getText().c_str());
00102 #line 103 "CPTensorConfParser.cpp"
00103 }
00104 }
00105 catch (antlr::RecognitionException& ex) {
00106 if( inputState->guessing == 0 ) {
00107 reportError(ex);
00108 recover(ex,_tokenSet_0);
00109 } else {
00110 throw;
00111 }
00112 }
00113 return r;
00114 }
00115
00116 bool CPTensorConfParser::boolvalue() {
00117 #line 52 "CPTensorConf.g"
00118 bool r;
00119 #line 120 "CPTensorConfParser.cpp"
00120
00121 try {
00122 {
00123 switch ( LA(1)) {
00124 case TRUE:
00125 {
00126 match(TRUE);
00127 if ( inputState->guessing==0 ) {
00128 #line 53 "CPTensorConf.g"
00129 r = true;
00130 #line 131 "CPTensorConfParser.cpp"
00131 }
00132 break;
00133 }
00134 case FALSE:
00135 {
00136 match(FALSE);
00137 if ( inputState->guessing==0 ) {
00138 #line 53 "CPTensorConf.g"
00139 r = false;
00140 #line 141 "CPTensorConfParser.cpp"
00141 }
00142 break;
00143 }
00144 default:
00145 {
00146 throw antlr::NoViableAltException(LT(1), getFilename());
00147 }
00148 }
00149 }
00150 }
00151 catch (antlr::RecognitionException& ex) {
00152 if( inputState->guessing == 0 ) {
00153 reportError(ex);
00154 recover(ex,_tokenSet_0);
00155 } else {
00156 throw;
00157 }
00158 }
00159 return r;
00160 }
00161
00162 void CPTensorConfParser::configfile() {
00163 #line 38 "CPTensorConf.g"
00164
00165 scalefactor = 5;
00166 normalize = true;
00167 writetensor = false;
00168 writeserialparallel = false;
00169 calcerr = false;
00170
00171 #line 172 "CPTensorConfParser.cpp"
00172
00173 try {
00174 {
00175 int _cnt18=0;
00176 for (;;) {
00177 if ((_tokenSet_1.member(LA(1)))) {
00178 configentry();
00179 {
00180 if ((LA(1) == COMMENT) && (_tokenSet_0.member(LA(2))) && (LA(3) == antlr::Token::EOF_TYPE || LA(3) == EQUAL || LA(3) == COMMENT) && (_tokenSet_2.member(LA(4))) && (_tokenSet_0.member(LA(5))) && (_tokenSet_3.member(LA(6))) && (_tokenSet_4.member(LA(7))) && (_tokenSet_5.member(LA(8))) && (_tokenSet_3.member(LA(9))) && (_tokenSet_6.member(LA(10)))) {
00181 match(COMMENT);
00182 }
00183 else if ((_tokenSet_0.member(LA(1))) && (LA(2) == antlr::Token::EOF_TYPE || LA(2) == EQUAL || LA(2) == COMMENT) && (_tokenSet_2.member(LA(3))) && (_tokenSet_0.member(LA(4))) && (_tokenSet_3.member(LA(5))) && (_tokenSet_4.member(LA(6))) && (_tokenSet_5.member(LA(7))) && (_tokenSet_3.member(LA(8))) && (_tokenSet_6.member(LA(9))) && (_tokenSet_6.member(LA(10)))) {
00184 }
00185 else {
00186 throw antlr::NoViableAltException(LT(1), getFilename());
00187 }
00188
00189 }
00190 }
00191 else {
00192 if ( _cnt18>=1 ) { goto _loop18; } else {throw antlr::NoViableAltException(LT(1), getFilename());}
00193 }
00194
00195 _cnt18++;
00196 }
00197 _loop18:;
00198 }
00199 {
00200 for (;;) {
00201 if ((LA(1) == COMMENT)) {
00202 match(COMMENT);
00203 }
00204 else {
00205 goto _loop20;
00206 }
00207
00208 }
00209 _loop20:;
00210 }
00211 match(antlr::Token::EOF_TYPE);
00212 }
00213 catch (antlr::RecognitionException& ex) {
00214 if( inputState->guessing == 0 ) {
00215 reportError(ex);
00216 recover(ex,_tokenSet_7);
00217 } else {
00218 throw;
00219 }
00220 }
00221 }
00222
00223 std::string CPTensorConfParser::stringvalue() {
00224 #line 56 "CPTensorConf.g"
00225 std::string r;
00226 #line 227 "CPTensorConfParser.cpp"
00227 antlr::RefToken currvalue = antlr::nullToken;
00228
00229 try {
00230 currvalue = LT(1);
00231 match(STRING);
00232 if ( inputState->guessing==0 ) {
00233 #line 57 "CPTensorConf.g"
00234 r = currvalue->getText();
00235 #line 236 "CPTensorConfParser.cpp"
00236 }
00237 }
00238 catch (antlr::RecognitionException& ex) {
00239 if( inputState->guessing == 0 ) {
00240 reportError(ex);
00241 recover(ex,_tokenSet_7);
00242 } else {
00243 throw;
00244 }
00245 }
00246 return r;
00247 }
00248
00249 void CPTensorConfParser::initializeASTFactory( antlr::ASTFactory& )
00250 {
00251 }
00252 const char* CPTensorConfParser::tokenNames[] = {
00253 "<0>",
00254 "EOF",
00255 "<2>",
00256 "NULL_TREE_LOOKAHEAD",
00257 "SCALEFACTORT",
00258 "EQUAL",
00259 "NUMBER",
00260 "NORMALIZET",
00261 "WRITETENSORT",
00262 "WRITESERIALPARALLELT",
00263 "CALCERRT",
00264 "COMMENT",
00265 "TRUE",
00266 "FALSE",
00267 "STRING",
00268 "WS",
00269 "NEWLINE",
00270 "REAL",
00271 "INT",
00272 "DIGIT",
00273 "CHAR",
00274 "OTHER",
00275 0
00276 };
00277
00278 const unsigned long CPTensorConfParser::_tokenSet_0_data_[] = { 3986UL, 0UL, 0UL, 0UL };
00279
00280
00281 const antlr::BitSet CPTensorConfParser::_tokenSet_0(_tokenSet_0_data_,4);
00282 const unsigned long CPTensorConfParser::_tokenSet_1_data_[] = { 1936UL, 0UL, 0UL, 0UL };
00283
00284 const antlr::BitSet CPTensorConfParser::_tokenSet_1(_tokenSet_1_data_,4);
00285 const unsigned long CPTensorConfParser::_tokenSet_2_data_[] = { 14402UL, 0UL, 0UL, 0UL };
00286
00287 const antlr::BitSet CPTensorConfParser::_tokenSet_2(_tokenSet_2_data_,4);
00288 const unsigned long CPTensorConfParser::_tokenSet_3_data_[] = { 4018UL, 0UL, 0UL, 0UL };
00289
00290
00291 const antlr::BitSet CPTensorConfParser::_tokenSet_3(_tokenSet_3_data_,4);
00292 const unsigned long CPTensorConfParser::_tokenSet_4_data_[] = { 14434UL, 0UL, 0UL, 0UL };
00293
00294 const antlr::BitSet CPTensorConfParser::_tokenSet_4(_tokenSet_4_data_,4);
00295 const unsigned long CPTensorConfParser::_tokenSet_5_data_[] = { 16338UL, 0UL, 0UL, 0UL };
00296
00297
00298 const antlr::BitSet CPTensorConfParser::_tokenSet_5(_tokenSet_5_data_,4);
00299 const unsigned long CPTensorConfParser::_tokenSet_6_data_[] = { 16370UL, 0UL, 0UL, 0UL };
00300
00301
00302 const antlr::BitSet CPTensorConfParser::_tokenSet_6(_tokenSet_6_data_,4);
00303 const unsigned long CPTensorConfParser::_tokenSet_7_data_[] = { 2UL, 0UL, 0UL, 0UL };
00304
00305 const antlr::BitSet CPTensorConfParser::_tokenSet_7(_tokenSet_7_data_,4);
00306
00307