public ICLS_Expression Compiler_Expression_Loop_If(IList<Token> tlist, ICLS_Environment content, int pos, int posend)
{
CLS_Expression_LoopIf value = new CLS_Expression_LoopIf(pos, posend, tlist[pos].line, tlist[posend].line);
int b1;
int fs1 = pos + 1;
int fe1 = FindCodeAny(tlist, ref fs1, out b1);
if (b1 != 1)
{
return null;
}
//if(xxx)
{
ICLS_Expression subvalue;
bool succ = Compiler_Expression(tlist, content, fs1, fe1, out subvalue);
if (succ)
{
value.tokenEnd = fe1;
value.lineEnd = tlist[fe1].line;
value.listParam.Add(subvalue);
}
else
{
return null;
}
}
//if(...){yyy}
int b2;
int fs2 = fe1 + 1;
int fe2 = FindCodeAny(tlist, ref fs2, out b2);
{
ICLS_Expression subvalue;
bool succ = Compiler_Expression_Block(tlist, content, fs2, fe2, out subvalue);
if (succ)
{
value.tokenEnd = fe2;
value.lineEnd = tlist[fe2].line;
value.listParam.Add(subvalue);
}
else
{
return null;
}
}
int nelse = fe2 + 1;
if (b2 == 0) nelse++;
FindCodeAny(tlist, ref nelse, out b2);
if (tlist.Count > nelse)
{
if (tlist[nelse].type == TokenType.KEYWORD && tlist[nelse].text == "else")
{ //if(...){...}else{zzz}
int b3;
int fs3 = nelse + 1;
int fe3 = FindCodeAny(tlist, ref fs3, out b3);
ICLS_Expression subvalue;
bool succ = Compiler_Expression_Block(tlist, content, fs3, fe3, out subvalue);
if (succ)
{
value.tokenEnd = fe3;
value.lineEnd = tlist[fe3].line;
value.listParam.Add(subvalue);
}
else
{
return null;
}
}
}
return value;
}
public ICLS_Expression Compiler_Expression_Loop_Try(IList<Token> tlist, ICLS_Environment content, int pos, int posend)