private static JNode ParseLowLevelNodeValue(StringBuffer buffer, char?next) { if (char.IsDigit(next.Value) || next == '+' | next == '-') { //possible number var number = buffer.MoveNext((str, idx, chr) => idx + 1 < str.Length && new[] { JConstants.NodeClosingToken, JConstants.SeparatorToken, JConstants.EnumerationClosingToken } .Contains(str[idx + 1])); if (number.Contains(".") || number.Contains(",")) { if (long.TryParse(number, out var l)) { return(new JValueNode(l)); } } else { if (double.TryParse(number, out var d)) { return(new JValueNode(d)); } } JUtils.ValidateOutOfBounds(); } else { //possible boolean, null bool?token = buffer.IsNext("true", StringComparison.CurrentCultureIgnoreCase) ? true : buffer.IsNext("false", StringComparison.CurrentCultureIgnoreCase) ? false : (bool?)null; if (!token.HasValue || token.Value) { buffer.MoveNext(4); } else { buffer.MoveNext(5); } if (!token.HasValue) { return(new JValueNode(null)); } else { return(new JValueNode(token.Value)); } ; } throw new NotImplementedException("If you see this, I screwed up."); }
public static IEnumerable <JSegment> Parse(string path) { var buffer = new StringBuffer(path); return(Parse(buffer)); }
public static JNode Parse(string value) { var buffer = new StringBuffer(value); return(JNode.ParseNode(buffer)); }