//Assign position of array public override object VisitBodyArrayPosition(FaParser.BodyArrayPositionContext context) { string id = context.ID().GetText(); object position = VisitExpression(context.expression(0)); if (!(position is int)) { position = 0; Debug.LogError("La posición debe ser de tipo entero"); // Console.WriteLine("La posición debe ser de tipo entero"); MyConsole.main.AppendText("La posición debe ser de tipo entero"); } else { object value = VisitExpression(context.expression(1)); object arrExist = ExistInLast(id); if (arrExist is MyArray) { ((MyArray)arrExist).setValue((int)position, value); } else { Debug.LogError("Array con este identificador no ha sido declarado"); // Console.WriteLine("Array con este identificador no ha sido declarado"); MyConsole.main.AppendText("Array con este identificador no ha sido declarado"); } } return(null); }
/// <summary> /// Visit a parse tree produced by the <c>bodyArrayPosition</c> /// labeled alternative in <see cref="FaParser.body"/>. /// <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 VisitBodyArrayPosition([NotNull] FaParser.BodyArrayPositionContext context) { return(VisitChildren(context)); }