src/br/univali/ttoproject/compiler/parser/Token.java
/**
     * Returns a new Token object, by default. However, if you want, you can create
     * and return subclass objects based on the value of ofKind. Simply add the
     * cases to the switch for all those special cases. For example, if you have a
     * subclass of Token called IDToken that you want to create if ofKind is ID,
     * simply add something like :
     * <p>
     * case MyParserConstants.ID : return new IDToken(ofKind, image);
     * <p>
     * to the following switch statement. Then you can cast matchedToken variable to
     * the appropriate type and use sit in your lexical actions.
     */
Returns a new Token object, by default. However, if you want, you can create
and return subclass objects based on the value of ofKind. Simply add the
cases to the switch for all those special cases. For example, if you have a
subclass of Token called IDToken that you want to create if ofKind is ID,
simply add something like :

case MyParserConstants.ID : return new IDToken(ofKind, image);

to the following switch statement. Then you can cast matchedToken variable to
the appropriate type and use sit in your lexical actions.
Returns a new Token object by default . However if you want you can create and return subclass objects based on the value of ofKind . Simply add the cases to the switch for all those special cases . For example if you have a subclass of Token called IDToken that you want to create if ofKind is ID simply add something like : case MyParserConstants . ID : return new IDToken ( ofKind image ) ; to the following switch statement . Then you can cast matchedToken variable to the appropriate type and use sit in your lexical actions .
public static CategorizedToken newToken(int ofKind, String image) {
        switch (ofKind) {
            case ParserConstants.PROGRAM:
            case ParserConstants.DEFINE:
            case ParserConstants.NOT:
            case ParserConstants.VARIABLE:
            case ParserConstants.IS:
            case ParserConstants.NATURAL_TYPE:
            case ParserConstants.REAL_TYPE:
            case ParserConstants.CHAR_TYPE:
            case ParserConstants.BOOLEAN_TYPE:
            case ParserConstants.EXECUTE:
            case ParserConstants.SET:
            case ParserConstants.TO:
            case ParserConstants.GET:
            case ParserConstants.PUT:
            case ParserConstants.VERIFY:
            case ParserConstants.LOOP:
            case ParserConstants.WHILE:
            case ParserConstants.DO:
                return new CategorizedToken(TokenCategory.Keyword, ofKind, image);
            case ParserConstants.IDENTIFIER:
                return new CategorizedToken(TokenCategory.Identifier, ParserConstants.IDENTIFIER, image);
            case ParserConstants.NATURAL_CONST:
                return new CategorizedToken(TokenCategory.NaturalConstant, ofKind, image);
            case ParserConstants.REAL_CONST:
                return new CategorizedToken(TokenCategory.RealConstant, ofKind, image);
            case ParserConstants.CHAR_CONST:
                return new CategorizedToken(TokenCategory.CharConstant, ofKind, image);
            case ParserConstants.TRUE:
            case ParserConstants.FALSE:
                return new CategorizedToken(TokenCategory.BooleanConstant, ofKind, image);
            case ParserConstants.EOF:
            case ParserConstants.LBRACE:
            case ParserConstants.RBRACE:
            case ParserConstants.LPARENTHESES:
            case ParserConstants.RPARANTHESES:
            case ParserConstants.LBRACKET:
            case ParserConstants.RBRACKET:
            case ParserConstants.DOT:
            case ParserConstants.COMMA:
            case ParserConstants.PLUS:
            case ParserConstants.MINUS:
            case ParserConstants.POWER:
            case ParserConstants.MULTIPLICATION:
            case ParserConstants.DIVISION:
            case ParserConstants.INTEGER_DIVISION:
            case ParserConstants.REST:
            case ParserConstants.EQUAL:
            case ParserConstants.DIFFERENT:
            case ParserConstants.SMALLER:
            case ParserConstants.GREATER:
            case ParserConstants.SMALLER_EQUAL:
            case ParserConstants.GREATER_EQUAL:
            case ParserConstants.AND:
            case ParserConstants.OR:
            case ParserConstants.NOT_SYMBOL:
            case ParserConstants.HEADER:
                return new CategorizedToken(TokenCategory.SpecialSymbol, ofKind, image);
            default:
                return new CategorizedToken(TokenCategory.Unknown, ofKind, image);
        }
    }
public static CategorizedToken newToken ( int ofKind , String image ) { switch ( ofKind ) { case ParserConstants . PROGRAM : case ParserConstants . DEFINE : case ParserConstants . NOT : case ParserConstants . VARIABLE : case ParserConstants . IS : case ParserConstants . NATURAL_TYPE : case ParserConstants . REAL_TYPE : case ParserConstants . CHAR_TYPE : case ParserConstants . BOOLEAN_TYPE : case ParserConstants . EXECUTE : case ParserConstants . SET : case ParserConstants . TO : case ParserConstants . GET : case ParserConstants . PUT : case ParserConstants . VERIFY : case ParserConstants . LOOP : case ParserConstants . WHILE : case ParserConstants . DO : return new CategorizedToken ( TokenCategory . Keyword , ofKind , image ) ; case ParserConstants . IDENTIFIER : return new CategorizedToken ( TokenCategory . Identifier , ParserConstants . IDENTIFIER , image ) ; case ParserConstants . NATURAL_CONST : return new CategorizedToken ( TokenCategory . NaturalConstant , ofKind , image ) ; case ParserConstants . REAL_CONST : return new CategorizedToken ( TokenCategory . RealConstant , ofKind , image ) ; case ParserConstants . CHAR_CONST : return new CategorizedToken ( TokenCategory . CharConstant , ofKind , image ) ; case ParserConstants . TRUE : case ParserConstants . FALSE : return new CategorizedToken ( TokenCategory . BooleanConstant , ofKind , image ) ; case ParserConstants . EOF : case ParserConstants . LBRACE : case ParserConstants . RBRACE : case ParserConstants . LPARENTHESES : case ParserConstants . RPARANTHESES : case ParserConstants . LBRACKET : case ParserConstants . RBRACKET : case ParserConstants . DOT : case ParserConstants . COMMA : case ParserConstants . PLUS : case ParserConstants . MINUS : case ParserConstants . POWER : case ParserConstants . MULTIPLICATION : case ParserConstants . DIVISION : case ParserConstants . INTEGER_DIVISION : case ParserConstants . REST : case ParserConstants . EQUAL : case ParserConstants . DIFFERENT : case ParserConstants . SMALLER : case ParserConstants . GREATER : case ParserConstants . SMALLER_EQUAL : case ParserConstants . GREATER_EQUAL : case ParserConstants . AND : case ParserConstants . OR : case ParserConstants . NOT_SYMBOL : case ParserConstants . HEADER : return new CategorizedToken ( TokenCategory . SpecialSymbol , ofKind , image ) ; default : return new CategorizedToken ( TokenCategory . Unknown , ofKind , image ) ; } }
Returns a new Token object, by default.
Returns a new Token object by default .