private Token scanText ( int c ) throws IOException { // Read first character in text so that source info does not include // tags. c = mSource . read ( ) ; int startLine = mSource . getLineNumber ( ) ; int startPos = mSource . getStartPosition ( ) ; int endPos = mSource . getEndPosition ( ) ; StringBuilder buf = new StringBuilder ( 256 ) ; while ( c != - 1 ) { if ( c == SourceReader . ENTER_CODE ) { if ( mEmitSpecial ) { mLookahead . push ( makeStringToken ( Token . ENTER_CODE , mSource . getBeginTag ( ) ) ) ; } break ; } else if ( c == SourceReader . ENTER_TEXT ) { buf . append ( mSource . getEndTag ( ) ) ; } else { buf . append ( ( char ) c ) ; } if ( mSource . peek ( ) < 0 ) { endPos = mSource . getEndPosition ( ) ; } c = mSource . read ( ) ; } if ( c == - 1 ) { // If the last token in the source file is text, trim all trailing // whitespace from it. int length = buf . length ( ) ; int i ; for ( i = length - 1 ; i >= 0 ; i -- ) { if ( buf . charAt ( i ) > ' ' ) { break ; } } buf . setLength ( i + 1 ) ; } String str = buf . toString ( ) ; return new StringToken ( startLine , startPos , endPos , Token . STRING , str ) ; }
The ENTER_TEXT code has already been scanned when this is called .