public ICLS_Expression Compiler_Expression_Loop_ForEach(IList<Token> tlist, ICLS_Environment content, int pos, int posend)
{
int b1;
int fs1 = pos + 1;
int fe1 = FindCodeAny(tlist, ref fs1, out b1);
CLS_Expression_LoopForEach value = new CLS_Expression_LoopForEach(pos, fe1, tlist[pos].line, tlist[fe1].line);
//int testbegin = fs1 + 1;
if (b1 != 1)
{
return null;
}
for (int i = fs1 + 1; i <= fe1 - 1; i++)
{
if (tlist[i].text == "in" && tlist[i].type == TokenType.KEYWORD)
{
//添加 foreach 定义变量部分
{
ICLS_Expression subvalue;
bool succ = Compiler_Expression(tlist, content, fs1 + 1, i - 1, out subvalue);
if (!succ) return null;
if (subvalue != null)
{
value.listParam.Add(subvalue);
}
}
//添加 foreach 列表部分
{
ICLS_Expression subvalue;
bool succ = Compiler_Expression(tlist, content, i + 1, fe1 - 1, out subvalue);
if (!succ) return null;
if (subvalue != null)
{
value.listParam.Add(subvalue);
}
}
break;
}
}
ICLS_Expression subvalueblock;
int b2;
int fs2 = fe1 + 1;
int fecode = FindCodeAny(tlist, ref fs2, out b2);
bool succ2 = Compiler_Expression_Block(tlist, content, fs2, fecode, out subvalueblock);
if (succ2)
{
value.tokenEnd = fecode;
value.lineEnd = tlist[fecode].line;
value.listParam.Add(subvalueblock);
return value;
}
return null;
}
public ICLS_Expression Compiler_Expression_Loop_While(IList<Token> tlist, ICLS_Environment content, int pos, int posend)