Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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));
            }
        }