%( 1 == 0 %? yes %? no %) %( 1 == 1 %? yes %? no %) ^^ notice no %:
In fact, there will be error reported when executing $ stap -e 'probe begin{ a = %( 1 == 0 %? yes %? no %)}' parse error: expected literal string or number saw: operator '}' at <input>:1:43 source: probe begin{ a = %( 1 == 0 %? yes %? no %)} ^ 1 parse error(s). Pass 1: parse failed. Try again with another '--vp 1' option. but, maybe more accurate message is better, like $ stap -e 'probe begin{ a = %( 1 == 0 %? yes %? no %)}' parse error: incomplete conditional - missing '%(' at: operator '%?' at <input>:1:35 source: probe begin{ a = %( 1 == 0 %? yes %? no %)} ^ parse error: expected statement saw: <input> EOF 2 parse error(s). Pass 1: parse failed. Try again with another '--vp 1' option. This can be reached by the following patch. diff --git a/parse.cxx b/parse.cxx index b88ef7f..2ae8c68 100644 --- a/parse.cxx +++ b/parse.cxx @@ -394,6 +394,8 @@ parser::scan_pp (bool wildcard) if (m && m->type == tok_operator && m->content == "%(") // nested %( nesting ++; + if (m && m->type == tok_operator && m->content == "%?" && !nesting) + throw parse_error ("incomplete conditional - missing '%('", m); if (nesting == 0 && m && (m->type == tok_operator && (m->content == "%:" || // ELSE m->content == "%)"))) // END break;
commit c28668eaddf956b8c481e436e939d0b35bacaf68 Author: Wenji Huang <wenji.huang@oracle.com> Date: Tue Jan 12 13:45:55 2010 +0800 PR10747: check invalid preprocessor construct * parse.cxx (scan_pp): Match '%(' and '%?'. * testsuite/semko/conditional.stp: New test.
committed