Comments begin with `#` and extend to the end of the line.
Newlines are significant, but they can be escaped by putting a `$`
-before them.
+before them. To produce a literal `$` in a path or variable value use
+`$$`.
Other whitespace is only significant if it's at the beginning of a
line. If a line is intended more than the previous one, it's
}
parsed_.push_back(make_pair(input.substr(start, end - start), SPECIAL));
++end;
+ } else if (start < input.size() && input[start] == '$') {
+ parsed_.push_back(make_pair("$", RAW));
+ end = start + 1;
} else {
for (end = start; end < input.size(); ++end) {
char c = input[end];
env.vars["var"] = "barbar";
EXPECT_EQ("foo barbarbaz", str.Evaluate(&env));
}
+TEST(EvalString, Dollars) {
+ EvalString str;
+ string err;
+ EXPECT_TRUE(str.Parse("foo$$bar$bar", &err));
+ ASSERT_EQ("", err);
+ TestEnv env;
+ env.vars["bar"] = "baz";
+ EXPECT_EQ("foo$barbaz", str.Evaluate(&env));
+}
struct StatTest : public StateTestWithBuiltinRules,
public DiskInterface {
EXPECT_EQ("not # a comment", state.bindings_.LookupVariable("foo"));
}
+TEST_F(ParserTest, Dollars) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(
+"rule foo\n"
+" command = ${out}bar$$baz$$$\n"
+"blah\n"
+"x = $$dollar\n"
+"build $x: foo y\n"
+));
+ EXPECT_EQ("$dollar", state.bindings_.LookupVariable("x"));
+ EXPECT_EQ("$dollarbar$baz$blah", state.edges_[0]->EvaluateCommand());
+}
+
TEST_F(ParserTest, CanonicalizeFile) {
ASSERT_NO_FATAL_FAILURE(AssertParse(
"rule cat\n"