public bool NextIndices(Executer exec, out int[] indices) { indices = null; int originalPos = position; if (!EndOfStream && _buffer[position] == '[') { IList <object> args; position = GroupParser.ReadGroup(_buffer, position, exec, out args) + 1; indices = new int[args.Count]; for (int i = 0; i < args.Count; ++i) { int?index = args[i] as int?; if (index == null) { throw ThrowHelper.InvalidTypeInExpression(args[i].GetType().Name, typeof(int).Name); } else { indices[i] = index.Value; } } return(true); } position = originalPos; return(false); }
public bool NextFunction(Executer exec, out Function func) { func = null; if (EndOfStream) { return(false); } int originalPos = position; if (char.IsLetter(_buffer[position]) || _buffer[position] == '_') { position = FindAcceptableFuncChars(_buffer, ++position); if (position < _buffer.Length) { StringSegment name = _buffer.Subsegment(originalPos, position - originalPos); SkipWhiteSpace(); if (Next("(")) { IList <object> args; position = GroupParser.ReadGroup(_buffer, position - 1, exec, out args) + 1; func = new Function(exec); func.Parse(_buffer.Subsegment(originalPos, position - originalPos), name, args); return(true); } } } position = originalPos; return(false); }