summaryrefslogtreecommitdiff
path: root/src/token.h
blob: 4d738ecdc40fae7e48fec1491f1acf4cfc8ba47e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef TOKEN_H
#define TOKEN_H

class Number;
namespace Bu
{
    class String;
    class Formatter;
};

class Token
{
public:
    enum Type
    {
        tNumber         = 0x1001,
        tVariable       = 0x2002,
        //tCommand        = 0x2003,
        tPlus           = 0x4004,
        tMinus          = 0x4005,
        tDivide         = 0x4006,
        tMultiply       = 0x4007,
        tModulus        = 0x4008,
        tOpenParen      = 0x8009,
        tCloseParen     = 0x800a,
        tEquals         = 0x400b,
        tString         = 0x200c,

        tNegate         = 0x800d,
        tEndOfLine      = 0x010e,

        tEndOfInput     = 0x010f,

        tUninitialized  = 0x0110,
        tComputedValue  = 0x0111,

        tCmdExit        = 0x0201,
        tCmdScale       = 0x0202,
        tCmdRadix       = 0x0203,
        tCmdExtended    = 0x02f0,
        tCmdParam       = 0x02f1,
        tCmdEndParams   = 0x02f2,


        mMetaNumber     = 0x1000,
        mMetaString     = 0x2000,
        mMetaOperator   = 0x4000,
        mMetaAltOp      = 0x8000,
        mMetaMeta       = 0x0100,
        mMetaCmd        = 0x0200
    };

    Token();
    Token( Type eType );
    Token( Type eType, Bu::String *s );
    Token( Type eType, Number *n );
    Token( const Token &rSrc );
    ~Token();

    Token &operator=( const Token &rhs );

    Type eType;
    union
    {
        Bu::String *sVal;
        class Number *nVal;
    };
};

Bu::Formatter &operator<<( Bu::Formatter &f, Token::Type eType );
Bu::Formatter &operator<<( Bu::Formatter &f, const Token &t );

#endif