public override void ExitFun_call(lisp_gammarParser.Fun_callContext context)
        {
            if (!_FuncExp)
            {
                if (!_IfExp)
                {
                    DebugAction.Debug_WriteLine(Context2String(context));
                    DebugAction.Debug_WriteLine(context.ChildCount);
                    DebugAction.Debug_WriteLine(context.GetChild(1).GetText());
                    DebugAction.Debug_WriteLine(context.GetChild(1).ChildCount);
                    DebugAction.Debug_WriteLine(context.GetChild(1).GetType());
                    ParserRuleContext fun  = null;
                    ParserRuleContext IDs  = null;
                    ParserRuleContext Body = null;
                    switch (context.GetChild(1).GetType().ToString())
                    {
                    case "lisp_gammarParser+Fun_expContext":
                        fun  = context.GetChild(1) as ParserRuleContext;
                        IDs  = context.GetChild(1).GetChild(2) as ParserRuleContext;
                        Body = context.GetChild(1).GetChild(3) as ParserRuleContext;
                        break;

                    case "lisp_gammarParser+Fun_nameContext":
                        if (context.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(0) != null)
                        {
                            DebugAction.Debug_WriteLine(context.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetType());
                            fun  = context.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(0) as ParserRuleContext;
                            IDs  = context.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(2) as ParserRuleContext;
                            Body = context.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(3) as ParserRuleContext;
                        }
                        else
                        {
                            DebugAction.Debug_WriteLine("no");
                            fun  = context.GetChild(1).GetChild(0).GetChild(0) as ParserRuleContext;
                            IDs  = context.GetChild(1).GetChild(0).GetChild(0).GetChild(2) as ParserRuleContext;
                            Body = context.GetChild(1).GetChild(0).GetChild(0).GetChild(3) as ParserRuleContext;
                        }
                        break;
                    }

                    /*
                     * var fun = context.GetChild(1).GetChild(0).GetChild(0);
                     * var IDs = context.GetChild(1).GetChild(0).GetChild(0).GetChild(2);
                     * var Body = context.GetChild(1).GetChild(0).GetChild(0).GetChild(3);*/


                    DebugAction.Debug_WriteLine(fun.GetText());
                    DebugAction.Debug_WriteLine(IDs.GetText());
                    DebugAction.Debug_WriteLine(Body.GetText());
                    DebugAction.Debug_WriteLine(fun.ChildCount);
                    DebugAction.Debug_WriteLine(IDs.ChildCount);
                    DebugAction.Debug_WriteLine(Body.ChildCount);
                    var exp = Context2String(Body.GetChild(Body.ChildCount - 1));
                    DebugAction.Debug_WriteLine(exp);

                    if (IDs.ChildCount - 2 == context.ChildCount - 3)
                    {
                        for (int i = 1; i < IDs.ChildCount - 1; i++)
                        {
                            if (int.TryParse(Context2String(context.GetChild(i + 1)), out int b))
                            {
                                exp = exp.Replace(" " + IDs.GetChild(i).GetText() + " ", "  " + Context2String(context.GetChild(i + 1)) + "  ");
                            }
                        }
                        for (int i = 1; i < IDs.ChildCount - 1; i++)
                        {
                            if (!int.TryParse(Context2String(context.GetChild(i + 1)), out int b))
                            {
                                exp = exp.Replace(" " + IDs.GetChild(i).GetText() + " ", "  " + Context2String(context.GetChild(i + 1)) + "  ");
                            }
                        }
                    }
                    else
                    {
                        ParsingMessage.ErrorCode(5, context);
                    }
                    DebugAction.Debug_WriteLine("This is Exp: " + exp);
                    if (Body.ChildCount > 1)
                    {
                        for (int i = 0; i < Body.ChildCount - 1; i++)
                        {
                            DebugAction.Debug_WriteLine(Body.GetChild(i).GetChild(2).GetText());
                            DebugAction.Debug_WriteLine(Body.GetChild(i).GetChild(3).GetText());
                            exp = exp.Replace(" " + Body.GetChild(i).GetChild(2).GetText() + " ", Context2String(Body.GetChild(i).GetChild(3)));
                        }
                        DebugAction.Debug_WriteLine(exp);
                    }
                    var stmtctx = ParseExp(exp);
                    var s       = stmtctx.GetText();
                    DebugAction.Debug_WriteLine("THis is s:" + s);
                    DebugAction.Debug_WriteLine(stmtctx.GetText());
                    DebugAction.Debug_WriteLine(stmtctx.GetType());
                    if (int.TryParse(s, out int a) || s.StartsWith("#"))
                    {
                        DebugAction.Debug_WriteLine(1111);
                        ClearCtx(context);
                        AddCtx(context, stmtctx.GetText());
                    }
                    else
                    {
                        DebugAction.Debug_WriteLine(2222);
                        ClearCtx(context);
                        context.AddChild(stmtctx as ParserRuleContext);
                    }



                    //DebugAction.Debug_WriteLine(context.GetChild(1).GetChild(0).GetChild(0).ChildCount);

                    /*
                     * var funs = fun.Split('.');
                     * var Idctx = ParseIDs(funs[0]);
                     * if (Idctx.ChildCount - 2 == context.ChildCount - 3)
                     *  for (int i = 1; i < Idctx.ChildCount - 1; i++)
                     *  {
                     *      funs[1] = funs[1].Replace(" " + Idctx.GetChild(i).GetText() + " ", "  " + context.GetChild(i + 1).GetText() + "  ");
                     *  }
                     * else
                     *  ParsingMessage.ErrorCode(5, context);
                     * var stmtctx = ParseExp(funs[1]);
                     * ClearCtx(context);
                     * AddCtx(context, stmtctx.GetText());*/
                }
            }
            base.ExitFun_call(context);
        }
 /// <summary>
 /// Exit a parse tree produced by <see cref="lisp_gammarParser.fun_call"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFun_call([NotNull] lisp_gammarParser.Fun_callContext context)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="lisp_gammarParser.fun_call"/>.
 /// <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 VisitFun_call([NotNull] lisp_gammarParser.Fun_callContext context)
 {
     return(VisitChildren(context));
 }