StationLexer.cpp

Go to the documentation of this file.
00001 /* $ANTLR 2.7.6 (20070220): "StationParser.g" -> "StationLexer.cpp"$ */
00002 #include "StationLexer.hpp"
00003 #include <antlr/CharBuffer.hpp>
00004 #include <antlr/TokenStreamException.hpp>
00005 #include <antlr/TokenStreamIOException.hpp>
00006 #include <antlr/TokenStreamRecognitionException.hpp>
00007 #include <antlr/CharStreamException.hpp>
00008 #include <antlr/CharStreamIOException.hpp>
00009 #include <antlr/NoViableAltForCharException.hpp>
00010 
00011 #line 1 "StationParser.g"
00012 #line 13 "StationLexer.cpp"
00013 StationLexer::StationLexer(std::istream& in)
00014         : antlr::CharScanner(new antlr::CharBuffer(in),false)
00015 {
00016         initLiterals();
00017 }
00018 
00019 StationLexer::StationLexer(antlr::InputBuffer& ib)
00020         : antlr::CharScanner(ib,false)
00021 {
00022         initLiterals();
00023 }
00024 
00025 StationLexer::StationLexer(const antlr::LexerSharedInputState& state)
00026         : antlr::CharScanner(state,false)
00027 {
00028         initLiterals();
00029 }
00030 
00031 void StationLexer::initLiterals()
00032 {
00033 }
00034 
00035 antlr::RefToken StationLexer::nextToken()
00036 {
00037         antlr::RefToken theRetToken;
00038         for (;;) {
00039                 antlr::RefToken theRetToken;
00040                 int _ttype = antlr::Token::INVALID_TYPE;
00041                 resetText();
00042                 try {   // for lexical and char stream error handling
00043                         switch ( LA(1)) {
00044                         case 0x9 /* '\t' */ :
00045                         case 0x20 /* ' ' */ :
00046                         {
00047                                 mWS(true);
00048                                 theRetToken=_returnToken;
00049                                 break;
00050                         }
00051                         case 0x2b /* '+' */ :
00052                         case 0x2d /* '-' */ :
00053                         case 0x30 /* '0' */ :
00054                         case 0x31 /* '1' */ :
00055                         case 0x32 /* '2' */ :
00056                         case 0x33 /* '3' */ :
00057                         case 0x34 /* '4' */ :
00058                         case 0x35 /* '5' */ :
00059                         case 0x36 /* '6' */ :
00060                         case 0x37 /* '7' */ :
00061                         case 0x38 /* '8' */ :
00062                         case 0x39 /* '9' */ :
00063                         case 0x61 /* 'a' */ :
00064                         case 0x62 /* 'b' */ :
00065                         case 0x63 /* 'c' */ :
00066                         case 0x64 /* 'd' */ :
00067                         case 0x65 /* 'e' */ :
00068                         case 0x66 /* 'f' */ :
00069                         case 0x67 /* 'g' */ :
00070                         case 0x68 /* 'h' */ :
00071                         case 0x69 /* 'i' */ :
00072                         case 0x6a /* 'j' */ :
00073                         case 0x6b /* 'k' */ :
00074                         case 0x6c /* 'l' */ :
00075                         case 0x6d /* 'm' */ :
00076                         case 0x6e /* 'n' */ :
00077                         case 0x6f /* 'o' */ :
00078                         case 0x70 /* 'p' */ :
00079                         case 0x71 /* 'q' */ :
00080                         case 0x72 /* 'r' */ :
00081                         case 0x73 /* 's' */ :
00082                         case 0x74 /* 't' */ :
00083                         case 0x75 /* 'u' */ :
00084                         case 0x76 /* 'v' */ :
00085                         case 0x77 /* 'w' */ :
00086                         case 0x78 /* 'x' */ :
00087                         case 0x79 /* 'y' */ :
00088                         case 0x7a /* 'z' */ :
00089                         {
00090                                 mENTRY(true);
00091                                 theRetToken=_returnToken;
00092                                 break;
00093                         }
00094                         case 0x23 /* '#' */ :
00095                         {
00096                                 mCOMMENT(true);
00097                                 theRetToken=_returnToken;
00098                                 break;
00099                         }
00100                         case 0xa /* '\n' */ :
00101                         case 0xd /* '\r' */ :
00102                         {
00103                                 mNEWLINE(true);
00104                                 theRetToken=_returnToken;
00105                                 break;
00106                         }
00107                         default:
00108                         {
00109                                 if (LA(1)==EOF_CHAR)
00110                                 {
00111                                         uponEOF();
00112                                         _returnToken = makeToken(antlr::Token::EOF_TYPE);
00113                                 }
00114                                 else {throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
00115                         }
00116                         }
00117                         if ( !_returnToken )
00118                                 goto tryAgain; // found SKIP token
00119 
00120                         _ttype = _returnToken->getType();
00121                         _ttype = testLiteralsTable(_ttype);
00122                         _returnToken->setType(_ttype);
00123                         return _returnToken;
00124                 }
00125                 catch (antlr::RecognitionException& e) {
00126                                 throw antlr::TokenStreamRecognitionException(e);
00127                 }
00128                 catch (antlr::CharStreamIOException& csie) {
00129                         throw antlr::TokenStreamIOException(csie.io);
00130                 }
00131                 catch (antlr::CharStreamException& cse) {
00132                         throw antlr::TokenStreamException(cse.getMessage());
00133                 }
00134 tryAgain:;
00135         }
00136 }
00137 
00138 void StationLexer::mWS(bool _createToken) {
00139         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00140         _ttype = WS;
00141         std::string::size_type _saveIndex;
00142         
00143         { // ( ... )+
00144         int _cnt11=0;
00145         for (;;) {
00146                 switch ( LA(1)) {
00147                 case 0x20 /* ' ' */ :
00148                 {
00149                         match(' ' /* charlit */ );
00150                         break;
00151                 }
00152                 case 0x9 /* '\t' */ :
00153                 {
00154                         match('\t' /* charlit */ );
00155                         break;
00156                 }
00157                 default:
00158                 {
00159                         if ( _cnt11>=1 ) { goto _loop11; } else {throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
00160                 }
00161                 }
00162                 _cnt11++;
00163         }
00164         _loop11:;
00165         }  // ( ... )+
00166 #line 62 "StationParser.g"
00167         _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
00168 #line 169 "StationLexer.cpp"
00169         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00170            _token = makeToken(_ttype);
00171            _token->setText(text.substr(_begin, text.length()-_begin));
00172         }
00173         _returnToken = _token;
00174         _saveIndex=0;
00175 }
00176 
00177 void StationLexer::mENTRY(bool _createToken) {
00178         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00179         _ttype = ENTRY;
00180         std::string::size_type _saveIndex;
00181         
00182         {
00183         switch ( LA(1)) {
00184         case 0x2b /* '+' */ :
00185         {
00186                 mPLUS(false);
00187                 break;
00188         }
00189         case 0x2d /* '-' */ :
00190         {
00191                 mMINUS(false);
00192                 break;
00193         }
00194         case 0x61 /* 'a' */ :
00195         case 0x62 /* 'b' */ :
00196         case 0x63 /* 'c' */ :
00197         case 0x64 /* 'd' */ :
00198         case 0x65 /* 'e' */ :
00199         case 0x66 /* 'f' */ :
00200         case 0x67 /* 'g' */ :
00201         case 0x68 /* 'h' */ :
00202         case 0x69 /* 'i' */ :
00203         case 0x6a /* 'j' */ :
00204         case 0x6b /* 'k' */ :
00205         case 0x6c /* 'l' */ :
00206         case 0x6d /* 'm' */ :
00207         case 0x6e /* 'n' */ :
00208         case 0x6f /* 'o' */ :
00209         case 0x70 /* 'p' */ :
00210         case 0x71 /* 'q' */ :
00211         case 0x72 /* 'r' */ :
00212         case 0x73 /* 's' */ :
00213         case 0x74 /* 't' */ :
00214         case 0x75 /* 'u' */ :
00215         case 0x76 /* 'v' */ :
00216         case 0x77 /* 'w' */ :
00217         case 0x78 /* 'x' */ :
00218         case 0x79 /* 'y' */ :
00219         case 0x7a /* 'z' */ :
00220         {
00221                 mCHAR(false);
00222                 break;
00223         }
00224         case 0x30 /* '0' */ :
00225         case 0x31 /* '1' */ :
00226         case 0x32 /* '2' */ :
00227         case 0x33 /* '3' */ :
00228         case 0x34 /* '4' */ :
00229         case 0x35 /* '5' */ :
00230         case 0x36 /* '6' */ :
00231         case 0x37 /* '7' */ :
00232         case 0x38 /* '8' */ :
00233         case 0x39 /* '9' */ :
00234         {
00235                 mDIGIT(false);
00236                 break;
00237         }
00238         default:
00239         {
00240                 throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
00241         }
00242         }
00243         }
00244         { // ( ... )*
00245         for (;;) {
00246                 switch ( LA(1)) {
00247                 case 0x61 /* 'a' */ :
00248                 case 0x62 /* 'b' */ :
00249                 case 0x63 /* 'c' */ :
00250                 case 0x64 /* 'd' */ :
00251                 case 0x65 /* 'e' */ :
00252                 case 0x66 /* 'f' */ :
00253                 case 0x67 /* 'g' */ :
00254                 case 0x68 /* 'h' */ :
00255                 case 0x69 /* 'i' */ :
00256                 case 0x6a /* 'j' */ :
00257                 case 0x6b /* 'k' */ :
00258                 case 0x6c /* 'l' */ :
00259                 case 0x6d /* 'm' */ :
00260                 case 0x6e /* 'n' */ :
00261                 case 0x6f /* 'o' */ :
00262                 case 0x70 /* 'p' */ :
00263                 case 0x71 /* 'q' */ :
00264                 case 0x72 /* 'r' */ :
00265                 case 0x73 /* 's' */ :
00266                 case 0x74 /* 't' */ :
00267                 case 0x75 /* 'u' */ :
00268                 case 0x76 /* 'v' */ :
00269                 case 0x77 /* 'w' */ :
00270                 case 0x78 /* 'x' */ :
00271                 case 0x79 /* 'y' */ :
00272                 case 0x7a /* 'z' */ :
00273                 {
00274                         mCHAR(false);
00275                         break;
00276                 }
00277                 case 0x30 /* '0' */ :
00278                 case 0x31 /* '1' */ :
00279                 case 0x32 /* '2' */ :
00280                 case 0x33 /* '3' */ :
00281                 case 0x34 /* '4' */ :
00282                 case 0x35 /* '5' */ :
00283                 case 0x36 /* '6' */ :
00284                 case 0x37 /* '7' */ :
00285                 case 0x38 /* '8' */ :
00286                 case 0x39 /* '9' */ :
00287                 {
00288                         mDIGIT(false);
00289                         break;
00290                 }
00291                 case 0x23 /* '#' */ :
00292                 case 0x24 /* '$' */ :
00293                 case 0x25 /* '%' */ :
00294                 case 0x26 /* '&' */ :
00295                 case 0x27 /* '\'' */ :
00296                 case 0x28 /* '(' */ :
00297                 case 0x29 /* ')' */ :
00298                 case 0x2a /* '*' */ :
00299                 case 0x2c /* ',' */ :
00300                 case 0x2e /* '.' */ :
00301                 case 0x2f /* '/' */ :
00302                 case 0x3a /* ':' */ :
00303                 case 0x3b /* ';' */ :
00304                 case 0x3c /* '<' */ :
00305                 case 0x3f /* '?' */ :
00306                 case 0x40 /* '@' */ :
00307                 case 0x5b /* '[' */ :
00308                 case 0x5d /* ']' */ :
00309                 case 0x5e /* '^' */ :
00310                 case 0x5f /* '_' */ :
00311                 case 0x7b /* '{' */ :
00312                 case 0x7c /* '|' */ :
00313                 case 0x7d /* '}' */ :
00314                 case 0x7e /* '~' */ :
00315                 {
00316                         mOTHER(false);
00317                         break;
00318                 }
00319                 case 0x2b /* '+' */ :
00320                 {
00321                         mPLUS(false);
00322                         break;
00323                 }
00324                 case 0x2d /* '-' */ :
00325                 {
00326                         mMINUS(false);
00327                         break;
00328                 }
00329                 default:
00330                 {
00331                         goto _loop15;
00332                 }
00333                 }
00334         }
00335         _loop15:;
00336         } // ( ... )*
00337         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00338            _token = makeToken(_ttype);
00339            _token->setText(text.substr(_begin, text.length()-_begin));
00340         }
00341         _returnToken = _token;
00342         _saveIndex=0;
00343 }
00344 
00345 void StationLexer::mPLUS(bool _createToken) {
00346         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00347         _ttype = PLUS;
00348         std::string::size_type _saveIndex;
00349         
00350         match('+' /* charlit */ );
00351         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00352            _token = makeToken(_ttype);
00353            _token->setText(text.substr(_begin, text.length()-_begin));
00354         }
00355         _returnToken = _token;
00356         _saveIndex=0;
00357 }
00358 
00359 void StationLexer::mMINUS(bool _createToken) {
00360         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00361         _ttype = MINUS;
00362         std::string::size_type _saveIndex;
00363         
00364         match('-' /* charlit */ );
00365         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00366            _token = makeToken(_ttype);
00367            _token->setText(text.substr(_begin, text.length()-_begin));
00368         }
00369         _returnToken = _token;
00370         _saveIndex=0;
00371 }
00372 
00373 void StationLexer::mCHAR(bool _createToken) {
00374         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00375         _ttype = CHAR;
00376         std::string::size_type _saveIndex;
00377         
00378         {
00379         matchRange('a','z');
00380         }
00381         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00382            _token = makeToken(_ttype);
00383            _token->setText(text.substr(_begin, text.length()-_begin));
00384         }
00385         _returnToken = _token;
00386         _saveIndex=0;
00387 }
00388 
00389 void StationLexer::mDIGIT(bool _createToken) {
00390         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00391         _ttype = DIGIT;
00392         std::string::size_type _saveIndex;
00393         
00394         matchRange('0','9');
00395         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00396            _token = makeToken(_ttype);
00397            _token->setText(text.substr(_begin, text.length()-_begin));
00398         }
00399         _returnToken = _token;
00400         _saveIndex=0;
00401 }
00402 
00403 void StationLexer::mOTHER(bool _createToken) {
00404         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00405         _ttype = OTHER;
00406         std::string::size_type _saveIndex;
00407         
00408         switch ( LA(1)) {
00409         case 0x27 /* '\'' */ :
00410         {
00411                 match('\'' /* charlit */ );
00412                 break;
00413         }
00414         case 0x23 /* '#' */ :
00415         {
00416                 match('#' /* charlit */ );
00417                 break;
00418         }
00419         case 0x24 /* '$' */ :
00420         {
00421                 match('$' /* charlit */ );
00422                 break;
00423         }
00424         case 0x25 /* '%' */ :
00425         {
00426                 match('%' /* charlit */ );
00427                 break;
00428         }
00429         case 0x26 /* '&' */ :
00430         {
00431                 match('&' /* charlit */ );
00432                 break;
00433         }
00434         case 0x28 /* '(' */ :
00435         {
00436                 match('(' /* charlit */ );
00437                 break;
00438         }
00439         case 0x29 /* ')' */ :
00440         {
00441                 match(')' /* charlit */ );
00442                 break;
00443         }
00444         case 0x2a /* '*' */ :
00445         {
00446                 match('*' /* charlit */ );
00447                 break;
00448         }
00449         case 0x2c /* ',' */ :
00450         {
00451                 match(',' /* charlit */ );
00452                 break;
00453         }
00454         case 0x2e /* '.' */ :
00455         {
00456                 match('.' /* charlit */ );
00457                 break;
00458         }
00459         case 0x2f /* '/' */ :
00460         {
00461                 match('/' /* charlit */ );
00462                 break;
00463         }
00464         case 0x3a /* ':' */ :
00465         {
00466                 match(':' /* charlit */ );
00467                 break;
00468         }
00469         case 0x3b /* ';' */ :
00470         {
00471                 match(';' /* charlit */ );
00472                 break;
00473         }
00474         case 0x3c /* '<' */ :
00475         {
00476                 match('<' /* charlit */ );
00477                 break;
00478         }
00479         case 0x3f /* '?' */ :
00480         {
00481                 match('?' /* charlit */ );
00482                 break;
00483         }
00484         case 0x40 /* '@' */ :
00485         {
00486                 match('@' /* charlit */ );
00487                 break;
00488         }
00489         case 0x5b /* '[' */ :
00490         {
00491                 match('[' /* charlit */ );
00492                 break;
00493         }
00494         case 0x5d /* ']' */ :
00495         {
00496                 match(']' /* charlit */ );
00497                 break;
00498         }
00499         case 0x5e /* '^' */ :
00500         {
00501                 match('^' /* charlit */ );
00502                 break;
00503         }
00504         case 0x5f /* '_' */ :
00505         {
00506                 match('_' /* charlit */ );
00507                 break;
00508         }
00509         case 0x7b /* '{' */ :
00510         {
00511                 match('{' /* charlit */ );
00512                 break;
00513         }
00514         case 0x7c /* '|' */ :
00515         {
00516                 match('|' /* charlit */ );
00517                 break;
00518         }
00519         case 0x7d /* '}' */ :
00520         {
00521                 match('}' /* charlit */ );
00522                 break;
00523         }
00524         case 0x7e /* '~' */ :
00525         {
00526                 match('~' /* charlit */ );
00527                 break;
00528         }
00529         default:
00530         {
00531                 throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
00532         }
00533         }
00534         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00535            _token = makeToken(_ttype);
00536            _token->setText(text.substr(_begin, text.length()-_begin));
00537         }
00538         _returnToken = _token;
00539         _saveIndex=0;
00540 }
00541 
00542 void StationLexer::mCOMMENT(bool _createToken) {
00543         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00544         _ttype = COMMENT;
00545         std::string::size_type _saveIndex;
00546         
00547         match('#' /* charlit */ );
00548         { // ( ... )*
00549         for (;;) {
00550                 if ((_tokenSet_0.member(LA(1)))) {
00551                         {
00552                         match(_tokenSet_0);
00553                         }
00554                 }
00555                 else {
00556                         goto _loop19;
00557                 }
00558                 
00559         }
00560         _loop19:;
00561         } // ( ... )*
00562         mNEWLINE(false);
00563 #line 74 "StationParser.g"
00564         
00565                                 _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
00566                         
00567 #line 568 "StationLexer.cpp"
00568         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00569            _token = makeToken(_ttype);
00570            _token->setText(text.substr(_begin, text.length()-_begin));
00571         }
00572         _returnToken = _token;
00573         _saveIndex=0;
00574 }
00575 
00576 void StationLexer::mNEWLINE(bool _createToken) {
00577         int _ttype; antlr::RefToken _token; std::string::size_type _begin = text.length();
00578         _ttype = NEWLINE;
00579         std::string::size_type _saveIndex;
00580         
00581         {
00582         switch ( LA(1)) {
00583         case 0xa /* '\n' */ :
00584         {
00585                 match('\n' /* charlit */ );
00586                 break;
00587         }
00588         case 0xd /* '\r' */ :
00589         {
00590                 match('\r' /* charlit */ );
00591                 match('\n' /* charlit */ );
00592                 break;
00593         }
00594         default:
00595         {
00596                 throw antlr::NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
00597         }
00598         }
00599         }
00600 #line 82 "StationParser.g"
00601         newline();
00602 #line 603 "StationLexer.cpp"
00603         if ( _createToken && _token==antlr::nullToken && _ttype!=antlr::Token::SKIP ) {
00604            _token = makeToken(_ttype);
00605            _token->setText(text.substr(_begin, text.length()-_begin));
00606         }
00607         _returnToken = _token;
00608         _saveIndex=0;
00609 }
00610 
00611 
00612 const unsigned long StationLexer::_tokenSet_0_data_[] = { 4294958079UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL };
00613 // 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 
00614 const antlr::BitSet StationLexer::_tokenSet_0(_tokenSet_0_data_,8);
00615 

Generated on Thu Nov 22 13:58:27 2007 for GPLIB++ by  doxygen 1.5.1