private StmtIf ParseStmtElif() { StmtBlock elseObj = null; var branches = new List <Branch>(); branches.Add(ParseStmtIf()); while (Accept(TokenType.Else) != null) { List <IStatement> stmtBlock; if (Accept(TokenType.If) != null) { var expression = ParseExprParen(); stmtBlock = ParseStmtBlock(); branches.Add(new Branch(expression, new StmtBlock(stmtBlock))); } else { stmtBlock = ParseStmtBlock(); elseObj = new StmtBlock(stmtBlock); break; } } return(new StmtIf(branches, elseObj)); }
public Branch(IExpression condition, StmtBlock body) { AddChildren(condition, body); Condition = condition; Body = body; EndLabel = new Label(); }
public StmtWhile(IExpression condition, StmtBlock body) { AddChildren(condition, body); this.condition = condition; this.body = body; startLabel = new Label(); endLabel = new Label(); }
public StmtIf(List <Branch> branches, StmtBlock elseBody) { /*var temp = new Node[branches.Count + 1]; * temp[branches.Count] = elseBody;*/ AddChildren(branches.ToArray()); AddChildren(elseBody); this.Branches = branches; this.ElseBody = elseBody; ElseLabel = new Label(); AfterElseLabel = new Label(); }