Esempio n. 1
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="NewGrammarParser.exeCommandRead"/>.
 /// <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 VisitExeCommandRead([NotNull] NewGrammarParser.ExeCommandReadContext context)
 {
     return(VisitChildren(context));
 }
Esempio n. 2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="NewGrammarParser.exeCommandRead"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitExeCommandRead([NotNull] NewGrammarParser.ExeCommandReadContext context)
 {
 }
Esempio n. 3
0
        public override String VisitExeCommandRead([NotNull] NewGrammarParser.ExeCommandReadContext context)
        {
            String str = "";
            String variableName;

            if (context.GetChild(0).GetText().Equals("assign "))
            {
                variableName = Visit(context.GetChild(1));

                /*if (this.attributesList.Contains(variableName))
                 * {
                 *  variableName = "self." + variableName;
                 * }*/

                if (!context.GetChild(4).GetText().Equals(")"))
                {
                    str = context.GetChild(4).GetText();
                }

                if (context.GetChild(3).GetText().Contains("int"))
                {
                    return(variableName + " = int(input(" + str + "))");
                }
                else if (context.GetChild(3).GetText().Contains("real"))
                {
                    return(variableName + " = float(input(" + str + "))");
                }
                else if (context.GetChild(3).GetText().Contains("bool"))
                {
                    return(variableName + " = boolean(input(" + str + "))");
                }
                else
                {
                    return(variableName + " = input(" + str + ")");
                }
            }
            else
            {
                variableName = Visit(context.GetChild(0));

                /*if (this.attributesList.Contains(variableName))
                 * {
                 *  variableName = "self." + variableName;
                 * }*/

                if (!context.GetChild(3).GetText().Equals(")"))
                {
                    str = context.GetChild(3).GetText();
                }

                if (context.GetChild(2).GetText().Contains("int"))
                {
                    return(variableName + " = int(input(" + str + "))");
                }
                else if (context.GetChild(2).GetText().Contains("real"))
                {
                    return(variableName + " = float(input(" + str + "))");
                }
                else if (context.GetChild(2).GetText().Contains("bool"))
                {
                    return(variableName + " = boolean(input(" + str + "))");
                }
                else
                {
                    return(variableName + " = input(" + str + ")");
                }
            }

            //return base.VisitCommandRead(context);
        }