blob: f4e0479fb08aa71ba71dc9b2761892668f614539 (
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
|
#ifndef BU_LEXER_H
#define BU_LEXER_H
#include "bu/variant.h"
namespace Bu
{
class Stream;
/**
* The base class for creating a lexical analyzer. This is designed to work
* in tandem with the Bu::Parser class, which uses this to tokenize textual
* input. It can be used by just about anything that cares about tokens
* more than raw input, though.
*/
class Lexer
{
public:
Lexer();
virtual ~Lexer();
typedef int TokenType;
class Token
{
public:
Token();
Token( TokenType iToken );
template<class t>
Token( TokenType iToken, const t &v ) :
iToken( iToken )//,
// vExtra( v )
{
vExtra = v;
}
TokenType iToken;
Bu::Variant vExtra;
int iStartCol;
int iStartRow;
int iEndCol;
int iEndRow;
};
virtual Token *nextToken()=0;
virtual Bu::String tokenToString( const Token &t );
};
};
#endif
|