NumberFragment

Fragment
public sealed class NumberFragment : Fragment
A numeric literal. Leading signs and trailing unit suffixes are not part of a number; they are separate fragments, because neither can be classified without knowing the grammar.

Properties

After

public int After { get; }
Gets the index of the character after this fragment.
inherited fromFragment

Defect

public string Defect { get; }
Gets a description of what is wrong with this fragment, or null when no problem exists.
inherited fromFragment

Fractional

#
public double Fractional { get; }
Gets the value of this literal. Always populated and always safe to read. A double carries 53 bits of mantissa, so for digit runs beyond sixteen digits this is the nearest representable value rather than the exact one; Integral is exact whenever IsIntegral is true.

Integral

#
public BigInteger Integral { get; }
Gets the exact value of this literal. Only meaningful when IsIntegral is true.

IsFractional

#
public bool IsFractional { get; }
Gets whether this literal was written as something other than a plain digit run, and must therefore be read through Fractional.

IsIntegral

#
public bool IsIntegral { get; }
Gets whether Integral is the complete truth of this literal. This is a question about how the number was written rather than about its value, so "4.0" is not integral even though four is a whole number.

Kind

#
public override FragmentKind Kind { get; }
Gets the category of this fragment.
Fragment.Kind

Length

public int Length { get; }
Gets the number of characters covered by this fragment.
inherited fromFragment

NextMeaningful

public Fragment NextMeaningful { get; }
Gets the following fragment, skipping whitespace and single line comments. Line breaks and multi line comments are boundaries rather than trivia, and are returned rather than skipped.
inherited fromFragment

Notation

#
public NumberNotation Notation { get; }
Gets the notations used to write this literal.

PrevMeaningful

public Fragment PrevMeaningful { get; }
Gets the preceding fragment, skipping whitespace and single line comments. Line breaks and multi line comments are boundaries rather than trivia, and are returned rather than skipped.
inherited fromFragment

SignificantDecimals

#
public int SignificantDecimals { get; }
Gets the number of digits written between the decimal separator and the end of the mantissa. This is a purely lexical count, which is what makes "0.0" distinguishable from "0.000". Digit group underscores are not counted, and a literal without a separator has a scale of zero.

Start

public int Start { get; }
Gets the index of the first character of this fragment within Fragments.Source. This index is absolute, and remains valid in every view derived from the original collection.
inherited fromFragment

Text

public string Text { get; }
Gets the characters covered by this fragment.
inherited fromFragment

Methods

IsAdjacentTo

public bool IsAdjacentTo(Fragment other)
Gets whether this fragment is directly adjacent to the given one, with no intervening characters. Used to match multi character operators.
inherited fromFragment
other (Fragment)

IsAll

public bool IsAll(params FragmentKind[] filter)
Tests whether this fragment matches all of the provided filter kinds. Note: this fragment may have additional kinds not covered by the filter, if you want an exact match, just compare against Fragment.Kind.
inherited fromFragment
filter (params FragmentKind[])

IsAny

public bool IsAny(params FragmentKind[] filter)
Tests whether this fragment is any of the provided filter kinds.
inherited fromFragment
filter (params FragmentKind[])

ToString

public override string ToString()
Gets a description of this fragment, for debugging purposes.
inherited fromFragment
Object.ToString