Building Statement List: IF, ELSE, ELSEIF
This commit is contained in:
parent
0bf77b2051
commit
e08c48e7d2
12
main.cpp
12
main.cpp
|
@ -29,7 +29,7 @@ void Tokenize(const char FileName[]);
|
||||||
std::vector<std::string> VariableNames;
|
std::vector<std::string> VariableNames;
|
||||||
struct STATEMENT
|
struct STATEMENT
|
||||||
{
|
{
|
||||||
enum etype {OBRACE, EBRACE, DECL, ASSIGN, NEW, DELETE, NEWARRAY, DELETEARRAY, USE, RETURN};
|
enum etype {OBRACE, EBRACE, DECL, ASSIGN, NEW, DELETE, NEWARRAY, DELETEARRAY, USE, RETURN, IF, ELSE, ELSEIF};
|
||||||
etype Type;
|
etype Type;
|
||||||
unsigned int VarIndex;
|
unsigned int VarIndex;
|
||||||
TOKEN *Token;
|
TOKEN *Token;
|
||||||
|
@ -625,6 +625,16 @@ void CreateStatementList()
|
||||||
}
|
}
|
||||||
else if (indentlevel >= 1)
|
else if (indentlevel >= 1)
|
||||||
{
|
{
|
||||||
|
if (strcmp(tok->str,"if")==0)
|
||||||
|
AppendStatement(STATEMENT::IF, tok);
|
||||||
|
else if (strcmp(tok->str,"else")==0)
|
||||||
|
{
|
||||||
|
if (strcmp(getstr(tok,1),"if")==0)
|
||||||
|
AppendStatement(STATEMENT::ELSEIF, tok);
|
||||||
|
else
|
||||||
|
AppendStatement(STATEMENT::ELSE, tok);
|
||||||
|
}
|
||||||
|
|
||||||
// Declaring variables..
|
// Declaring variables..
|
||||||
if (IsName(tok->str) && strcmp(tok->str,"delete") && strcmp(tok->str,"return"))
|
if (IsName(tok->str) && strcmp(tok->str,"delete") && strcmp(tok->str,"return"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue