public enum TuTokenType
{
    NO_TOKEN = 0,
    OPENPAREN_TOKEN,
    COMMA_TOKEN,
    CLOSEPAREN_TOKEN,
    MONOQUOTE_TOKEN,
    TRIQUOTE_TOKEN,
    IDENTIFIER_TOKEN,
    TERMINATOR_TOKEN,
    COMMENT_TOKEN,
    NUMBER_TOKEN,
    HEXNUMBER_TOKEN
}

public class TuToken
{
    string name_;
    TuTokenType type_;
    int charNumber_;
    int lineNumber_;
    TuToken nextToken_;
    string error_;

    public string name { set { name_ = value; } get { return name_; } }
    public TuTokenType type { set { type_ = value; } get { return type_; } }
    public int charNumber { set { charNumber_ = value; } get { return charNumber_; } }
    public int lineNumber { set { lineNumber_ = value; } get { return lineNumber_; } }
    public TuToken nextToken
    {
        set
        {
            if (this == value)
                throw new System.Exception("next = self!");
            nextToken_ = value;
        }
        get { return nextToken_; }
    }
    public string error { get { return error_; } set { error_ = value; } }
    public TuToken() { name = null; charNumber = -1; }
    public string typeName()
    {
        switch (this.type)
        {
            case TuTokenType.NO_TOKEN: return "NoToken";
            case TuTokenType.OPENPAREN_TOKEN: return "OpenParen";
            case TuTokenType.COMMA_TOKEN: return "Comma";
            case TuTokenType.CLOSEPAREN_TOKEN: return "CloseParen";
            case TuTokenType.MONOQUOTE_TOKEN: return "MonoQuote";
            case TuTokenType.TRIQUOTE_TOKEN: return "TriQuote";
            case TuTokenType.IDENTIFIER_TOKEN: return "Identifier";
            case TuTokenType.TERMINATOR_TOKEN: return "Terminator";
            case TuTokenType.COMMENT_TOKEN: return "Comment";
            case TuTokenType.NUMBER_TOKEN: return "Number";
            case TuTokenType.HEXNUMBER_TOKEN: return "HexNumber";
        }
        return null;
    }
    public void quoteName(string name) { name = "\"" + name_ + "\""; }
    public int nameIs(string n)
    {
        return name.CompareTo(n);
    }
    public bool isValidMessageName()
    {
        switch (this.type)
        {
            case TuTokenType.IDENTIFIER_TOKEN:
            case TuTokenType.MONOQUOTE_TOKEN:
            case TuTokenType.TRIQUOTE_TOKEN:
            case TuTokenType.NUMBER_TOKEN:
            case TuTokenType.HEXNUMBER_TOKEN:
                return true;
            default:
                return false;
        }
    }
    public void print() { printSelf(); }
    public void printSelf() { System.Console.Write("'" + name + "'"); }

}