static bool StillCollecting(string item, char[] to, ParsingScript script, ref string action) { char prev = script.TryPrevPrev(); char ch = script.TryPrev(); char next = script.TryCurrent(); if (to.Contains(ch) || ch == Constants.START_ARG || ch == Constants.START_GROUP || next == Constants.EMPTY) { return(false); } // Case of a negative number, or starting with the closing bracket: if (item.Length == 0 && ((ch == '-' && next != '-') || ch == Constants.END_ARRAY || ch == Constants.END_ARG)) { return(true); } // Case of a scientific notation 1.2e+5 or 1.2e-5 or 1e5: if (Char.ToUpper(prev) == 'E' && (ch == '-' || ch == '+' || Char.IsDigit(ch)) && item.Length > 1 && Char.IsDigit(item[item.Length - 2])) { return(true); } // Otherwise if it's an action (+, -, *, etc.) or a space // we're done collecting current token. if ((action = Utils.ValidAction(script.FromPrev())) != null || (item.Length > 0 && ch == Constants.SPACE)) { return(false); } if (ch == Constants.TERNARY_OPERATOR) { script.Backward(); return(false); } return(true); }