Esempio n. 1
0
 public RstFunction(LineCol location, RantFunctionSignature funcInfo, List <RST> args)
     : base(location)
 {
     _funcInfo = funcInfo;
     _args     = args;
     _argc     = args.Count;
 }
Esempio n. 2
0
 public RAFunction(Stringe range, RantFunctionSignature funcInfo, List <RantAction> argActions)
     : base(range)
 {
     _funcInfo   = funcInfo;
     _argActions = argActions;
     _argc       = argActions.Count;
 }
Esempio n. 3
0
        protected override IEnumerator <DeserializeRequest> Deserialize(EasyReader input)
        {
            input.ReadInt32(out _argc);
            string funcName = input.ReadString();

            _funcInfo = RantFunctionRegistry.GetFunction(funcName, _argc);
            if (_args == null)
            {
                _args = new List <RST>(_argc);
            }
            for (int i = 0; i < _argc; i++)
            {
                var request = new DeserializeRequest();
                yield return(request);

                _args.Add(request.Result);
            }
        }
Esempio n. 4
0
        private IEnumerator <Parser> ParseFunction(RantCompiler compiler, CompileContext context, TokenReader reader,
                                                   Action <RST> actionCallback)
        {
            var functionName = reader.Read(R.Text, "acc-function-name");

            var arguments = new List <RST>();

            if (reader.PeekType() == R.Colon)
            {
                reader.ReadToken();

                var iterator = ReadArguments(compiler, reader, arguments);
                while (iterator.MoveNext())
                {
                    yield return(iterator.Current);
                }

                compiler.SetNextActionCallback(actionCallback);
            }
            else
            {
                reader.Read(R.RightSquare);
            }

            RantFunctionSignature sig = null;

            if (functionName.Value != null)
            {
                if (!RantFunctionRegistry.FunctionExists(functionName.Value))
                {
                    compiler.SyntaxError(functionName, false, "err-compiler-nonexistent-function", functionName.Value);
                    yield break;
                }

                if ((sig = RantFunctionRegistry.GetFunction(functionName.Value, arguments.Count)) == null)
                {
                    compiler.SyntaxError(functionName, false, "err-compiler-nonexistent-overload", functionName.Value, arguments.Count);
                    yield break;
                }

                actionCallback(new RstFunction(functionName.ToLocation(), sig, arguments));
            }
        }