aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-10-24 16:11:50 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:35 +0200
commitb0bed0e1205f44ae73850fac521f9162f29adef5 (patch)
tree27c8c1fe846dbc51abbcb582d82013917ba0096b
parent5c325b8613a4323ee47bd42ce6d962b9ab9f2d90 (diff)
Support >+ and <+ redirects in parser
-rw-r--r--build2/test/script/lexer.cxx6
-rw-r--r--build2/test/script/parser.cxx15
-rw-r--r--build2/test/script/script1
-rw-r--r--build2/test/script/script.cxx1
-rw-r--r--build2/test/script/token2
-rw-r--r--build2/test/script/token.cxx2
6 files changed, 25 insertions, 2 deletions
diff --git a/build2/test/script/lexer.cxx b/build2/test/script/lexer.cxx
index d6e35cb..ddab531 100644
--- a/build2/test/script/lexer.cxx
+++ b/build2/test/script/lexer.cxx
@@ -229,12 +229,13 @@ namespace build2
{
xchar p (peek ());
- if (p == '-' || p == ':' || p == '<')
+ if (p == '+' || p == '-' || p == ':' || p == '<')
{
get ();
switch (p)
{
+ case '+': return make_token (type::in_std);
case '-': return make_token (type::in_null);
case ':': return make_token (type::in_str_nn);
case '<':
@@ -261,12 +262,13 @@ namespace build2
{
xchar p (peek ());
- if (p == '-' || p == ':' || p == '>')
+ if (p == '+' || p == '-' || p == ':' || p == '>')
{
get ();
switch (p)
{
+ case '+': return make_token (type::out_std);
case '-': return make_token (type::out_null);
case ':': return make_token (type::out_str_nn);
case '>':
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 84368b4..183b8ac 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -506,6 +506,7 @@ namespace build2
//
switch (tt)
{
+ case type::in_std:
case type::in_null:
case type::in_str:
case type::in_str_nn:
@@ -517,6 +518,7 @@ namespace build2
break;
}
+ case type::out_std:
case type::out_null:
case type::out_str:
case type::out_str_nn:
@@ -533,6 +535,9 @@ namespace build2
redirect_type rt;
switch (tt)
{
+ case type::in_std:
+ case type::out_std: rt = redirect_type::std; break;
+
case type::in_null:
case type::out_null: rt = redirect_type::null; break;
@@ -553,6 +558,7 @@ namespace build2
switch (rt)
{
case redirect_type::none:
+ case redirect_type::std:
case redirect_type::null:
break;
case redirect_type::here_string:
@@ -595,6 +601,9 @@ namespace build2
break;
}
+ case type::in_std:
+ case type::out_std:
+
case type::in_null:
case type::out_null:
@@ -650,6 +659,9 @@ namespace build2
//
switch (tt)
{
+ case type::in_std:
+ case type::out_std:
+
case type::in_null:
case type::out_null:
@@ -789,6 +801,9 @@ namespace build2
//
switch (tt)
{
+ case type::in_std:
+ case type::out_std:
+
case type::in_null:
case type::out_null:
diff --git a/build2/test/script/script b/build2/test/script/script
index f1a3f50..639bba9 100644
--- a/build2/test/script/script
+++ b/build2/test/script/script
@@ -41,6 +41,7 @@ namespace build2
enum class redirect_type
{
none,
+ std,
null,
here_string, // Value is the string.
here_document // Value is the document.
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index 172533c..95e6344 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -40,6 +40,7 @@ namespace build2
switch (r.type)
{
case redirect_type::none: assert (false); break;
+ case redirect_type::std: o << '+'; break;
case redirect_type::null: o << '-'; break;
case redirect_type::here_string: to_stream_q (o, r.value); break;
case redirect_type::here_document:
diff --git a/build2/test/script/token b/build2/test/script/token
index d20309a..64c1a0c 100644
--- a/build2/test/script/token
+++ b/build2/test/script/token
@@ -31,12 +31,14 @@ namespace build2
log_and, // &&
log_or, // ||
+ in_std, // <+
in_null, // <-
in_str, // <
in_str_nn, // <:
in_doc, // <<
in_doc_nn, // <<:
+ out_std, // >+
out_null, // >-
out_str, // >
out_str_nn, // >:
diff --git a/build2/test/script/token.cxx b/build2/test/script/token.cxx
index 0a8ecf1..93f4f83 100644
--- a/build2/test/script/token.cxx
+++ b/build2/test/script/token.cxx
@@ -28,12 +28,14 @@ namespace build2
case token_type::log_and: os << q << "&&" << q; break;
case token_type::log_or: os << q << "||" << q; break;
+ case token_type::in_std: os << q << "<+" << q; break;
case token_type::in_null: os << q << "<-" << q; break;
case token_type::in_str: os << q << '<' << q; break;
case token_type::in_str_nn: os << q << "<:" << q; break;
case token_type::in_doc: os << q << "<<" << q; break;
case token_type::in_doc_nn: os << q << "<<:" << q; break;
+ case token_type::out_std: os << q << ">+" << q; break;
case token_type::out_null: os << q << ">-" << q; break;
case token_type::out_str: os << q << '>' << q; break;
case token_type::out_str_nn: os << q << ">:" << q; break;