diff options
author | Evan Martin <martine@danga.com> | 2011-12-29 21:00:27 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-12-29 21:14:39 (GMT) |
commit | 8a0c96075786c1983bdfa2f37f32b75200ea0334 (patch) | |
tree | 95e2b0c24aedcda9ec5ed09329e69fd7a1925212 /src/ninja.cc | |
parent | ad7d9f43f1bd8e04321d8fdb07ebf7b96ab525a1 (diff) | |
download | Ninja-8a0c96075786c1983bdfa2f37f32b75200ea0334.zip Ninja-8a0c96075786c1983bdfa2f37f32b75200ea0334.tar.gz Ninja-8a0c96075786c1983bdfa2f37f32b75200ea0334.tar.bz2 |
switch the core ninja parser to use re2c for the lexer
- Delete the old "Tokenizer" code.
- Write separate tests for the lexer distinct from the parser.
- Switch the parser to use the new code.
- New lexer error output has file:line numbers so e.g. Emacs can
jump your editor to the syntax error.
- The EvalEnv ($-interpolation) code is now part of the lexer as well.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r-- | src/ninja.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ninja.cc b/src/ninja.cc index 452f075..e08f2fc 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -364,12 +364,15 @@ int CmdTargets(State* state, int argc, char* argv[]) { int CmdRules(State* state, int argc, char* /* argv */[]) { for (map<string, const Rule*>::iterator i = state->rules_.begin(); i != state->rules_.end(); ++i) { - if (i->second->description().unparsed_.empty()) { + if (i->second->description().empty()) { printf("%s\n", i->first.c_str()); } else { printf("%s: %s\n", i->first.c_str(), - i->second->description().unparsed_.c_str()); + // XXX I changed it such that we don't have an easy way + // to get the source text anymore, so this output is + // unsatisfactory. How useful is this command, anyway? + i->second->description().Serialize().c_str()); } } return 0; @@ -547,7 +550,10 @@ reload: ManifestParser parser(&state, &file_reader); string err; if (!parser.Load(input_file, &err)) { - Error("loading '%s': %s", input_file, err.c_str()); + // The pattern in Ninja for errors is to return a one-line string, + // but parse errors are special in that they are multiline with + // context. Just report it verbatim. + fprintf(stderr, "%s", err.c_str()); return 1; } |