29 :
Parser(state, file_reader)
35 lexer_.Start(filename, input);
39 bool haveDyndepVersion =
false;
45 if (!haveDyndepVersion)
46 return lexer_.Error(
"expected 'ninja_dyndep_version = ...'", err);
53 if (haveDyndepVersion)
58 haveDyndepVersion =
true;
64 if (!haveDyndepVersion)
65 return lexer_.Error(
"expected 'ninja_dyndep_version = ...'", err);
80 if (!
ParseLet(&name, &let_value, err))
82 if (name !=
"ninja_dyndep_version") {
83 return lexer_.Error(
"expected 'ninja_dyndep_version = ...'", err);
88 if (major != 1 || minor != 0) {
90 string(
"unsupported 'ninja_dyndep_version = ") + version +
"'", err);
96 if (!
lexer_.ReadIdent(key))
97 return lexer_.Error(
"expected variable name", err);
107 if (!
lexer_.ReadPath(&out0, err))
110 return lexer_.Error(
"expected path", err);
114 return lexer_.Error(
"empty path", err);
119 return lexer_.Error(
"no build statement exists for '" + path +
"'", err);
121 std::pair<DyndepFile::iterator, bool> res =
124 return lexer_.Error(
"multiple statements for '" + path +
"'", err);
125 dyndeps = &res.first->second;
131 if (!
lexer_.ReadPath(&out, err))
134 return lexer_.Error(
"explicit outputs not supported", err);
138 vector<EvalString> outs;
142 if (!
lexer_.ReadPath(&out, err))
154 if (!
lexer_.ReadIdent(&rule_name) || rule_name !=
"dyndep")
155 return lexer_.Error(
"expected build command name 'dyndep'", err);
160 if (!
lexer_.ReadPath(&in, err))
163 return lexer_.Error(
"explicit inputs not supported", err);
167 vector<EvalString> ins;
171 if (!
lexer_.ReadPath(&in, err))
181 return lexer_.Error(
"order-only inputs not supported", err);
192 return lexer_.Error(
"binding is not 'restat'", err);
194 dyndeps->
restat_ = !value.empty();
199 string path = in.Evaluate(&
env_);
201 return lexer_.Error(
"empty path", err);
210 string path = out.Evaluate(&
env_);
212 return lexer_.Error(
"empty path", err);
Store data loaded from one dyndep file.
bool ParseEdge(std::string *err)
bool ParseLet(std::string *key, EvalString *val, std::string *err)
DyndepFile * dyndep_file_
bool ParseDyndepVersion(std::string *err)
bool Parse(const std::string &filename, const std::string &input, std::string *err)
Parse a file, given its contents as a string.
DyndepParser(State *state, FileReader *file_reader, DyndepFile *dyndep_file)
Store dynamically-discovered dependency information for one edge.
std::vector< Node * > implicit_inputs_
std::vector< Node * > implicit_outputs_
An edge in the dependency graph; links between Nodes using Rules.
A tokenized string that contains variable references.
std::string Evaluate(Env *env) const
Interface for reading files from disk.
static const char * TokenName(Token t)
Return a human-readable form of a token, used in error messages.
Information about a node in the dependency graph: the file, whether it's dirty, mtime,...
bool ExpectToken(Lexer::Token expected, std::string *err)
If the next token is not expected, produce an error string saying "expected foo, got bar".
Parser(State *state, FileReader *file_reader)
Global state (file status) for a single run.
void CanonicalizePath(string *path, uint64_t *slash_bits)
void ParseVersion(const string &version, int *major, int *minor)
unsigned long long uint64_t