aboutsummaryrefslogtreecommitdiff
path: root/src/lexer.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lexer.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lexer.h b/src/lexer.h
new file mode 100644
index 0000000..37d268f
--- /dev/null
+++ b/src/lexer.h
@@ -0,0 +1,44 @@
1#ifndef BU_LEXER_H
2#define BU_LEXER_H
3
4#include "bu/variant.h"
5
6namespace Bu
7{
8 class Stream;
9
10 /**
11 * The base class for creating a lexical analyzer. This is designed to work
12 * in tandem with the Bu::Parser class, which uses this to tokenize textual
13 * input. It can be used by just about anything that cares about tokens
14 * more than raw input, though.
15 */
16 class Lexer
17 {
18 public:
19 Lexer();
20 virtual ~Lexer();
21
22 class Token
23 {
24 public:
25 Token();
26 Token( int iToken );
27
28 template<class t>
29 Token( int iToken, const t &v ) :
30 iToken( iToken ),
31 vExtra( v )
32 {
33 }
34 int iToken;
35 Bu::Variant vExtra;
36 };
37
38 virtual Token *nextToken()=0;
39
40 virtual Bu::FString tokenToString( const Token &t );
41 };
42};
43
44#endif