private IEnumerable <Parselet> FuncArgs(Token <R> fromToken, RantFunctionGroup group) { Token <R> funcToken = null; var actions = new List <RantAction>(); var sequences = new List <RantAction>(); while (!reader.End) { funcToken = reader.ReadToken(); if (funcToken.ID == R.Semicolon) { // add action to args and continue sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken)); actions.Clear(); reader.SkipSpace(); continue; } else if (funcToken.ID == R.RightSquare) { // add action to args and return sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken)); AddToOutput(new RAFunction(Stringe.Range(fromToken, funcToken), compiler.GetFunctionInfo(group, sequences.Count, fromToken, funcToken), sequences)); yield break; } yield return(GetParselet(funcToken, actions.Add)); } compiler.SyntaxError(fromToken, "Unterminated function: unexpected end of file"); }
private IEnumerable<Parselet> FuncArgs(Token<R> fromToken, RantFunctionGroup group) { Token<R> funcToken = null; var actions = new List<RantAction>(); var sequences = new List<RantAction>(); while (!reader.End) { funcToken = reader.ReadToken(); if (funcToken.ID == R.Semicolon) { // add action to args and continue sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken)); actions.Clear(); reader.SkipSpace(); continue; } else if (funcToken.ID == R.RightSquare) { // add action to args and return sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken)); AddToOutput(new RAFunction(Stringe.Range(fromToken, funcToken), compiler.GetFunctionInfo(group, sequences.Count, fromToken, funcToken), sequences)); yield break; } yield return GetParselet(funcToken, actions.Add); } compiler.SyntaxError(fromToken, "Unterminated function: unexpected end of file"); }
public RantFunctionInfo GetFunctionInfo(RantFunctionGroup group, int argc, Stringe from, Stringe to) { var func = group.GetFunction(argc); if (func == null) SyntaxError(Stringe.Between(from, to), $"No overload of function '{group.Name}' can take {argc} arguments"); return func; }
public RantFunctionInfo GetFunctionInfo(RantFunctionGroup group, int argc, Stringe from, Stringe to) { var func = group.GetFunction(argc); if (func == null) { SyntaxError(Stringe.Between(from, to), $"No overload of function '{group.Name}' can take {argc} arguments"); } return(func); }