aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/lexer.cxx16
-rw-r--r--build2/parser17
-rw-r--r--build2/parser.cxx2
-rw-r--r--build2/token3
-rw-r--r--build2/token.cxx2
-rw-r--r--old-tests/pairs/buildfile3
-rw-r--r--old-tests/pairs/test.out1
7 files changed, 19 insertions, 25 deletions
diff --git a/build2/lexer.cxx b/build2/lexer.cxx
index d3afdb0..e117f28 100644
--- a/build2/lexer.cxx
+++ b/build2/lexer.cxx
@@ -119,9 +119,11 @@ namespace build2
xchar c (get ());
uint64_t ln (c.line), cn (c.column);
- auto make_token = [&sep, ln, cn] (type t)
+ auto make_token = [&sep, ln, cn] (type t, string v = string ())
{
- return token (t, sep, ln, cn, token_printer);
+ return token (t, move (v),
+ sep, quote_type::unquoted, false,
+ ln, cn, token_printer);
};
if (eos (c))
@@ -130,7 +132,7 @@ namespace build2
// Handle pair separator.
//
if (c == st.sep_pair)
- return make_token (type::pair_separator);
+ return make_token (type::pair_separator, string (1, c));
switch (c)
{
@@ -232,9 +234,11 @@ namespace build2
uint64_t ln (c.line), cn (c.column);
- auto make_token = [sep, ln, cn] (type t)
+ auto make_token = [sep, ln, cn] (type t, string v = string ())
{
- return token (t, sep, ln, cn, token_printer);
+ return token (t, move (v),
+ sep, quote_type::unquoted, false,
+ ln, cn, token_printer);
};
// This mode is quite a bit like the value mode when it comes to special
@@ -244,7 +248,7 @@ namespace build2
// Handle pair separator.
//
if (c == st.sep_pair)
- return make_token (type::pair_separator);
+ return make_token (type::pair_separator, string (1, c));
// Note: we don't treat [ and ] as special here. Maybe can use them for
// something later.
diff --git a/build2/parser b/build2/parser
index 7ca9366..16b7782 100644
--- a/build2/parser
+++ b/build2/parser
@@ -395,7 +395,7 @@ namespace build2
//
if (peeked_)
{
- assert (peek_.mode == m && peek_.pair_separator == ps);
+ assert (peek_.mode == m);
return peek_.token.type;
}
@@ -436,18 +436,6 @@ namespace build2
}
}
- char
- pair_separator () const
- {
- if (replay_ != replay::play)
- return lexer_->pair_separator ();
- else
- {
- assert (replay_i_ != replay_data_.size ());
- return replay_data_[replay_i_].pair_separator;
- }
- }
-
void
expire_mode ()
{
@@ -552,8 +540,7 @@ namespace build2
lexer_next ()
{
lexer_mode m (lexer_->mode ()); // Get it first since it may expire.
- char ps (lexer_->pair_separator ());
- return replay_token {lexer_->next (), path_, m, ps};
+ return replay_token {lexer_->next (), path_, m};
}
const replay_token&
diff --git a/build2/parser.cxx b/build2/parser.cxx
index b95aeae..cfd18c6 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -3585,7 +3585,7 @@ namespace build2
fail (t) << "multiple " << what << "s on the left hand side "
<< "of a pair";
- ns.back ().pair = pair_separator ();
+ ns.back ().pair = t.value[0];
// If the next token is separated, then we have an empty RHS. Note
// that the case where it is not a name/group (e.g., a newline/eos)
diff --git a/build2/token b/build2/token
index e43e66d..d58aebd 100644
--- a/build2/token
+++ b/build2/token
@@ -27,7 +27,7 @@ namespace build2
eos,
newline,
word,
- pair_separator,
+ pair_separator, // token::value[0] is the pair separator char.
colon, // :
dollar, // $
@@ -156,7 +156,6 @@ namespace build2
build2::token token;
const path* file;
lexer_mode_base mode;
- char pair_separator;
using location_type = build2::location;
diff --git a/build2/token.cxx b/build2/token.cxx
index a721239..6f2eae5 100644
--- a/build2/token.cxx
+++ b/build2/token.cxx
@@ -19,7 +19,7 @@ namespace build2
{
case token_type::eos: os << "<end of file>"; break;
case token_type::newline: os << "<newline>"; break;
- case token_type::pair_separator: os << "<pair separator>"; break;
+ case token_type::pair_separator: os << "<pair separator " << t.value[0] << ">"; break;
case token_type::word: os << '\'' << t.value << '\''; break;
case token_type::colon: os << q << ':' << q; break;
diff --git a/old-tests/pairs/buildfile b/old-tests/pairs/buildfile
index 3b55044..4068be3 100644
--- a/old-tests/pairs/buildfile
+++ b/old-tests/pairs/buildfile
@@ -37,4 +37,7 @@ print foo@{bar BAR} # foo@bar foo@BAR
#print @@ # error: double pair separator
+v=foo
+print @"$v"
+
./:
diff --git a/old-tests/pairs/test.out b/old-tests/pairs/test.out
index 6033c84..f7280ac 100644
--- a/old-tests/pairs/test.out
+++ b/old-tests/pairs/test.out
@@ -25,3 +25,4 @@ foo@{}
{}@bar {}@BAR
{}@bar {}@BAR
foo@bar foo@BAR
+{}@foo