implemented loop handling for single loop lines
This commit is contained in:
parent
deaa8bd438
commit
cee06594d9
|
@ -13,7 +13,7 @@
|
|||
std::string file_path;
|
||||
bool dbg;
|
||||
bool dbg_prnt_invld_only;
|
||||
bool use_all = true; // 46 invalid parses
|
||||
bool use_all = true; // 26 invalid parses
|
||||
|
||||
FunctionInfo fi;
|
||||
std::string func;
|
||||
|
@ -285,7 +285,8 @@ int main()
|
|||
case 'd':
|
||||
if (ln_is(ln, i, "do {"))
|
||||
{ // setting loop end, if not already in a loop
|
||||
set_str_if_empty(&lp_utl, ind + "}");
|
||||
set_str_if_empty(&lp_utl, ln[ln.length() - 1] == '{' ? ind + "}" : "\1"); // check if this is a single line do-while loop (who would even program such a thing!?
|
||||
break;
|
||||
}
|
||||
if (ln_is(ln, i, "case ") || ln_is(ln, i, "default:"))
|
||||
{
|
||||
|
@ -294,6 +295,13 @@ int main()
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
if (ln_is(ln, i, "for ("))
|
||||
{
|
||||
set_str_if_empty(&lp_utl, ln[ln.length() - 1] == '{' ? ind + "}" : "\1"); // check if this is a single line for loop
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'i': // check for if
|
||||
if (ln_is(ln, i, "if "))
|
||||
{ // enough characters left to be if statement
|
||||
|
@ -336,7 +344,8 @@ int main()
|
|||
case 'w':
|
||||
if (ln_is(ln, i, "while ("))
|
||||
{ // setting loop end, if not already in a loop
|
||||
set_str_if_empty(&lp_utl, ind + "}");
|
||||
set_str_if_empty(&lp_utl, ln[ln.length() - 1] == '{' ? ind + "}" : "\1"); // check if this is a single line while loop
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -379,6 +388,8 @@ int main()
|
|||
|
||||
if (!lp_utl.empty() && ln.starts_with(lp_utl))
|
||||
lp_utl = "";
|
||||
if (lp_utl == "\1")
|
||||
lp_utl = "";
|
||||
if (!skp_push_utl.empty() && ln.starts_with(skp_push_utl))
|
||||
skp_push_utl = ""; // reset skip since line has been reached now
|
||||
if (skp_push_utl == "\1")
|
||||
|
|
Loading…
Reference in New Issue