summaryrefslogtreecommitdiffstats
path: root/src/parsers.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-01-23 04:51:52 (GMT)
committerEvan Martin <martine@danga.com>2011-01-23 04:51:52 (GMT)
commita206206f3ff6c118f89cce04bf39f424bd1a6510 (patch)
treefad94b150e9d2bed7fdc48ec80d5f180e1298982 /src/parsers.cc
parentc1cb4f5ee82b1d41a5fb028aea0c6daa0461f050 (diff)
downloadNinja-a206206f3ff6c118f89cce04bf39f424bd1a6510.zip
Ninja-a206206f3ff6c118f89cce04bf39f424bd1a6510.tar.gz
Ninja-a206206f3ff6c118f89cce04bf39f424bd1a6510.tar.bz2
allow implicit deps
Diffstat (limited to 'src/parsers.cc')
-rw-r--r--src/parsers.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/parsers.cc b/src/parsers.cc
index 7b810fe..f309854 100644
--- a/src/parsers.cc
+++ b/src/parsers.cc
@@ -20,6 +20,7 @@ string Token::AsString() const {
case EQUALS: return "'='";
case COLON: return "':'";
case PIPE: return "'|'";
+ case PIPE2: return "'||'";
case TEOF: return "eof";
case INDENT: return "indenting in";
case OUTDENT: return "indenting out";
@@ -181,8 +182,13 @@ Token::Type Tokenizer::PeekToken() {
token_.type_ = Token::EQUALS;
++cur_;
} else if (*cur_ == '|') {
- token_.type_ = Token::PIPE;
- ++cur_;
+ if (cur_ + 1 < end_ && cur_[1] == '|') {
+ token_.type_ = Token::PIPE2;
+ cur_ += 2;
+ } else {
+ token_.type_ = Token::PIPE;
+ ++cur_;
+ }
} else if (*cur_ == '\n') {
token_.type_ = Token::NEWLINE;
++cur_;
@@ -413,7 +419,7 @@ bool ManifestParser::ParseEdge(string* err) {
}
// Add all order-only deps, counting how many as we go.
- int order_only = 0;
+ int implicit = 0;
if (tokenizer_.PeekToken() == Token::PIPE) {
tokenizer_.ConsumeToken();
for (;;) {
@@ -421,6 +427,19 @@ bool ManifestParser::ParseEdge(string* err) {
if (!tokenizer_.ReadIdent(&in))
break;
ins.push_back(in);
+ ++implicit;
+ }
+ }
+
+ // Add all order-only deps, counting how many as we go.
+ int order_only = 0;
+ if (tokenizer_.PeekToken() == Token::PIPE2) {
+ tokenizer_.ConsumeToken();
+ for (;;) {
+ string in;
+ if (!tokenizer_.ReadIdent(&in))
+ break;
+ ins.push_back(in);
++order_only;
}
}
@@ -467,6 +486,7 @@ bool ManifestParser::ParseEdge(string* err) {
state_->AddIn(edge, *i);
for (vector<string>::iterator i = outs.begin(); i != outs.end(); ++i)
state_->AddOut(edge, *i);
+ edge->implicit_deps_ = implicit;
edge->order_only_deps_ = order_only;
return true;