From db400c28dceb98799da739196ce156d0807f9ad4 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 24 Feb 2015 16:43:17 +0100 Subject: [PATCH] Recursive programs entry --- src/parse.h | 54 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/parse.h b/src/parse.h index 14c08fd..1b7f02c 100644 --- a/src/parse.h +++ b/src/parse.h @@ -54,26 +54,60 @@ static bool _cut(const string& entry, vector& entries) entries.push_back(tmp); tmp.clear(); } - if (i<(entry.size()-1) && entry.at(i+1)=='<') + + if (entry.substr(i, 2) == "<<") { - //get expression + int up = 1; + + // found a program begin i+=2; - tmp = "<<"; + tmp="<< "; // trim leading spaces while (i>") + { + up--; + i+=2; + tmp+=" >>"; + // trim trailing spaces + while (i0) + { + tmp += " >>"; + } + if (tmp.size()>0) + { + entries.push_back(tmp); + tmp.clear(); } - entries.push_back(tmp); - tmp.clear(); } else { - // reinject < which is not a program begin + // reinject '<'' which is not a prog begin tmp = "<"; } break;