Beispiel #1
0
    public override object VisitSwitch_return(FaParser.Switch_returnContext context)
    {
        int    nCases = context.dataType().Length;
        string id     = context.ID().GetText();
        bool   thrown = false;
        object result = null;

        if (Exist(id) is MyVariable)          //TODO : agregar array
        {
            object value = ((MyVariable)Exist(id)).value;
            for (int i = 0; i < nCases; i++)
            {
                object caseValue = VisitDataType(context.dataType(i));
                if (caseValue.GetType() == value.GetType() && caseValue == value)
                {
                    result = Visit(context.body_return(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_return().Length > nCases && !thrown)
            {
                result = Visit(context.body_return(context.body_return().Length - 1));
            }
        }
        return(result);
    }
Beispiel #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="FaParser.switch_return"/>.
 /// <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 VisitSwitch_return([NotNull] FaParser.Switch_returnContext context)
 {
     return(VisitChildren(context));
 }