From b0bed0e1205f44ae73850fac521f9162f29adef5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 24 Oct 2016 16:11:50 +0300 Subject: Support >+ and <+ redirects in parser --- build2/test/script/lexer.cxx | 6 ++++-- build2/test/script/parser.cxx | 15 +++++++++++++++ build2/test/script/script | 1 + build2/test/script/script.cxx | 1 + build2/test/script/token | 2 ++ build2/test/script/token.cxx | 2 ++ 6 files changed, 25 insertions(+), 2 deletions(-) (limited to 'build2/test') 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; -- cgit v1.1