int FindCodeBlock(IList<Token> tokens, int pos)
{
int dep = 0;
for (int i = pos; i < tokens.Count; i++)
{
if (tokens[i].type == TokenType.PUNCTUATION)
{
if (tokens[i].text == "{")
{
dep++;
}
if (tokens[i].text == "}")
{
dep--;
if (dep < 0)
return i - 1;
}
}
}
if (dep != 0)
return -1;
else
return tokens.Count - 1;
}