aboutsummaryrefslogtreecommitdiff
path: root/src/parser.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/parser.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/parser.h b/src/parser.h
new file mode 100644
index 0000000..26b15a6
--- /dev/null
+++ b/src/parser.h
@@ -0,0 +1,48 @@
1#ifndef BU_PARSER_H
2#define BU_PARSER_H
3
4#include "bu/list.h"
5#include "bu/fstring.h"
6#include "bu/lexer.h"
7
8namespace Bu
9{
10 /**
11 * The base framework for a LR(1) grammar parser. Provided a proper set of
12 * ParserStates this will prase any input the lexer can provide.
13 */
14 class Parser
15 {
16 public:
17 Parser();
18 virtual ~Parser();
19
20 /**
21 * When a Lexer is pushed onto the stack it becomes the source for
22 * future tokens read by the parser until it is popped off the stack.
23 * The Parser takes ownership of every Lexer pushed onto the stack,
24 * and will delete it when it is popped off the stack.
25 */
26 void pushLexer( Lexer *pLex );
27
28 /**
29 * Pop a lexer off the stack, and delete it.
30 */
31 void popLexer();
32
33 /**
34 * Execute a parse.
35 */
36 void parse();
37
38 private:
39 typedef Bu::List<Lexer *> LexerStack;
40 typedef Bu::List<Lexer::Token *> TokenStack;
41 typedef Bu::List<State *> StateStack;
42 LexerStack sLexer;
43 TokenStack sToken;
44 StateStack sState;
45 };
46};
47
48#endif