I'm looking at a project in which some if
and for
statements do not have their associated brackets, like so:
if(condition)
single_line_statement;
for(int i=0;i<10;i++)
single_line_statement;
I want to find these statements!
However, this is made challenging by the existence of code with two different bracketing styles:
if(condition){
stuff;
}
and
if(condition(a) && condition(b))
{
stuff;
}
as well as by complex statements such as (note the nested brackets):
for (auto const &x : y)
{
for (auto const &m : ted.bob())
{
if (m.n(o) != 0)
{
p[q] = true;
}
r["s"].push_back(rn.t(u));
}
}
How can I find the if
and for
statements without brackets?