aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-25 07:22:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:35 +0200
commita6ae456de2d2bb88de07c80560424e8fb644dfce (patch)
tree6a51120901cde9cb427ec2be07be2fa069cdb3f5 /build2/test/script/parser.cxx
parentf2522265c0e778f3c545d8f984b2621369b10c17 (diff)
Diagnose semicolon after testscript setup/teardown commands
Diffstat (limited to 'build2/test/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 1231759..424029f 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -294,7 +294,7 @@ namespace build2
if (lt != line_type::test)
next (t, tt);
- return make_pair (lt, parse_command_line (t, tt, 0));
+ return make_pair (lt, parse_command_line (t, tt, lt, 0));
}
void parser::
@@ -306,7 +306,7 @@ namespace build2
case line_type::setup:
case line_type::tdown: next (t, tt); // Skip plus/minus fallthrough.
- case line_type::test: parse_command_line (t, tt, li); break;
+ case line_type::test: parse_command_line (t, tt, lt, li); break;
}
}
@@ -397,7 +397,7 @@ namespace build2
}
bool parser::
- parse_command_line (token& t, type& tt, size_t li)
+ parse_command_line (token& t, type& tt, line_type lt, size_t li)
{
command c;
@@ -616,8 +616,8 @@ namespace build2
const location ll (get_location (t)); // Line location.
- // Keep parsing chunks of the command line until we see the newline or
- // the exit status comparison.
+ // Keep parsing chunks of the command line until we see one of the
+ // "terminators" (newline, semicolon, exit status comparison, etc).
//
location l (ll);
names ns; // Reuse to reduce allocations.
@@ -888,7 +888,11 @@ namespace build2
if (tt == type::equal || tt == type::not_equal)
c.exit = parse_command_exit (t, tt);
- bool semi (tt == type::semi);
+ // Semicolon is only valid in test command lines. Note that we still
+ // recognize it lexically, it's just not a valid token per the
+ // grammar.
+ //
+ bool semi (tt == type::semi && lt == line_type::test);
if (semi)
next (t, tt); // Get newline.