/* XHL - Extensible Host Language
 * Copyright 2012 Sergej Chodarev
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package sk.tuke.xhl.core;

import sk.tuke.xhl.core.elements.Position;

/**
 * Token from lexical analysis
 */
public class Token {

    public static enum TokenType {
        PAR_OPEN, PAR_CLOSE,
        BRACKET_OPEN, BRACKET_CLOSE,
        BRACE_OPEN, BRACE_CLOSE,
        COMMA, DOT, TRUE, FALSE, NULL,
        SYMBOL, OPERATOR, STRING, NUMBER,
        INDENT, DEDENT, LINEEND, EOF
    }

    public final TokenType type;
    public final double doubleValue;
    public final String stringValue;
    public final Position position;

    public Token(TokenType t, Position p) {
        this(t, 0, null, p);
    }

    public Token(TokenType t, double n, Position p) {
        this(t, n, null, p);
    }

    public Token(TokenType t, String s, Position p) {
        this(t, 0, s, p);
    }

    private Token(TokenType t, double n, String s, Position p) {
        type = t;
        doubleValue = n;
        stringValue = s;
        position = p;
    }
}

@@ -1,10 +1,13 @@
 /*
+%0A *
  XHL - E
@@ -1578,11 +1578,289 @@
 p;%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        if (type == TokenType.NUMBER)%0A            return %22NUMBER%3C%22 + doubleValue + %22%3E%22;%0A        else if (stringValue != null)%0A            return type + %22%3C%22 + stringValue + %22%3E%22;%0A        else%0A            return type.toString();%0A    %7D
 %0A%7D%0A

Implement Toke.toString()