diff options
-rw-r--r-- | parse.cxx | 20 | ||||
-rw-r--r-- | testsuite/semko/conditional.stp | 5 |
2 files changed, 23 insertions, 2 deletions
@@ -380,6 +380,7 @@ parser::scan_pp (bool wildcard) vector<const token*> my_enqueued_pp; int nesting = 0; + int then = 0; while (true) // consume THEN tokens { try @@ -394,11 +395,18 @@ parser::scan_pp (bool wildcard) if (m && m->type == tok_operator && m->content == "%(") // nested %( nesting ++; + if (m && m->type == tok_operator && m->content == "%?") { + then ++; + if (nesting != then) + throw parse_error ("incomplete conditional - missing '%('", m); + } if (nesting == 0 && m && (m->type == tok_operator && (m->content == "%:" || // ELSE m->content == "%)"))) // END break; - if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) + if (nesting && m && m->type == tok_operator && m->content == "%)") { // nested %) nesting --; + then --; + } if (!m) throw parse_error ("incomplete conditional - missing '%:' or '%)'", t); @@ -414,6 +422,7 @@ parser::scan_pp (bool wildcard) { delete m; // "%:" int nesting = 0; + int then = 0; while (true) { try @@ -428,10 +437,17 @@ parser::scan_pp (bool wildcard) if (m && m->type == tok_operator && m->content == "%(") // nested %( nesting ++; + if (m && m->type == tok_operator && m->content == "%?") { + then ++; + if (nesting != then) + throw parse_error ("incomplete conditional - missing '%('", m); + } if (nesting == 0 && m && m->type == tok_operator && m->content == "%)") // END break; - if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) + if (nesting && m && m->type == tok_operator && m->content == "%)") { // nested %) nesting --; + then --; + } if (!m) throw parse_error ("incomplete conditional - missing %)", t); diff --git a/testsuite/semko/conditional.stp b/testsuite/semko/conditional.stp new file mode 100644 index 00000000..ee164548 --- /dev/null +++ b/testsuite/semko/conditional.stp @@ -0,0 +1,5 @@ +#! stap -p2 + +probe begin { + %( 1 == 0 %? print(1) %? print(2) %) +} |