summaryrefslogtreecommitdiff
path: root/src/lexer.h
blob: d5631d418cdd6b0aa0fe7272d3da7a5ac151eea4 (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
#ifndef LEXER_H
#define LEXER_H

#include <bu/stream.h>

class Token;

class Lexer
{
public:
    Lexer( Bu::Stream &rIn );
    virtual ~Lexer();

    enum Mode
    {
        modeNormal,
        modeCommand,
    };

    void setMode( Mode e ) { eMode = e; }
    Mode getMode() const { return eMode; }

    Token nextToken();

    int getScale() const { return iScale; }
    void setScale( int i ) { iScale = i; }

    int getRadix() const { return iRadix; }
    void setRadix( int i );

    Token &operator[]( int iIdx );

private:
    Token nextTokenNormal();
    Token nextTokenCommand();

private:
    Bu::Stream &rIn;
    Bu::String sBuf;
    int iBufPos;
    int iScale;
    int iRadix;
    char numRangeTop;
    char ascRangeTop;
    Mode eMode;
};

#endif