//###################### // IF's //###################### public override object VisitIf_regular(FaParser.If_regularContext context) { int nExpressions = context.expression().Length; bool thrown = false; for (int i = 0; i < nExpressions; i++) { object valueExp = VisitExpression(context.expression(i)); if (getType(valueExp) == 0) { if ((bool)valueExp) { Visit(context.body_regular(i)); thrown = true; break; } } else { Debug.LogError("La expresión a evaluar debe ser booleana"); // Console.WriteLine("La expresión a evaluar debe ser booleana"); MyConsole.main.AppendText("La expresión a evaluar debe ser booleana"); break; } } if (context.body_regular().Length > nExpressions && !thrown) { Visit(context.body_regular(context.body_regular().Length - 1)); } return(null); }
/// <summary> /// Visit a parse tree produced by <see cref="FaParser.if_regular"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitIf_regular([NotNull] FaParser.If_regularContext context) { return(VisitChildren(context)); }