52 char* in = &(*content)[0];
53 char* end = in + content->size();
54 bool have_target =
false;
55 bool parsing_targets =
true;
56 bool poisoned_input =
false;
59 bool have_newline =
false;
67 const char* start = in;
68 char* yymarker = NULL;
72 static const unsigned char yybm[] = {
73 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 128, 128, 0, 0, 128, 128, 128,
78 128, 128, 0, 128, 128, 128, 128, 128,
79 128, 128, 128, 128, 128, 128, 128, 128,
80 128, 128, 128, 0, 0, 128, 0, 128,
81 128, 128, 128, 128, 128, 128, 128, 128,
82 128, 128, 128, 128, 128, 128, 128, 128,
83 128, 128, 128, 128, 128, 128, 128, 128,
84 128, 128, 128, 128, 0, 128, 0, 128,
85 0, 128, 128, 128, 128, 128, 128, 128,
86 128, 128, 128, 128, 128, 128, 128, 128,
87 128, 128, 128, 128, 128, 128, 128, 128,
88 128, 128, 128, 128, 0, 128, 128, 0,
89 128, 128, 128, 128, 128, 128, 128, 128,
90 128, 128, 128, 128, 128, 128, 128, 128,
91 128, 128, 128, 128, 128, 128, 128, 128,
92 128, 128, 128, 128, 128, 128, 128, 128,
93 128, 128, 128, 128, 128, 128, 128, 128,
94 128, 128, 128, 128, 128, 128, 128, 128,
95 128, 128, 128, 128, 128, 128, 128, 128,
96 128, 128, 128, 128, 128, 128, 128, 128,
97 128, 128, 128, 128, 128, 128, 128, 128,
98 128, 128, 128, 128, 128, 128, 128, 128,
99 128, 128, 128, 128, 128, 128, 128, 128,
100 128, 128, 128, 128, 128, 128, 128, 128,
101 128, 128, 128, 128, 128, 128, 128, 128,
102 128, 128, 128, 128, 128, 128, 128, 128,
103 128, 128, 128, 128, 128, 128, 128, 128,
104 128, 128, 128, 128, 128, 128, 128, 128,
107 if (yybm[0+yych] & 128) {
112 if (yych >= 0x01)
goto yy1;
114 if (yych <=
'\n')
goto yy3;
115 if (yych <=
'\f')
goto yy1;
120 if (yych <=
'#')
goto yy1;
123 if (yych <= '>
') goto yy1;
124 if (yych <= '\\
') goto yy8;
136 // For any other character (e.g. whitespace), swallow it here,
137 // allowing the outer logic to loop around again.
143 // A newline ends the current file name and the current rule.
149 if (yych == '\n
') goto yy3;
153 if (yybm[0+yych] & 128) {
158 // Got a span of plain text.
159 int len = (int)(in - start);
160 // Need to shift it over if we're overwriting backslashes.
162 memmove(out, start, len);
168 if (yych ==
'$')
goto yy9;
171 yych = *(yymarker = ++in);
174 if (yych <= 0x00)
goto yy2;
175 if (yych <=
'\t')
goto yy10;
178 if (yych ==
'\r')
goto yy12;
179 if (yych <= 0x1F)
goto yy10;
184 if (yych ==
'#')
goto yy14;
187 if (yych <=
':')
goto yy15;
188 if (yych ==
'\\')
goto yy17;
210 if (yych ==
'\n')
goto yy11;
217 int len = (int)(in - start);
220 memset(out,
'\\', n);
229 int len = (int)(in - start);
230 if (len > 2 && out < start)
231 memset(out,
'\\', len - 2);
239 if (yych <= 0x00)
goto yy18;
240 if (yych <= 0x08)
goto yy16;
241 if (yych <=
'\n')
goto yy18;
243 if (yych <=
'\r')
goto yy18;
244 if (yych ==
' ')
goto yy18;
251 int len = (int)(in - start);
252 if (len > 2 && out < start)
253 memset(out,
'\\', len - 2);
262 if (yych <= 0x00)
goto yy6;
263 if (yych <=
'\t')
goto yy10;
266 if (yych ==
'\r')
goto yy6;
267 if (yych <= 0x1F)
goto yy10;
272 if (yych ==
'#')
goto yy14;
275 if (yych <=
':')
goto yy15;
276 if (yych ==
'\\')
goto yy20;
285 int len = (int)(in - start - 1);
288 memmove(out, start, len);
290 if (*(in - 1) ==
'\n')
298 int len = (int)(in - start);
300 memset(out,
'\\', len - 1);
308 if (yych <= 0x00)
goto yy6;
309 if (yych <=
'\t')
goto yy10;
312 if (yych ==
'\r')
goto yy6;
313 if (yych <= 0x1F)
goto yy10;
318 if (yych ==
'#')
goto yy14;
321 if (yych <=
':')
goto yy15;
322 if (yych ==
'\\')
goto yy17;
330 int len = (int)(out - filename);
331 const bool is_dependency = !parsing_targets;
332 if (len > 0 && filename[len - 1] ==
':') {
334 parsing_targets =
false;
342 std::vector<StringPiece>::iterator pos = std::find(
ins_.begin(),
ins_.end(), piece);
343 if (pos ==
ins_.end()) {
345 if (poisoned_input) {
346 *err =
"inputs may not also have inputs";
350 ins_.push_back(piece);
354 outs_.push_back(piece);
356 }
else if (!is_dependency) {
358 poisoned_input =
true;
364 parsing_targets =
true;
365 poisoned_input =
false;
368 if (!have_target && !is_empty) {
369 *err =
"expected ':' in depfile";
bool Parse(std::string *content, std::string *err)
Parse an input file.
DepfileParser(DepfileParserOptions options=DepfileParserOptions())
std::vector< StringPiece > outs_
std::vector< StringPiece > ins_
StringPiece represents a slice of a string whose memory is managed externally.