Save This Page
Home » openjdk-7 » net.nosica » compiler » parser » [javadoc | source]
    1   /* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */
    2   package net.nosica.compiler.parser;
    3   
    4   /**
    5    * Describes the input token stream.
    6    */
    7   
    8   public class Token {
    9   
   10     public Token()
   11     {
   12       net.nosica.compiler.framework.application.EnvironmentImpl.instance().getParser().addToken(this);
   13     }
   14   
   15     /**
   16      * An integer that describes the kind of this token.  This numbering
   17      * system is determined by JavaCCParser, and a table of these numbers is
   18      * stored in the file ...Constants.java.
   19      */
   20     public int kind;
   21   
   22     /**
   23      * beginLine and beginColumn describe the position of the first character
   24      * of this token; endLine and endColumn describe the position of the
   25      * last character of this token.
   26      */
   27     public int beginLine, beginColumn, endLine, endColumn;
   28   
   29     /**
   30      * The string image of the token.
   31      */
   32     public String image;
   33   
   34     /**
   35      * A reference to the next regular (non-special) token from the input
   36      * stream.  If this is the last token from the input stream, or if the
   37      * token manager has not read tokens beyond this one, this field is
   38      * set to null.  This is true only if this token is also a regular
   39      * token.  Otherwise, see below for a description of the contents of
   40      * this field.
   41      */
   42     public Token next;
   43   
   44     /**
   45      * This field is used to access special tokens that occur prior to this
   46      * token, but after the immediately preceding regular (non-special) token.
   47      * If there are no such special tokens, this field is set to null.
   48      * When there are more than one such special token, this field refers
   49      * to the last of these special tokens, which in turn refers to the next
   50      * previous special token through its specialToken field, and so on
   51      * until the first special token (whose specialToken field is null).
   52      * The next fields of special tokens refer to other special tokens that
   53      * immediately follow it (without an intervening regular token).  If there
   54      * is no such token, this field is null.
   55      */
   56     public Token specialToken;
   57   
   58     /**
   59      * Returns the image.
   60      */
   61     public final String toString()
   62     {
   63        return image;
   64     }
   65   
   66     /**
   67      * Returns a new Token object, by default. However, if you want, you
   68      * can create and return subclass objects based on the value of ofKind.
   69      * Simply add the cases to the switch for all those special cases.
   70      * For example, if you have a subclass of Token called IDToken that
   71      * you want to create if ofKind is ID, simlpy add something like :
   72      *
   73      *    case MyParserConstants.ID : return new IDToken();
   74      *
   75      * to the following switch statement. Then you can cast matchedToken
   76      * variable to the appropriate type and use it in your lexical actions.
   77      */
   78     public static final Token newToken(int ofKind)
   79     {
   80        switch(ofKind)
   81        {
   82          default : return new Token();
   83        }
   84     }
   85   
   86   }

Save This Page
Home » openjdk-7 » net.nosica » compiler » parser » [javadoc | source]