aboutsummaryrefslogtreecommitdiff
path: root/build/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-09 15:56:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-09 15:56:54 +0200
commitea66709a853255c7957a8a7907fd21fa7f6cfd3f (patch)
tree061f828174b4a1d9d5c5fbc0b3b7427b5eea1ee8 /build/parser.cxx
parent8a9870ed59225972de389b7b4a494a57390bff1b (diff)
Add support for quoting directive names
Now only unquoted, literal names are recognized as directives, for example: 'print' = abc print $print
Diffstat (limited to 'build/parser.cxx')
-rw-r--r--build/parser.cxx27
1 files changed, 14 insertions, 13 deletions
diff --git a/build/parser.cxx b/build/parser.cxx
index 42b9a98..1ceb193 100644
--- a/build/parser.cxx
+++ b/build/parser.cxx
@@ -90,11 +90,12 @@ namespace build
tt != type::colon) // Empty name: ': ...'
break; // Something else. Let our caller handle that.
- // See if this is one of the keywords.
+ // See if this is one of the directives. This should be an
+ // unquoted literal name.
//
- if (tt == type::name)
+ if (tt == type::name && !t.quoted)
{
- const string& n (t.name ());
+ const string& n (t.value);
if (n == "print")
{
@@ -642,7 +643,7 @@ namespace build
if (at == token_type::equal || at == token_type::plus_equal)
{
- var = &variable_pool.find (t.name ());
+ var = &variable_pool.find (t.value);
val = at == token_type::equal
? &scope_->assign (*var)
: &scope_->append (*var);
@@ -857,10 +858,10 @@ namespace build
if (!concat.empty () &&
((tt != type::name &&
tt != type::dollar &&
- tt != type::lparen) || peeked ().separated ()))
+ tt != type::lparen) || peeked ().separated))
{
tt = type::name;
- t = token (move (concat), true, t.line (), t.column ());
+ t = token (move (concat), true, false, t.line, t.column);
concat.clear ();
}
else if (!first)
@@ -870,7 +871,7 @@ namespace build
//
if (tt == type::name)
{
- string name (t.name ()); //@@ move?
+ string name (t.value); //@@ move?
tt = peek ();
// Should we accumulate? If the buffer is not empty, then
@@ -881,7 +882,7 @@ namespace build
//
if (!concat.empty () || // Continue.
((tt == type::dollar ||
- tt == type::lparen) && !peeked ().separated ())) // Start.
+ tt == type::lparen) && !peeked ().separated)) // Start.
{
concat += name;
continue;
@@ -1062,7 +1063,7 @@ namespace build
string n;
if (tt == type::name)
- n = t.name ();
+ n = t.value;
else if (tt == type::lparen)
{
lexer_->expire_mode ();
@@ -1159,7 +1160,7 @@ namespace build
if (!concat.empty () || // Continue.
((tt == type::name || // Start.
tt == type::dollar ||
- tt == type::lparen) && !peeked ().separated ()))
+ tt == type::lparen) && !peeked ().separated))
{
// This should be a simple value or a simple directory. The
// token still points to the name (or closing paren).
@@ -1642,7 +1643,7 @@ namespace build
peeked_ = false;
}
- tt = t.type ();
+ tt = t.type;
return tt;
}
@@ -1655,7 +1656,7 @@ namespace build
peeked_ = true;
}
- return peek_.type ();
+ return peek_.type;
}
static location
@@ -1663,6 +1664,6 @@ namespace build
{
assert (data != nullptr);
const string& p (**static_cast<const string* const*> (data));
- return location (p.c_str (), t.line (), t.column ());
+ return location (p.c_str (), t.line, t.column);
}
}