blob: 95241b6662277fee1fe046f9d81ff77428678ef0 (
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
|
#pragma once
#include "ast_types.hpp"
struct ParserContext
{
::std::string filename;
::std::string base_path;
::std::unique_ptr<Module> output_module;
// semi-evil hack used to break '>>' apart into '>' '>'
::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.size() < 2);
next_token.push_back( tok );
}
};
#include ".gen/rust.tab.hpp"
extern int yylineno;
extern int yylex(YYSTYPE* lvalp, ParserContext& context);
extern void yyerror(ParserContext& context, const char *s);
extern int yydebug;
|