Exemplo n.º 1
0
 public override void TryParse(TFunction caller, bool forFlag)
 {
     ReturnBubble = null;
     ReturnFlag   = false;
     if (caller != null)
     {
         BlindExecute = caller.BlindExecute;
         Tracer       = caller.Tracer;
         Caller       = caller;
         Extensions   = caller.Extensions;
     }
     if (caller != null && caller.Arguments != null && ExpectedArgs != null && ExpectedArgs.Length > 0)
     {
         ProvidedArgs = new TokenStack();
         var args = caller.ReturnArgsArray();
         if (args.Length > 0)
         {
             if (args.Length > ExpectedArgs.Length)
             {
                 Compiler.ExceptionListener.Throw($"The arguments supplied do not match the arguments expected!");
                 return;
             }
             for (var i = 0; i < args.Length; i++)
             {
                 var exp = ExpectedArgs[i].Replace("var ", "").Replace(" ", "");
                 ProvidedArgs.Add(new Token(exp, args[i], caller.Line));
             }
         }
     }
     Parse();
 }
Exemplo n.º 2
0
        public virtual void TryParse(TFunction caller)
        {
            ReturnBubble = null;
            ReturnFlag   = false;
            if (caller != null)
            {
                BlindExecute = caller.BlindExecute;
                Tracer       = caller.Tracer;
                Caller       = caller;
            }
            var findFor = Extensions.FirstOrDefault(f => f.Name == "For") as ExtensionFor;

            if (findFor != null)
            {
                //if for extension exists, reroutes this tryparse method to the loop version without the for check
                ForExtension(caller, findFor);
                return;
            }
            //combine expected args and given args and add them to variabel pool
            if (caller != null && caller.Arguments != null && ExpectedArgs != null && ExpectedArgs.Length > 0)
            {
                ProvidedArgs = new TokenStack();
                var args = caller.ReturnArgsArray();
                if (ExpectedArgs.Length > 0)
                {
                    for (var i = 0; i < ExpectedArgs.Length; i++)
                    {
                        var exp = ExpectedArgs[i].Replace("var ", "").Replace(" ", "");
                        if (args.ElementAtOrDefault(i) == null)
                        {
                            ProvidedArgs.Add(new Token(exp, "null", caller.Line));
                        }
                        else
                        {
                            ProvidedArgs.Add(new Token(exp, args[i], caller.Line));
                        }
                    }
                }
            }
            var guts  = Value.Split('{')[1].Split('}');
            var lines = guts[0].Split(';');

            foreach (var l in lines)
            {
                new Line(l, this);
            }
            //clear local var stack after use
            LocalVariables = new TokenStack();
        }
Exemplo n.º 3
0
        //this overload is when the function is called with the for extension
        public virtual void TryParse(TFunction caller, bool forFlag)
        {
            ReturnBubble = null;
            ReturnFlag   = false;
            if (caller != null)
            {
                BlindExecute = caller.BlindExecute;
                Tracer       = caller.Tracer;
                Caller       = caller;
            }
            //combine expected args and given args and add them to variabel pool
            if (caller != null && caller.Arguments != null && ExpectedArgs != null && ExpectedArgs.Length > 0)
            {
                ProvidedArgs = new TokenStack();
                var args = caller.ReturnArgsArray();
                if (ExpectedArgs.Length > 0)
                {
                    for (var i = 0; i < ExpectedArgs.Length; i++)
                    {
                        var exp = ExpectedArgs[i].Replace("var ", "").Replace(" ", "");
                        if (args.ElementAtOrDefault(i) == null)
                        {
                            ProvidedArgs.Add(new Token(exp, "null", caller.Line));
                        }
                        else
                        {
                            ProvidedArgs.Add(new Token(exp, args[i], caller.Line));
                        }
                    }
                }
            }
            var guts  = Value.Split('{')[1].Split('}');
            var lines = guts[0].Split(';');

            foreach (var l in lines)
            {
                new Line(l, this);
            }
            //clear local var stack after use
            LocalVariables = new TokenStack();
        }
Exemplo n.º 4
0
        public override void TryParse(TFunction caller)
        {
            ReturnBubble = null;
            ReturnFlag   = false;
            if (caller != null)
            {
                BlindExecute = caller.BlindExecute;
                Tracer       = caller.Tracer;
                Caller       = caller;
                Extensions   = caller.Extensions;
            }
            var findFor = Extensions.FirstOrDefault(f => f.Name == "For") as ExtensionFor;

            if (findFor != null)
            {
                //if for extension exists, reroutes this tryparse method to the loop version without the for check
                ForExtension(caller, findFor);
                return;
            }
            if (caller != null && caller.Arguments != null && ExpectedArgs != null && ExpectedArgs.Length > 0)
            {
                ProvidedArgs = new TokenStack();
                var args = caller.ReturnArgsArray();
                if (args.Length > 0)
                {
                    if (args.Length > ExpectedArgs.Length)
                    {
                        Compiler.ExceptionListener.Throw($"The arguments supplied do not match the arguments expected!");
                        return;
                    }
                    for (var i = 0; i < args.Length; i++)
                    {
                        var exp = ExpectedArgs[i].Replace("var ", "").Replace(" ", "");
                        ProvidedArgs.Add(new Token(exp, args[i], caller.Line));
                    }
                }
            }
            Parse();
        }