[antlr-interest] How to redirect the input stream?

Frank Yue professoryue at gmail.com
Fri May 11 02:29:26 PDT 2007


HI, all !  I want to ask lexer  to scan another character stream
when EOF is reached . Documents provied by www.antlr.org give me
little information about how to redirect the  character stream.

               default:
                       {
                               if (LA(1)==EOF_CHAR)
                               {
                                       uponEOF();
                                       _returnToken =
makeToken(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
                               }

                               else
                              {
                                consume();
                                goto tryAgain;
                               }
                       }


detail of uponEOF( ) from CharScanner.hpp:
       virtual void uponEOF()
       {
       }
   note:uponEOF( ) does nothing in here .

       virtual RefToken makeToken(int t)
       {
               RefToken tok = tokenFactory();
               tok->setType(t);
               tok->setColumn(inputState->tokenStartColumn);
               tok->setLine(inputState->tokenStartLine);
               return tok;
       }
  note: Create a new RefToken of type t

I am looking forward to your early reply .


More information about the antlr-interest mailing list