aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-11-01 12:18:59 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:37 +0200
commit5583ffaa2581858cb7f7f75e28660bc038bcc8ec (patch)
tree72707ac943e4f2a5a0457869d7672db558940461 /build2/test/script/parser.cxx
parent40a34dc212a5749350723ac4f390335c0c5283e3 (diff)
Add support for cleanup types to testscript parser
Diffstat (limited to 'build2/test/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx36
1 files changed, 29 insertions, 7 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index fc40fd0..7fb0608 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -807,6 +807,7 @@ namespace build2
pending p (pending::program);
bool nn (false); // True if pending here-{str,doc} is "no-newline".
bool app (false); // True if to append to pending file.
+ cleanup_type ct; // Pending cleanup type.
// Ordered sequence of here-document redirects that we can expect to
// see after the command line.
@@ -823,7 +824,7 @@ namespace build2
// to program arguments by default.
//
auto add_word =
- [&c, &p, &nn, &app, &hd, this] (string&& w, const location& l)
+ [&c, &p, &nn, &app, &ct, &hd, this] (string&& w, const location& l)
{
auto add_merge = [&l, this] (redirect& r, const string& w, int fd)
{
@@ -913,7 +914,8 @@ namespace build2
case pending::clean:
{
c.cleanups.push_back (
- {cleanup_type::always, parse_path (move (w), "cleanup path")});
+ {ct, parse_path (move (w), "cleanup path")});
+
break;
}
}
@@ -1092,6 +1094,20 @@ namespace build2
}
};
+ // Set pending cleanup type.
+ //
+ auto parse_clean = [&p, &ct] (type tt)
+ {
+ switch (tt)
+ {
+ case type::clean_always: ct = cleanup_type::always; break;
+ case type::clean_maybe: ct = cleanup_type::maybe; break;
+ case type::clean_never: ct = cleanup_type::never; break;
+ }
+
+ p = pending::clean;
+ };
+
const location ll (get_location (t)); // Line location.
// Keep parsing chunks of the command line until we see one of the
@@ -1136,7 +1152,9 @@ namespace build2
case type::out_file:
case type::out_file_app:
- case type::clean:
+ case type::clean_always:
+ case type::clean_maybe:
+ case type::clean_never:
{
if (pre_parse_)
{
@@ -1206,9 +1224,11 @@ namespace build2
break;
}
- case type::clean:
+ case type::clean_always:
+ case type::clean_maybe:
+ case type::clean_never:
{
- p = pending::clean;
+ parse_clean (tt);
break;
}
@@ -1369,9 +1389,11 @@ namespace build2
break;
}
- case type::clean:
+ case type::clean_always:
+ case type::clean_maybe:
+ case type::clean_never:
{
- p = pending::clean;
+ parse_clean (tt);
break;
}