aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.cli6
-rw-r--r--libbuild2/lexer+eval.test.testscript4
-rw-r--r--libbuild2/lexer.cxx8
-rw-r--r--libbuild2/parser.cxx8
-rw-r--r--libbuild2/token.cxx3
-rw-r--r--libbuild2/token.hxx1
6 files changed, 25 insertions, 5 deletions
diff --git a/doc/manual.cli b/doc/manual.cli
index f6039d6..cb6c1ec 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -3465,7 +3465,11 @@ Note that \c{?:} (ternary operator) and \c{!} (logical not) are
right-associative. Unlike C++, all the comparison operators have the same
precedence. A qualified name cannot be combined with any other operator
(including ternary) unless enclosed in parentheses. The \c{eval} option in the
-\c{eval-value} production shall contain a single value only (no commas).|
+\c{eval-value} production shall contain a single value only (no commas).
+
+Additionally, the \c{`} (backtick) and \c{|} (bitwise or) tokens are reserved
+for future support of arithmetic evaluation contexts and evaluation pipelines,
+respectively.|
A function call starts with \c{$} followed by its name and an eval context
listing its arguments. Note that there is no space between the name and
diff --git a/libbuild2/lexer+eval.test.testscript b/libbuild2/lexer+eval.test.testscript
index 75c8fce..53c5923 100644
--- a/libbuild2/lexer+eval.test.testscript
+++ b/libbuild2/lexer+eval.test.testscript
@@ -27,7 +27,9 @@ EOO
: logical
:
$* <:'x|x||x&x&&x!x!!x)' >>EOO
-'x|x'
+'x'
+|
+'x'
||
'x&x'
&&
diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx
index ff7be02..9b7d01e 100644
--- a/libbuild2/lexer.cxx
+++ b/libbuild2/lexer.cxx
@@ -120,8 +120,8 @@ namespace build2
// NOTE: remember to update special() lambda in parse_names() if
// adding any new single-character tokens to the eval mode.
//
- s1 = ":<>=!&|?, $(){}#\t\n";
- s2 = " = &| ";
+ s1 = ":<>=!&|?,` $(){}#\t\n";
+ s2 = " = & ";
break;
}
case lexer_mode::buildspec:
@@ -478,6 +478,7 @@ namespace build2
case '$': return make_token (type::dollar);
case '?': return make_token (type::question);
case ',': return make_token (type::comma);
+ case '`': return make_token (type::backtick);
case '(': return make_token (type::lparen);
case ')':
{
@@ -498,7 +499,7 @@ namespace build2
type r (type::eos);
switch (c)
{
- case '|': if (p == '|') r = type::log_or; break;
+ case '|': r = (p == '|' ? type::log_or : type::bit_or); break;
case '&': if (p == '&') r = type::log_and; break;
case '<': r = (p == '=' ? type::less_equal : type::less); break;
@@ -514,6 +515,7 @@ namespace build2
switch (r)
{
+ case type::bit_or:
case type::less:
case type::greater:
case type::log_not: break;
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 2255947..711c5f0 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -4038,6 +4038,12 @@ namespace build2
values r (parse_eval_comma (t, tt, pmode, true));
+ if (tt == type::backtick) // @@ TMP
+ fail (t) << "arithmetic evaluation context not yet supported";
+
+ if (tt == type::bit_or) // @@ TMP
+ fail (t) << "evaluation pipeline not yet supported";
+
if (tt != type::rparen)
fail (t) << "unexpected " << t; // E.g., stray ':'.
@@ -5862,6 +5868,8 @@ namespace build2
case type::dollar: r = '$'; break;
case type::question: r = '?'; break;
case type::comma: r = ','; break;
+ case type::backtick: r = '`'; break;
+ case type::bit_or: r = '|'; break;
case type::log_not: r = '!'; break;
case type::lparen: r = '('; break;
case type::rparen: r = ')'; break;
diff --git a/libbuild2/token.cxx b/libbuild2/token.cxx
index 7ce85be..ab14388 100644
--- a/libbuild2/token.cxx
+++ b/libbuild2/token.cxx
@@ -53,6 +53,7 @@ namespace build2
case token_type::question: os << q << '?' << q; break;
case token_type::percent: os << q << '%' << q; break;
case token_type::comma: os << q << ',' << q; break;
+ case token_type::backtick: os << q << '`' << q; break;
case token_type::lparen: os << q << '(' << q; break;
case token_type::rparen: os << q << ')' << q; break;
@@ -81,6 +82,8 @@ namespace build2
case token_type::less_equal: os << q << "<=" << q; break;
case token_type::greater_equal: os << q << ">=" << q; break;
+ case token_type::bit_or: os << q << '|' << q; break;
+
case token_type::log_or: os << q << "||" << q; break;
case token_type::log_and: os << q << "&&" << q; break;
case token_type::log_not: os << q << '!' << q; break;
diff --git a/libbuild2/token.hxx b/libbuild2/token.hxx
index 7344ecd..030ab48 100644
--- a/libbuild2/token.hxx
+++ b/libbuild2/token.hxx
@@ -37,6 +37,7 @@ namespace build2
question, // ?
percent, // %
comma, // ,
+ backtick, // `
lparen, // (
rparen, // )