Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * @(#)StreamPosTokenizer.java
    *
    * Copyright (c) 2000-2011 Werner Randelshofer, Goldau, Switzerland.
    * All rights reserved.
    *
    * You may not use, copy or modify this file, except in compliance with the
    * license agreement you entered into with Werner Randelshofer.
    * For details see accompanying license terms.
   */
  package org.monte.media.io;
  
  import java.io.*;
  import java.util.Vector;

This extension of StreamTokenizer keeps track of the position of the tokens in the input stream, and it can parse hexadecimal numbers and double numbers with exponents.

The handling of numeric data is also different: a single dot '.' and minus dot '-.' are not treated as numbers.

Author(s):
Werner Randelshofer, Hausmatt 10, Goldau, CH-6405, Switzerland
Version:
$Id: StreamPosTokenizer.java 299 2013-01-03 07:40:18Z werner $
  
  
  
  public class StreamPosTokenizer
          /*extends StreamTokenizer*/ {
      private Reader reader = null;
    
    
Position of the next character that will be read from the file. rlw
  
      private int readpos = 0;
    
    
Start and end position of the current token. rlw
  
      private int startpos = -1, endpos = -1;
      private Vector<Integerunread = new Vector<Integer>();
      
      private char buf[] = new char[20];
    
    
The next character to be considered by the nextToken method. May also be NEED_CHAR to indicate that a new character should be read, or SKIP_LF to indicate that a new character should be read and, if it is a '\n' character, it should be discarded and a second new character should be read.
  
      private int peekc = ;
      
      private static final int NEED_CHAR = .;
      private static final int SKIP_LF = . - 1;
      
      private boolean pushedBack;
      private boolean forceLower;
    
The line number of the last token read
  
      private int lineno = 1;
      
      private boolean eolIsSignificantP = false;
      private boolean slashSlashCommentsP = false;
      private boolean slashStarCommentsP = false;
      
      // rlw
      private char[] slashSlash = new char[] {'/','/'};
      private char[] slashStar = new char[] {'/','*'};
      private char[] starSlash = new char[] {'*','/'};
      
      private byte ctype[] = new byte[256];
      private static final byte CT_WHITESPACE = 1;
      private static final byte CT_DIGIT = 2;
      private static final byte CT_ALPHA = 4;
      private static final byte CT_QUOTE = 8;
      private static final byte CT_COMMENT = 16;
      
      private boolean isParseHexNumbers = false;
      private boolean isParseExponents = false;
    
    
After a call to the nextToken method, this field contains the type of the token just read. For a single character token, its value is the single character, converted to an integer. For a quoted string token (see , its value is the quote character. Otherwise, its value is one of the following:
  • TT_WORD indicates that the token is a word.
  • TT_NUMBER indicates that the token is a number.
  • TT_EOL indicates that the end of line has been read. The field can only have this value if the eolIsSignificant method has been called with the argument true.
  • TT_EOF indicates that the end of the input stream has been reached.

 
     public int ttype = ;
    
    
A constant indicating that the end of the stream has been read.
 
     public static final int TT_EOF = -1;
    
    
A constant indicating that the end of the line has been read.
 
     public static final int TT_EOL = '\n';
    
    
A constant indicating that a number token has been read.
 
     public static final int TT_NUMBER = -2;
    
    
A constant indicating that a word token has been read.
 
     public static final int TT_WORD = -3;
     
     /* A constant indicating that no token has been read, used for
      * initializing ttype.  FIXME This could be made public and
      * made available as the part of the API in a future release.
      */
     private static final int TT_NOTHING = -4;
    
    
If the current token is a word token, this field contains a string giving the characters of the word token. When the current token is a quoted string token, this field contains the body of the string.

The current token is a word when the value of the ttype field is TT_WORD. The current token is a quoted string token when the value of the ttype field is a quote character.

 
     public String sval;
    
    
If the current token is a number, this field contains the value of that number. The current token is a number when the value of the ttype field is TT_NUMBER.

 
     public double nval;
    
    
Initializes everything except the streams.
 
     public StreamPosTokenizer() {
         wordChars('a''z');
         wordChars('A''Z');
         wordChars(128 + 32, 255);
         whitespaceChars(0, ' ');
         commentChar('/');
         quoteChar('"');
         quoteChar('\'');
         parseNumbers();
     }
    
    
    
Create a tokenizer that parses the given character stream.

Since:
JDK1.1
 
     public StreamPosTokenizer(Reader r) {
         this();
         if (r == null) {
             throw new NullPointerException();
         }
          = r;
     }
    
    
Sets the reader for the tokenizer.

Parameters:
r
 
     public void setReader(Reader r) {
         this. = r;
          = 0;
         .clear();
          = ;
          = false;
          = false;
          = 0;
          =  = -1;
          = ;
     }
    
    
Resets this tokenizer's syntax table so that all characters are "ordinary." See the ordinaryChar method for more information on a character being ordinary.

 
     public void resetSyntax() {
         for (int i = .; --i >= 0;)
             [i] = 0;
     }
    
    
Specifies that all characters c in the range low <= c <= high are word constituents. A word token consists of a word constituent followed by zero or more word constituents or number constituents.

Parameters:
low the low end of the range.
hi the high end of the range.
 
     public void wordChars(int lowint hi) {
         if (low < 0)
             low = 0;
         if (hi >= .)
             hi = . - 1;
         while (low <= hi)
             [low++] |= ;
     }
    
    
Specifies that all characters c in the range low <= c <= high are white space characters. White space characters serve only to separate tokens in the input stream.

Parameters:
low the low end of the range.
hi the high end of the range.
 
     public void whitespaceChars(int lowint hi) {
         if (low < 0)
             low = 0;
         if (hi >= .)
             hi = . - 1;
         while (low <= hi)
             [low++] = ;
     }
    
    
Specifies that all characters c in the range low <= c <= high are "ordinary" in this tokenizer. See the ordinaryChar method for more information on a character being ordinary.

Parameters:
low the low end of the range.
hi the high end of the range.
See also:
java.io.StreamTokenizer.ordinaryChar(int)
 
     public void ordinaryChars(int lowint hi) {
         if (low < 0)
             low = 0;
         if (hi >= .)
             hi = . - 1;
         while (low <= hi)
             [low++] = 0;
     }
    
    
Specifies that the character argument is "ordinary" in this tokenizer. It removes any special significance the character has as a comment character, word component, string delimiter, white space, or number character. When such a character is encountered by the parser, the parser treates it as a single-character token and sets ttype field to the character value.

Parameters:
ch the character.
See also:
java.io.StreamTokenizer.ttype
 
     public void ordinaryChar(int ch) {
         if (ch >= 0 && ch < .)
             [ch] = 0;
     }
    
    
Specified that the character argument starts a single-line comment. All characters from the comment character to the end of the line are ignored by this stream tokenizer.

Parameters:
ch the character.
 
     public void commentChar(int ch) {
         if (ch >= 0 && ch < .)
             [ch] = ;
     }
    
    
Specifies that matching pairs of this character delimit string constants in this tokenizer.

When the nextToken method encounters a string constant, the ttype field is set to the string delimiter and the sval field is set to the body of the string.

If a string quote character is encountered, then a string is recognized, consisting of all characters after (but not including) the string quote character, up to (but not including) the next occurrence of that same string quote character, or a line terminator, or end of file. The usual escape sequences such as "\n" and "\t" are recognized and converted to single characters as the string is parsed.

 
     public void quoteChar(int ch) {
         if (ch >= 0 && ch < .)
             [ch] = ;
     }
    
    
Specifies that numbers should be parsed by this tokenizer. The syntax table of this tokenizer is modified so that each of the twelve characters:
      0 1 2 3 4 5 6 7 8 9 . -
 

has the "numeric" attribute.

When the parser encounters a word token that has the format of a double precision floating-point number, it treats the token as a number rather than a word, by setting the the ttype field to the value TT_NUMBER and putting the numeric value of the token into the nval field.

 
     public void parseNumbers() {
         for (int i = '0'i <= '9'i++)
             [i] |= ;
         ['.'] |= ;
         ['-'] |= ;
         //ctype['+'] |= CT_DIGIT; // rlw
     }
     
     public void parsePlusAsNumber() {
         ['+'] |= ;
     }
    
    
Enables number parsing for decimal numbers and for hexadecimal numbers
 
     public void parseHexNumbers() {
         parseNumbers();
          = true;
     }
    
Enables number parsing of exponents. Exponents appear after the last digit of number with capital letter 'E' or small letter 'e'.
 
     public void parseExponents() {
         parseNumbers();
          = true;
     }
    
    
Determines whether or not ends of line are treated as tokens. If the flag argument is true, this tokenizer treats end of lines as tokens; the nextToken method returns TT_EOL and also sets the ttype field to this value when an end of line is read.

A line is a sequence of characters ending with either a carriage-return character ('\r') or a newline character ('\n'). In addition, a carriage-return character followed immediately by a newline character is treated as a single end-of-line token.

If the flag is false, end-of-line characters are treated as white space and serve only to separate tokens.

Parameters:
flag true indicates that end-of-line characters are separate tokens; false indicates that end-of-line characters are white space.
See also:
java.io.StreamTokenizer.nextToken()
java.io.StreamTokenizer.ttype
java.io.StreamTokenizer.TT_EOL
 
     public void eolIsSignificant(boolean flag) {
          = flag;
     }
    
    
Determines whether or not the tokenizer recognizes C-style comments. If the flag argument is true, this stream tokenizer recognizes C-style comments. All text between successive occurrences of /* and */ are discarded.

If the flag argument is false, then C-style comments are not treated specially.

Parameters:
flag true indicates to recognize and ignore C-style comments.
 
     public void slashStarComments(boolean flag) {
          = flag;
     }
    
    
Determines whether or not the tokenizer recognizes C++-style comments. If the flag argument is true, this stream tokenizer recognizes C++-style comments. Any occurrence of two consecutive slash characters ('/') is treated as the beginning of a comment that extends to the end of the line.

If the flag argument is false, then C++-style comments are not treated specially.

Parameters:
flag true indicates to recognize and ignore C++-style comments.
 
     public void slashSlashComments(boolean flag) {
          = flag;
     }
    
    
Determines whether or not word token are automatically lowercased. If the flag argument is true, then the value in the sval field is lowercased whenever a word token is returned (the ttype field has the value TT_WORD by the nextToken method of this tokenizer.

If the flag argument is false, then the sval field is not modified.

Parameters:
fl true indicates that all word tokens should be lowercased.
See also:
java.io.StreamTokenizer.nextToken()
java.io.StreamTokenizer.ttype
java.io.StreamTokenizer.TT_WORD
 
     public void lowerCaseMode(boolean fl) {
          = fl;
     }
    
    
Read the next character
 
     private int read() throws IOException {
         // rlw
         int data;
         if (.size() > 0) {
             data = ((Integer.lastElement()).intValue();
             .removeElementAt(.size() - 1);
         } else {
             data = .read();
         }
         if (data != -1) { ++; }
         return data;
     }
    
Unread
 
     private void unread(int c) {
         .addElement(c);
         --;
     }
    
    
Parses the next token from the input stream of this tokenizer. The type of the next token is returned in the ttype field. Additional information about the token may be in the nval field or the sval field of this tokenizer.

Typical clients of this class first set up the syntax tables and then sit in a loop calling nextToken to parse successive tokens until TT_EOF is returned.

Returns:
the value of the ttype field.
Throws:
java.io.IOException if an I/O error occurs.
See also:
java.io.StreamTokenizer.nval
java.io.StreamTokenizer.sval
java.io.StreamTokenizer.ttype
 
     @SuppressWarnings("empty-statement")
     public int nextToken() throws IOException {
         if () {
              = false;
             return ;
         }
         byte ct[] = ;
          = null;
         
         int c = ;
         if (c < 0)
             c = ;
         if (c == ) {
             c = read();
             if (c < 0) {
                 // rlw
                  =  =  - 1;
                 return  = ;
             }
             if (c == '\n')
                 c = ;
         }
         if (c == ) {
             c = read();
             if (c < 0) {
                 // rlw
                  =  =  - 1;
                 return  = ;
             }
         }
          = c;    /* Just to be safe */
         
         /* Set peekc so that the next invocation of nextToken will read
          * another character unless peekc is reset in this invocation
          */
          = ;
         
         int ctype = c < 256 ? ct[c] : ;
         while ((ctype & ) != 0) {
             if (c == '\r') {
                 ++;
                 if () {
                      = ;
                     // rlw
                      =  =  - 1;
                     return  = ;
                 }
                 c = read();
                 if (c == '\n')
                     c = read();
             } else {
                 if (c == '\n') {
                     ++;
                     if () {
                         // rlw
                          =  =  - 1;
                         return  = ;
                     }
                 }
                 c = read();
             }
             if (c < 0) {
                 // rlw
                  =  = ;
                 return  = ;
             }
             ctype = c < 256 ? ct[c] : ;
         }
         
         // rlw
          =  - 1;
         
         // rlw hexadecimal
         hex: if (((ctype & ) != 0) &&
                 c == '0' && ) {
             c = read();
             if (c == 'x') {
                 int digits = 0;
                 long hval = 0;
                 while (digits < 16) {
                     c = read();
                     if (c >= '0' && c <= '9') {
                         hval = (hval << 4) | (c - '0');
                     } else if (c >= 'A' && c <= 'F') {
                         hval = (hval << 4) | (c - 'A' + 10);
                     } else if (c >= 'a' && c <= 'f') {
                         hval = (hval << 4) | (c - 'a' + 10);
                     } else {
                         unread(c);
                         if (digits == 0) {
                              = "0x";
                              =  - 1;
                             return  = ;
                         } else {
                              = (doublehval;
                              =  - 1;
                             return  = ;
                         }
                     }
                     digits++;
                 }
                  = (doublehval;
                  =  - 1;
                 return  = ;
             } else {
                 unread(c);
                 c = '0';
             }
         }
         
         digit: if ((ctype & ) != 0) {
             int digits = 0;
             boolean neg = false;
             if (c == '-') {
                 c = read();
                 if (c != '.' && (c < '0' || c > '9')) {
                      = c;
                     // rlw
                     if (('-' & ) != 0) {
                         unread(c);
                         c = '-';
                         break digit;
                     } else {
                          =  - 1;
                         return  = '-';
                     }
                 }
                 neg = true;
             } else if (c == '+') {
                 c = read();
                 if (c != '.' && (c < '0' || c > '9')) {
                      = c;
                     // rlw
                     if (('+' & ) != 0) {
                         unread(c);
                         c = '+';
                         break digit;
                     } else {
                          =  - 1;
                         return  = '-';
                     }
                 }
                 neg = false;
             }
             
             double v = 0;
             int decexp = 0;
             int seendot = 0;
             while (true) {
                 if (c == '.' && seendot == 0)
                     seendot = 1;
                 else if ('0' <= c && c <= '9') {
                     digits++;
                     v = v * 10 + (c - '0');
                     decexp += seendot;
                 } else
                     break;
                 c = read();
             }
              = c;
             if (decexp != 0) {
                 double denom = 10;
                 decexp--;
                 while (decexp > 0) {
                     denom *= 10;
                     decexp--;
                 }
                 /* Do one division of a likely-to-be-more-accurate number */
                 v = v / denom;
             }
              = neg ? -v : v;
             // rlw
              = (c == -1) ?  - 1 :  - 2;
             if (digits == 0) {
                 if (('.' & ) != 0) {
                     unread(c);
                     if (neg) {
                         unread('.');
                         c = '-';
                     } else {
                         read(); // consume full stop
                         c = '.';
                     }
                     break digit;
                 } else {
                     return  = '.';
                 }
             } else {
                 if () {
                     if (c == 'E' || c == 'e') {
                         c = read();
                         
                         digits = 0;
                         neg = false;
                         if (c == '-') {
                             c = read();
                             if (c < '0' || c > '9') {
                                 unread(c);
                                 unread('E');
                                 return  = ;
                             }
                             neg = true;
                         }
                         v = 0;
                         decexp = 0;
                         while (true) {
                             if ('0' <= c && c <= '9') {
                                 digits++;
                                 v = v * 10 + (c - '0');
                             } else {
                                 break;
                             }
                             c = read();
                         }
                          = c;
                          *= Math.pow(10, (neg) ? -v : v);
                     }
                 }
                 return  = ;
             }
         }
         
         if ((ctype & ) != 0) {
             int i = 0;
             do {
                 if (i >= .) {
                     char nb[] = new char[. * 2];
                     System.arraycopy(, 0, nb, 0, .);
                      = nb;
                 }
                 [i++] = (charc;
                 c = read();
                 ctype = c < 0 ?  : c < 256 ? ct[c] : ;
             } while ((ctype & ( | )) != 0);
              = c;
              = String.copyValueOf(, 0, i);
             if ()
                  = .toLowerCase();
             // rlw EOF must be treated specially
              = (c == -1) ?  - 1 :  - 2;
             return  = ;
         }
         
         if ((ctype & ) != 0) {
              = c;
             int i = 0;
             /* Invariants (because \Octal needs a lookahead):
              *   (i)  c contains char value
              *   (ii) d contains the lookahead
              */
             int d = read();
             while (d >= 0 && d !=  && d != '\n' && d != '\r') {
                 if (d == '\\') {
                     c = read();
                     int first = c;   /* To allow \377, but not \477 */
                     if (c >= '0' && c <= '7') {
                         c = c - '0';
                         int c2 = read();
                         if ('0' <= c2 && c2 <= '7') {
                             c = (c << 3) + (c2 - '0');
                             c2 = read();
                             if ('0' <= c2 && c2 <= '7' && first <= '3') {
                                 c = (c << 3) + (c2 - '0');
                                 d = read();
                             } else
                                 d = c2;
                         } else
                             d = c2;
                     } else {
                         switch (c) {
                             case 'a':
                                 c = 0x7;
                                 break;
                             case 'b':
                                 c = '\b';
                                 break;
                             case 'f':
                                 c = 0xC;
                                 break;
                             case 'n':
                                 c = '\n';
                                 break;
                             case 'r':
                                 c = '\r';
                                 break;
                             case 't':
                                 c = '\t';
                                 break;
                             case 'v':
                                 c = 0xB;
                                 break;
                         }
                         d = read();
                     }
                 } else {
                     c = d;
                     d = read();
                 }
                 if (i >= .) {
                     char nb[] = new char[. * 2];
                     System.arraycopy(, 0, nb, 0, .);
                      = nb;
                 }
                 [i++] = (char)c;
             }
             
             /* If we broke out of the loop because we found a matching quote
              * character then arrange to read a new character next time
              * around; otherwise, save the character.
              */
              = (d == ) ?  : d;
             
              = String.copyValueOf(, 0, i);
             // rlw
              =  - 2;
             return ;
         }
         /* rlw*/
         /*
         if (c == '/' && (slashSlashCommentsP || slashStarCommentsP)) {
             c = read();
             if (c == '*' && slashStarCommentsP) {
                 int prevc = 0;
                 while ((c = read()) != '/' || prevc != '*') {
                     if (c == '\r') {
                         lineno++;
                         c = read();
                         if (c == '\n') {
                             c = read();
                         }
                     } else {
                         if (c == '\n') {
                             lineno++;
                             c = read();
                         }
                     }
                     if (c < 0) {
                         endpos = readpos;
                         return ttype = TT_EOF;
                     }
                     prevc = c;
                 }
                 return nextToken();
             } else if (c == '/' && slashSlashCommentsP) {
                 while ((c = read()) != '\n' && c != '\r' && c >= 0);
                 peekc = c;
                 return nextToken();
             } else {
                 // Now see if it is still a single line comment
                 if ((ct['/'] & CT_COMMENT) != 0) {
                     while ((c = read()) != '\n' && c != '\r' && c >= 0);
                     peekc = c;
                     return nextToken();
                 } else {
                     peekc = c;
                     // rlw
                     endpos = readpos - 2;
                     return ttype = '/';
                 }
             }
         }*/
         
         if ( && c == [0]
                 ||  && c == [0]) {
             if (c == [0] && . == 1) {
                 // This is the scanner code if the slashStar token
                 // is one characters long
                 while ((c = read()) != [0]) {
                     if (c == '\r') {
                         ++;
                         c = read();
                         if (c == '\n') {
                             c = read();
                         }
                     } else {
                         if (c == '\n') {
                             ++;
                             c = read();
                         }
                     }
                     if (c < 0) {
                          = ;
                         return  = ;
                     }
                 }
                 return nextToken();
             } else if (c == [0] && . == 1) {
                 // This is the scanner code if the slashSlash token
                 // is one characters long
                 while ((c = read()) != '\n' && c != '\r' && c >= 0);
                  = c;
                 return nextToken();
             } else {
                 // This is the scanner code if the slashStar and the slashSlash
                 // tokens are two characters long
                 c = read();
                 if (c == [1] && ) {
                     int prevc = 0;
                     while ((c = read()) != [1] || prevc != [0]) {
                         if (c == '\r') {
                             ++;
                             c = read();
                             if (c == '\n') {
                                 c = read();
                             }
                         } else {
                             if (c == '\n') {
                                 ++;
                                 c = read();
                             }
                         }
                         if (c < 0) {
                              = ;
                             return  = ;
                         }
                         prevc = c;
                     }
                     return nextToken();
                 } else if (c == [1] && ) {
                     while ((c = read()) != '\n' && c != '\r' && c >= 0);
                      = c;
                     return nextToken();
                 } else {
                     // Now see if it is still a single line comment
                     if ((ct[[0]] & ) != 0) {
                         while ((c = read()) != '\n' && c != '\r' && c >= 0);
                          = c;
                         return nextToken();
                     } else {
                          = c;
                         // rlw
                          =  - 2;
                         return  = [0];
                     }
                 }
             }
         }
         
         if ((ctype & ) != 0) {
             while ((c = read()) != '\n' && c != '\r' && c >= 0);
              = c;
             //lineno++;  removed because it counts line break twice
             return nextToken();
         }
         
         // rlw
          =  - 1;
         return  = c;
     }
    
Reads the next character from the input stream, without passing it to the tokenizer.
 
     public int nextChar() throws IOException {
         if () {
             throw new IllegalStateException("can't read char when a token has been pushed back");
         }
         if ( == ) {
             return read();
         } else {
             int ch = ;
              = ;
             return ch;
         }
     }
    
Unreads a character back into the input stream of the tokenizer.
 
     public void pushCharBack(int chthrows IOException {
         if () {
             throw new IllegalStateException("can't push back char when a token has been pushed back");
         }
         if ( == ) {
             unread(ch);
         } else {
             unread();
              = ;
             unread(ch);
         }
     }
    
Sets the slash star and star slash tokens. Due to limitations by this implementation, both tokens must have the same number of characters and the character length must be either 1 or 2.
 
     public void setSlashStarTokens(String slashStarString starSlash) {
         if (slashStar.length() != starSlash.length()) {
             throw new IllegalArgumentException("SlashStar and StarSlash tokens must be of same length: '"+slashStar+"' '"+starSlash+"'");
         }
         if (slashStar.length() < 1 || slashStar.length() > 2) {
             throw new IllegalArgumentException("SlashStar and StarSlash tokens must be of length 1 or 2: '"+slashStar+"' '"+starSlash+"'");
         }
         this. = slashStar.toCharArray();
         this. = starSlash.toCharArray();
         commentChar(this.[0]);
     }
    
Sets the slash slash token. Due to limitations by this implementation, the character length must be either 1 or 2.
 
     public void setSlashSlashToken(String slashSlash) {
        if (slashSlash.length() < 1 || slashSlash.length() > 2) {
            throw new IllegalArgumentException("SlashSlash token must be of length 1 or 2: '"+slashSlash+"'");
        }
        this. = slashSlash.toCharArray();
        commentChar(this.[0]);
    }
    
    
Causes the next call to the nextToken method of this tokenizer to return the current value in the ttype field, and not to modify the value in the nval or sval field.

    public void pushBack() {
        if ( != )   /* No-op if nextToken() not called */
             = true;
    }
    
    
Return the current line number.

Returns:
the current line number of this stream tokenizer.
    public int lineno() {
        return ;
    }
    
    
Returns the start position of the token relative to the position that the stream had, when the StreamPosTokenizer was constructed.

Returns:
the start position of the token.
    public int getStartPosition() {
        return ;
    }
    
Set the start position of the current token.
    public void setStartPosition(int p) {
         = p;
    }
    
Returns the end position of the token relative to the position that the stream had, when the StreamPosTokenizer was constructed.

Returns:
the end position of the token.
    public int getEndPosition() {
        return ;
    }
    
    
Consumes a substring from the current sval of the StreamPosTokenizer.
    public void consumeGreedy(String greedyToken) {
        if (greedyToken.length() < .length()) {
            pushBack();
            setStartPosition(getStartPosition() + greedyToken.length());
             = .substring(greedyToken.length());
        }
    }
    
Returns the string representation of the current stream token.

Returns:
a string representation of the token specified by the ttype, nval, and sval fields.
See also:
java.io.StreamTokenizer.nval
java.io.StreamTokenizer.sval
java.io.StreamTokenizer.ttype
    @Override
    public String toString() {
        String ret;
        switch () {
            case :
                ret = "EOF";
                break;
            case :
                ret = "EOL";
                break;
            case :
                ret = ;
                break;
            case :
                ret = "n=" + ;
                break;
            case :
                ret = "NOTHING";
                break;
            default:{
                char s[] = new char[3];
                s[0] = s[2] = '\'';
                s[1] = (char;
                ret = new String(s);
                break;
            }
        }
        return "Token[" + ret + "], line " + ;
    }
New to GrepCode? Check out our FAQ X