blob: c54c31f6877dd1b3081eff9ee0bc655f3a9201dc (
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
|
/*
* Copyright (C) 2007-2014 Xagasoft, All rights reserved.
*
* This file is part of the libbu++ library and is released under the
* terms of the license contained in the file LICENSE.
*/
#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
|