summaryrefslogtreecommitdiff
path: root/bnf/lex.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'bnf/lex.hpp')
-rw-r--r--bnf/lex.hpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/bnf/lex.hpp b/bnf/lex.hpp
index b9865552..4c4c6576 100644
--- a/bnf/lex.hpp
+++ b/bnf/lex.hpp
@@ -10,18 +10,30 @@ struct ParserContext
::std::unique_ptr<Module> output_module;
// semi-evil hack used to break '>>' apart into '>' '>'
- int next_token;
+ ::std::vector<int> next_token;
ParserContext(::std::string filename):
filename(filename),
output_module(),
next_token(0)
- {}
-
+ {
+ //next_token.reserve(2);
+ }
+
+ int popback() {
+ if( next_token.size() > 0 ) {
+ int rv = next_token.back();
+ next_token.pop_back();
+ return rv;
+ }
+ else {
+ return 0;
+ }
+ }
void pushback(int tok) {
- assert(next_token == 0);
- next_token = tok;
+ assert(next_token.size() < 2);
+ next_token.push_back( tok );
}
};
#include ".gen/rust.tab.hpp"