-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLexer.cpp
More file actions
46 lines (38 loc) · 838 Bytes
/
Lexer.cpp
File metadata and controls
46 lines (38 loc) · 838 Bytes
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
#include "Global.h"
#include <stack>
#include "Parser.h"
#include "Lexer.h"
void before_rule()
{
yylloc.first_line = yylloc.last_line = yylineno;
yylloc.first_column = yylloc.last_column;
if (*yytext == '\n')
{
yylloc.last_line++;
yylloc.last_column = 1;
}
else {
yylloc.last_column += yyleng;
}
}
void after_rule()
{
}
stack<YYLTYPE> location_stack = stack<YYLTYPE>();
stack<int> line_stack = stack<int>();
void yypush_location_state(const char *new_file_name)
{
line_stack.push(yylineno);
yylineno = 1;
location_stack.push(yylloc);
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 1;
yylloc.file_name = new_file_name;
}
void yypop_location_state()
{
yylineno = line_stack.top();
line_stack.pop();
yylloc = location_stack.top();
location_stack.pop();
}