Build Statement List: ENDIF

This commit is contained in:
Daniel Marjamäki 2007-05-19 17:57:08 +00:00
parent 9523f0e2e8
commit 22b1e990bb
1 changed files with 15 additions and 1 deletions

View File

@ -34,7 +34,7 @@ struct STATEMENT
MALLOC, FREE, MALLOC, FREE,
NEW, DELETE, NEW, DELETE,
NEWARRAY, DELETEARRAY, NEWARRAY, DELETEARRAY,
IF, ELSE, ELSEIF, IF, ELSE, ELSEIF, ENDIF,
RETURN, CONTINUE, BREAK}; RETURN, CONTINUE, BREAK};
etype Type; etype Type;
unsigned int VarIndex; unsigned int VarIndex;
@ -638,10 +638,16 @@ void CreateStatementList()
} }
else if (indentlevel >= 1) else if (indentlevel >= 1)
{ {
bool hasif = false;
if (strcmp(tok->str,"if")==0) if (strcmp(tok->str,"if")==0)
{
hasif = true;
AppendStatement(STATEMENT::IF, tok); AppendStatement(STATEMENT::IF, tok);
}
else if (strcmp(tok->str,"else")==0) else if (strcmp(tok->str,"else")==0)
{ {
hasif = true;
if (strcmp(getstr(tok,1),"if")==0) if (strcmp(getstr(tok,1),"if")==0)
AppendStatement(STATEMENT::ELSEIF, tok); AppendStatement(STATEMENT::ELSEIF, tok);
else else
@ -799,6 +805,11 @@ void CreateStatementList()
break; break;
} }
} }
if (hasif)
{
AppendStatement(STATEMENT::ENDIF, tok);
}
} }
} }
@ -867,6 +878,9 @@ void CreateStatementList()
std::cout << "else"; std::cout << "else";
break; break;
case STATEMENT::ENDIF:
std::cout << "endif";
break;
case STATEMENT::RETURN: case STATEMENT::RETURN:
std::cout << "return " << VariableNames[s.VarIndex]; std::cout << "return " << VariableNames[s.VarIndex];