summaryrefslogtreecommitdiffstats
path: root/src/parsers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/parsers.cc')
-rw-r--r--src/parsers.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/parsers.cc b/src/parsers.cc
index 849a3e1..567be6b 100644
--- a/src/parsers.cc
+++ b/src/parsers.cc
@@ -148,15 +148,24 @@ bool Tokenizer::ExpectIdent(const char* expected, string* err) {
return true;
}
-bool Tokenizer::ReadIdent(string* out) {
+bool Tokenizer::ReadIdent(StringPiece* out) {
PeekToken();
if (token_.type_ != Token::IDENT)
return false;
- out->assign(token_.pos_, token_.end_ - token_.pos_);
+ out->str_ = token_.pos_;
+ out->len_ = token_.end_ - token_.pos_;
ConsumeToken();
return true;
}
+bool Tokenizer::ReadIdent(string* out) {
+ StringPiece token;
+ if (!ReadIdent(&token))
+ return false;
+ out->assign(token.str_, token.len_);
+ 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).
@@ -276,7 +285,7 @@ bool MakefileParser::Parse(const string& input, string* err) {
if (!tokenizer_.ExpectToken(Token::COLON, err))
return false;
while (tokenizer_.PeekToken() == Token::IDENT) {
- string in;
+ StringPiece in;
tokenizer_.ReadIdent(&in);
ins_.push_back(in);
}