diff options
Diffstat (limited to 'src/parsers.cc')
-rw-r--r-- | src/parsers.cc | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/src/parsers.cc b/src/parsers.cc index 4920496..ea73287 100644 --- a/src/parsers.cc +++ b/src/parsers.cc @@ -74,14 +74,12 @@ void Tokenizer::SkipWhitespace(bool newline) { if (token_.type_ == Token::NEWLINE && newline) Newline(NULL); - const char kContinuation = makefile_flavor_ ? '\\' : '$'; - while (cur_ < end_) { if (*cur_ == ' ') { ++cur_; } else if (newline && *cur_ == '\n') { Newline(NULL); - } else if (*cur_ == kContinuation && cur_ + 1 < end_ && cur_[1] == '\n') { + } else if (*cur_ == '$' && cur_ + 1 < end_ && cur_[1] == '\n') { ++cur_; ++cur_; } else if (*cur_ == '#' && cur_ == cur_line_) { while (cur_ < end_ && *cur_ != '\n') @@ -166,23 +164,10 @@ bool Tokenizer::ReadIdent(string* out) { return true; } -// A note on backslashes in Makefiles, from reading the docs: -// Backslash-newline is the line continuation character. -// Backslash-# escapes a # (otherwise meaningful as a comment start). -// Backslash-% escapes a % (otherwise meaningful as a special). -// Finally, quoting the GNU manual, "Backslashes that are not in danger -// of quoting ‘%’ characters go unmolested." -// How do you end a line with a backslash? The netbsd Make docs suggest -// reading the result of a shell command echoing a backslash! -// -// Rather than implement the above, we do the simpler thing here. -// If anyone actually has depfiles that rely on the more complicated -// behavior we can adjust this. bool Tokenizer::ReadToNewline(string *text, string* err, size_t max_length) { // XXX token_.clear(); - const char kContinuation = makefile_flavor_ ? '\\' : '$'; while (cur_ < end_ && *cur_ != '\n') { - if (*cur_ == kContinuation) { + if (*cur_ == '$') { // Might be a line continuation; peek ahead to check. if (cur_ + 1 >= end_) return Error("unexpected eof", err); @@ -212,7 +197,7 @@ Token::Type Tokenizer::PeekToken() { return token_.type_; token_.pos_ = cur_; - if (!makefile_flavor_ && cur_indent_ == -1) { + if (cur_indent_ == -1) { cur_indent_ = cur_ - cur_line_; if (cur_indent_ != last_indent_) { if (cur_indent_ > last_indent_) { @@ -271,32 +256,6 @@ void Tokenizer::ConsumeToken() { token_.Clear(); } -MakefileParser::MakefileParser() { - tokenizer_.SetMakefileFlavor(); -} - -bool MakefileParser::Parse(const string& input, string* err) { - tokenizer_.Start(input.data(), input.data() + input.size()); - - tokenizer_.SkipWhitespace(true); - - if (!tokenizer_.ReadIdent(&out_)) - return tokenizer_.ErrorExpected("output filename", err); - if (!tokenizer_.ExpectToken(Token::COLON, err)) - return false; - while (tokenizer_.PeekToken() == Token::IDENT) { - StringPiece in; - tokenizer_.ReadIdent(&in); - ins_.push_back(in); - } - if (!tokenizer_.ExpectToken(Token::NEWLINE, err)) - return false; - if (!tokenizer_.ExpectToken(Token::TEOF, err)) - return false; - - return true; -} - ManifestParser::ManifestParser(State* state, FileReader* file_reader) : state_(state), file_reader_(file_reader) { env_ = &state->bindings_; |