115 : dfa.fTransitions) {
116 states =
std::max(states, row.size());
117 }
118 out <<
"using State = " << (states <= 256 ?
"uint8_t" :
"uint16_t") <<
";\n";
119
120
121 size_t startChar = 0;
122 for (; startChar < dfa.fCharMappings.size(); ++startChar) {
123 if (dfa.fCharMappings[startChar] != 0) {
124 break;
125 }
126 }
127
128
129
131 out <<
"static constexpr uint8_t kInvalidChar = 18;";
132 out <<
"static constexpr uint8_t kMappings[" << dfa.fCharMappings.size() - startChar <<
"] = {";
133 for (size_t index = startChar; index < dfa.fCharMappings.size(); ++index) {
135 }
137
139
140 out <<
"static const uint8_t kAccepts[" << states <<
"] = {";
141 for (
size_t i = 0;
i < states; ++
i) {
142 if (
i < dfa.fAccepts.size() && dfa.fAccepts[
i] !=
INVALID) {
143 out <<
" " << dfa.fAccepts[
i] <<
",";
144 } else {
146 }
147 }
150
151 out << token <<
" " << lexer <<
"::next() {";
153 // Note that we cheat here: normally a lexer needs to worry about the case
154 // where a token has a prefix which is not itself a valid token - for instance,
void WriteTransitionTable(std::ofstream &out, const DFA &dfa, size_t states)
static float max(float r, float g, float b)
static SkString to_string(int n)