aboutsummaryrefslogtreecommitdiff
path: root/src/experimental/lexer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/experimental/lexer.h')
-rw-r--r--src/experimental/lexer.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/experimental/lexer.h b/src/experimental/lexer.h
new file mode 100644
index 0000000..b057692
--- /dev/null
+++ b/src/experimental/lexer.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_LEXER_H
9#define BU_LEXER_H
10
11#include "bu/variant.h"
12
13namespace Bu
14{
15 class Stream;
16
17 /**
18 * The base class for creating a lexical analyzer. This is designed to work
19 * in tandem with the Bu::Parser class, which uses this to tokenize textual
20 * input. It can be used by just about anything that cares about tokens
21 * more than raw input, though.
22 */
23 class Lexer
24 {
25 public:
26 Lexer();
27 virtual ~Lexer();
28
29 typedef int TokenType;
30
31 class Token
32 {
33 public:
34 Token();
35 Token( TokenType iToken );
36
37 template<class t>
38 Token( TokenType iToken, const t &v ) :
39 iToken( iToken )//,
40// vExtra( v )
41 {
42 vExtra = v;
43 }
44 TokenType iToken;
45 Bu::Variant vExtra;
46 int iStartCol;
47 int iStartRow;
48 int iEndCol;
49 int iEndRow;
50 };
51
52 virtual Token *nextToken()=0;
53
54 virtual Bu::String tokenToString( const Token &t );
55 };
56};
57
58#endif