diff options
author | Nico Weber <nicolasweber@gmx.de> | 2018-04-06 16:43:49 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2018-04-06 16:45:32 (GMT) |
commit | 001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4 (patch) | |
tree | dc94861ab8065feb21e438fb3a745cd0ed82fe59 /src/lexer.in.cc | |
parent | 04ba59b2ad986bd5765b14c5b497ccb0a2e909d4 (diff) | |
download | Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.zip Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.tar.gz Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.tar.bz2 |
Improve location of error messages around identifiers.
Lexer::ReadIdent() now sets last_token_ before returning, like
Lexer::ReadEvalString() does. So all "expected identifiers" and things
that call ReadIdent (pool parser, rule parser, let parser, code parsing
the rule name after a : in a build line) now point the "^ near here" at
what was there instead of the previous last_token
According to manifest_parser_perftest, this is perf-neutral.
Diffstat (limited to 'src/lexer.in.cc')
-rw-r--r-- | src/lexer.in.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lexer.in.cc b/src/lexer.in.cc index f861239..20ed442 100644 --- a/src/lexer.in.cc +++ b/src/lexer.in.cc @@ -182,16 +182,21 @@ void Lexer::EatWhitespace() { bool Lexer::ReadIdent(string* out) { const char* p = ofs_; + const char* start; for (;;) { - const char* start = p; + start = p; /*!re2c varname { out->assign(start, p - start); break; } - [^] { return false; } + [^] { + last_token_ = start; + return false; + } */ } + last_token_ = start; ofs_ = p; EatWhitespace(); return true; |