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); } }
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)); } }
static RantEngine() { ForceLoad(); RantFunctionRegistry.Load(); }
/// <summary> /// Enumerates the aliases assigned to the specified function name. /// </summary> /// <param name="functionName">The function name to retrieve aliases for.</param> /// <returns></returns> public static IEnumerable <string> GetFunctionAliases(string functionName) => RantFunctionRegistry.GetAliases(functionName);
/// <summary> /// Returns the description for the function with the specified name. /// </summary> /// <param name="functionName">The name of the function to get the description for.</param> /// <param name="argc">The number of arguments in the overload to get the description for.</param> /// <returns></returns> public static string GetFunctionDescription(string functionName, int argc) => RantFunctionRegistry.GetFunctionDescription(functionName, argc);
/// <summary> /// Enumerates the available functions. /// </summary> /// <returns></returns> public static IEnumerable <IRantFunctionGroup> GetFunctions() => RantFunctionRegistry.GetFunctions();
/// <summary> /// Enumerates all function names and their aliases. /// </summary> /// <returns></returns> public static IEnumerable <string> GetFunctionNamesAndAliases() => RantFunctionRegistry.GetFunctionNamesAndAliases();
/// <summary> /// Returns the function with the specified name. The return value will be null if the function is not found. /// </summary> /// <param name="functionName">The name of the function to retrieve.</param> /// <returns></returns> public static IRantFunctionGroup GetFunction(string functionName) => RantFunctionRegistry.GetFunctionGroup(functionName);
/// <summary> /// Determines whether a function with the specified name is defined in the current engine version. /// </summary> /// <param name="functionName">The name of the function to search for. Argument is not case-sensitive.</param> /// <returns></returns> public static bool FunctionExists(string functionName) { return(RantFunctionRegistry.FunctionExists(functionName)); }
static RantEngine() { RantFunctionRegistry.Load(); Parselet.Load(); }