예제 #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();
 }
예제 #2
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();
        }