int FindBlock(ICLS_Environment env, IList<CSLE.Token> tokens, int start)
{
if (tokens[start].type != CSLE.TokenType.PUNCTUATION)
{
env.logger.Log_Error("(script)FindBlock 没有从符号开始");
}
string left = tokens[start].text;
string right = "}";
if (left == "{") right = "}";
if (left == "(") right = ")";
if (left == "[") right = "]";
int depth = 0;
for (int i = start; i < tokens.Count; i++)
{
if (tokens[i].type == CSLE.TokenType.PUNCTUATION)
{
if (tokens[i].text == left)
{
depth++;
}
else if (tokens[i].text == right)
{
depth--;
if (depth == 0)
{
return i;
}
}
}
}
return -1;
}
}