This repository was archived by the owner on Apr 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlexeme.cxx
More file actions
120 lines (113 loc) · 4.89 KB
/
Copy pathlexeme.cxx
File metadata and controls
120 lines (113 loc) · 4.89 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "lexeme.h"
#include <iostream>
namespace sap
{
const char* const lex::type_STRINGS[] = { "SYMBOL"
, "INDENT"
, "DEDENT"
, "NEWLINE"
, "Double const"
, "Bool const"
, "Str const"
, "RESERVED"
, "IDENTIFIER"
, "RULE"
, "Epsilon"
}; // type_STRINGS
const char* const lex::symbol_STRINGS[] = { ","
, "."
, "("
, ")"
, "+"
, "-"
, "*"
, "/"
, "=="
, "="
, "<"
, ">"
, "!="
, ":"
}; // symbol_STRINGS
const char* const lex::reserved_STRINGS[] = { "def"
, "class"
, "if"
, "else"
, "while"
, "break"
, "return"
, "print"
, "input"
}; // reserved_STRINGS
const char* const lex::rule_STRINGS[] = { "{applicable}"
, "{assignment}"
, "{class-decl}"
, "{class-list}"
, "{classes}"
, "{comparator-eq}"
, "{comparator-int}"
, "{elseline}"
, "{expr-int}"
, "{fcall}"
, "{ifline}"
, "{input}"
, "{logic-bool}"
, "{logic-int}"
, "{logic-str}"
, "{logic}"
, "{mcall}"
, "{method-decl}"
, "{method-list}"
, "{methods}"
, "{mparams}"
, "{mparam-list}"
, "{operand-int}"
, "{operand-bool}"
, "{operand-str}"
, "{operator-int}"
, "{param-list}"
, "{params}"
, "{rightside}"
, "{sline-list}"
, "{slines}"
, "{sline}"
, "{start}"
, "{whileline}"
, "{new_identifier}"
, "{breakline}"
, "{returnline}"
, "{printline}"
}; // rule_STRINGS
std::ostream& operator<<( std::ostream& out, lex::type rhs )
{
out << lex::type_STRINGS[ static_cast< uint8_t >( rhs ) ];
return out;
}
std::ostream& operator<<( std::ostream& out, lex::symbol rhs )
{
out << lex::symbol_STRINGS[ static_cast< uint8_t >( rhs ) ];
return out;
}
std::ostream& operator<<( std::ostream& out, lex::reserved_word rhs )
{
out << lex::reserved_STRINGS[ static_cast< uint8_t >( rhs ) ];
return out;
}
std::ostream& operator<<( std::ostream& out, lex::rule rhs )
{
out << lex::rule_STRINGS[ static_cast< uint8_t >( rhs ) ];
return out;
}
std::ostream& operator<<( std::ostream& out, lex rhs )
{
out << "«"
<< "type: '"
<< rhs.type_
<< '\''
<< ", value: '"
<< rhs.value_
<< '\''
<< "»";
return out;
}
} // namespace sap