diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-05-22 15:32:31 +0300 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-05-27 08:38:57 +0200 |
commit | b0b048c03930b826ab3dbf88b56fd664fca26886 (patch) | |
tree | d6e5e89fb40a31136f6d3e870e59c23f14b70631 /libbuild2/test | |
parent | b27f36b7af5186ad66fd1afa6e7fdc742f2aa1bd (diff) |
Add script command redirect aliases
Diffstat (limited to 'libbuild2/test')
-rw-r--r-- | libbuild2/test/script/lexer.cxx | 10 | ||||
-rw-r--r-- | libbuild2/test/script/lexer.hxx | 6 | ||||
-rw-r--r-- | libbuild2/test/script/parser+redirect.test.testscript | 8 | ||||
-rw-r--r-- | libbuild2/test/script/parser+regex.test.testscript | 5 | ||||
-rw-r--r-- | libbuild2/test/script/parser.cxx | 5 |
5 files changed, 25 insertions, 9 deletions
diff --git a/libbuild2/test/script/lexer.cxx b/libbuild2/test/script/lexer.cxx index 0e8691c..a94109b 100644 --- a/libbuild2/test/script/lexer.cxx +++ b/libbuild2/test/script/lexer.cxx @@ -15,6 +15,14 @@ namespace build2 { using type = token_type; + build2::script::redirect_aliases lexer::redirect_aliases { + type (type::in_str), + type (type::in_doc), + type (type::in_file), + type (type::out_str), + type (type::out_doc), + type (type::out_file_cmp)}; + void lexer:: mode (base_mode m, char ps, optional<const char*> esc, uintptr_t data) { @@ -239,7 +247,7 @@ namespace build2 m == lexer_mode::first_token || m == lexer_mode::second_token) { - if (optional<token> t = next_cmd_op (c, sep, m)) + if (optional<token> t = next_cmd_op (c, sep)) return move (*t); } diff --git a/libbuild2/test/script/lexer.hxx b/libbuild2/test/script/lexer.hxx index 4b6c53a..452e794 100644 --- a/libbuild2/test/script/lexer.hxx +++ b/libbuild2/test/script/lexer.hxx @@ -48,7 +48,8 @@ namespace build2 const char* escapes = nullptr) : base_lexer (is, name, 1 /* line */, nullptr /* escapes */, - false /* set_mode */) + false /* set_mode */, + redirect_aliases) { mode (m, '\0', escapes); } @@ -62,6 +63,9 @@ namespace build2 virtual token next () override; + public: + static redirect_aliases_type redirect_aliases; + private: token next_line (); diff --git a/libbuild2/test/script/parser+redirect.test.testscript b/libbuild2/test/script/parser+redirect.test.testscript index 3858808..79530e0 100644 --- a/libbuild2/test/script/parser+redirect.test.testscript +++ b/libbuild2/test/script/parser+redirect.test.testscript @@ -49,7 +49,7 @@ : portable-path : $* <<EOI >>EOO - cmd <</EOI_ >/EOO_ 2>/EOE_ + cmd <</EOI_ >>/EOO_ 2>>/EOE_ foo EOI_ bar @@ -57,7 +57,7 @@ baz EOE_ EOI - cmd <</EOI_ >/EOO_ 2>/EOE_ + cmd <</EOI_ >>/EOO_ 2>>/EOE_ foo EOI_ bar @@ -113,13 +113,13 @@ : portable-path : $* <<EOI >>EOO - cmd >/~%EOF% 2>/~%EOE% + cmd >>/~%EOF% 2>>/~%EOE% foo EOF bar EOE EOI - cmd >/~%EOF% 2>/~%EOE% + cmd >>/~%EOF% 2>>/~%EOE% foo EOF bar diff --git a/libbuild2/test/script/parser+regex.test.testscript b/libbuild2/test/script/parser+regex.test.testscript index 8627304..db418b3 100644 --- a/libbuild2/test/script/parser+regex.test.testscript +++ b/libbuild2/test/script/parser+regex.test.testscript @@ -162,9 +162,12 @@ EOE EOO - : no-newline + : no-newline-str : $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' + + : no-newline-doc + : $* <<EOI >>EOO cmd 2>>:~/EOE/ foo diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx index 798b743..c206e0a 100644 --- a/libbuild2/test/script/parser.cxx +++ b/libbuild2/test/script/parser.cxx @@ -428,7 +428,7 @@ namespace build2 pair<command_expr, here_docs> p; if (lt != line_type::cmd_else && lt != line_type::cmd_end) - p = parse_command_expr (t, tt); + p = parse_command_expr (t, tt, lexer::redirect_aliases); // Colon and semicolon are only valid in test command lines and // after 'end' in if-else. Note that we still recognize them @@ -1248,7 +1248,8 @@ namespace build2 // Note: this one is only used during execution. - pair<command_expr, here_docs> p (parse_command_expr (t, tt)); + pair<command_expr, here_docs> p ( + parse_command_expr (t, tt, lexer::redirect_aliases)); switch (tt) { |