示例#1
0
        /// <summary>
        /// A parser which parses a floating point number without a sign.
        /// The resulting <c>double</c> is not checked for overflow.
        /// </summary>
        /// <returns>A parser which parses a floating point number without a sign.</returns>

        public static Parser <char, double> UnsignedReal()
        => Map(
            (integerPart, _, decimalPart) => integerPart.HasValue ? integerPart.Value + decimalPart : decimalPart,
            UnsignedInt(10).Optional(),
            Char('.'),
            DigitCharDouble().ChainAtLeastOnceL(
                () =>
        {
            var sb = new PooledList <char>();
            sb.Add('.');
            return(sb);
        },
                (sb, c) =>
                { sb.Add(c); return(sb); }
                ).Select(sb =>
        {
            ReadOnlySpan <char> csp = sb.AsSpan();
            double x = 0.0;
            x        = Double.Parse(csp.ToString(), System.Globalization.NumberStyles.Float);
            sb.Clear();
            return(x);
        }
                         )
            );
示例#2
0
 public void AddExpected(Expected <TToken> expected)
 {
     _expecteds.Add(expected);
 }
示例#3
0
 public void BeginExpectedTran()
 {
     _expectedBookmarks.Add(_expecteds.Count);
 }
示例#4
0
 public void Apply(T value)
 {
     _list.Add(value);
 }
示例#5
0
 public void PushBookmark()
 {
     _bookmarks.Add(Location);
 }