public Conditional(Token conditionalType, Ast predicate, ScopeDeclr body, Conditional alternate = null) : this(conditionalType) { Predicate = predicate; Body = body; Alternate = alternate; }
public void Visit(Conditional ast) { if (ast.Predicate != null) { ast.Predicate.Visit(this); } ast.Body.Visit(this); if (ast.Alternate != null) { ast.Alternate.Visit(this); } SetScope(ast); }
public void Visit(Conditional ast) { Console.Write(ast.Token); if (ast.Predicate != null) { PrintWrap("Predicate", () => ast.Predicate.Visit(this)); } ast.Body.Visit(this); if (ast.Alternate != null) { if (ast.Alternate.Token.TokenType == TokenType.If) { Console.Write("Else"); } ast.Alternate.Visit(this); } }
public void Visit(Conditional ast) { Exec(ast); }
private void ConditionalDo(Conditional conditional) { // else has no predicate if (conditional.Predicate == null) { Exec(conditional.Body); return; } MemorySpaces.CreateScope(); var success = Convert.ToBoolean(Exec(conditional.Predicate)); if(success) { Exec(conditional.Body); MemorySpaces.PopScope(); } else { MemorySpaces.PopScope(); Exec(conditional.Alternate); } }