Table of Contents

Class Terminals

Namespace
Farkle.Builder
Assembly
Farkle.dll

Provides factory methods for common terminal symbols.

public static class Terminals
Inheritance
Terminals

Methods

Decimal(string)

Creates a terminal that matches a signed floating-point number.

public static IGrammarSymbol<decimal> Decimal(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<decimal>

Remarks

This terminal matches non-empty sequences of decimal digits, separated by a dot, and optionally followed by an exponent of the form [eE][+-]?[0-9]+. A leading minus sign is also allowed.

The set of accepted strings has changed in Farkle 7. Previously the dot, and digits either only before or only after it, were optional, which made the terminal match integer literals, but caused conflicts. Making them mandatory avoids these conflicts and improves simplicity and predictability.

Double(string)

Creates a terminal that matches a signed floating-point number.

public static IGrammarSymbol<double> Double(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<double>

Remarks

This terminal matches non-empty sequences of decimal digits, separated by a dot, and optionally followed by an exponent of the form [eE][+-]?[0-9]+. A leading minus sign is also allowed.

The set of accepted strings has changed in Farkle 7. Previously the dot, and digits either only before or only after it, were optional, which made the terminal match integer literals, but caused conflicts. Making them mandatory avoids these conflicts and improves simplicity and predictability.

Int32(string)

Creates a terminal that matches a signed integer.

public static IGrammarSymbol<int> Int32(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<int>

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited. A leading minus sign is also allowed.

Int64(string)

Creates a terminal that matches a signed integer.

public static IGrammarSymbol<long> Int64(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<long>

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited. A leading minus sign is also allowed.

SignedFloat<T>(string)

Creates a terminal that matches a signed floating-point number.

public static IGrammarSymbol<T> SignedFloat<T>(string name) where T : IFloatingPoint<T>

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<T>

Type Parameters

T

The type this terminal returns. Must implement IFloatingPoint<TSelf>.

Remarks

This terminal matches non-empty sequences of decimal digits, separated by a dot, and optionally followed by an exponent of the form [eE][+-]?[0-9]+. A leading minus sign is also allowed.

The set of accepted strings has changed in Farkle 7. Previously the dot, and digits either only before or only after it, were optional, which made the terminal match integer literals, but caused conflicts. Making them mandatory avoids these conflicts and improves simplicity and predictability.

SignedInteger<T>(string)

Creates a terminal that matches a signed integer.

public static IGrammarSymbol<T> SignedInteger<T>(string name) where T : ISignedNumber<T>

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<T>

Type Parameters

T

The type this terminal returns. Must implement ISignedNumber<TSelf>.

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited. A leading minus sign is also allowed.

Single(string)

Creates a terminal that matches a signed floating-point number.

public static IGrammarSymbol<float> Single(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<float>

Remarks

This terminal matches non-empty sequences of decimal digits, separated by a dot, and optionally followed by an exponent of the form [eE][+-]?[0-9]+. A leading minus sign is also allowed.

The set of accepted strings has changed in Farkle 7. Previously the dot, and digits either only before or only after it, were optional, which made the terminal match integer literals, but caused conflicts. Making them mandatory avoids these conflicts and improves simplicity and predictability.

String(string, char)

Creates a terminal that matches a single-line C-style string.

public static IGrammarSymbol<string> String(string name, char delimiter)

Parameters

name string

The terminal's name.

delimiter char

The character that starts and ends the string.

Returns

IGrammarSymbol<string>

Remarks

All escape sequences described in String(string, char, string, bool) are supported.

String(string, char, string, bool)

Creates a terminal that matches a C-style string.

public static IGrammarSymbol<string> String(string name, char delimiter, string escapeChars, bool multiLine)

Parameters

name string

The terminal's name.

delimiter char

The character that starts and ends the string.

escapeChars string

The characters that are allowed to be escaped with a </code>. </code> and delimiter are always allowed to be escaped.

multiLine bool

Whether new line characters are allowed.

Returns

IGrammarSymbol<string>

Remarks

The following escape sequences if enabled in escapeChars have special meaning:

  • \a, \b, \f, \n, \r, \t and \v correspond to the same characters as in C.
  • \e corresponds to the U+001B escape character.
  • \UXXXX, where X is a case-insensitive hexadecimal number, corresponds to the U+XXXX character.
Escape sequences with all other characters are treated as the character itself.

UInt32(string)

Creates a terminal that matches an unsigned integer.

public static IGrammarSymbol<uint> UInt32(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<uint>

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited.

UInt64(string)

Creates a terminal that matches an unsigned integer.

public static IGrammarSymbol<ulong> UInt64(string name)

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<ulong>

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited.

UnsignedFloat<T>(string)

Creates a terminal that matches an unsigned floating-point number.

public static IGrammarSymbol<T> UnsignedFloat<T>(string name) where T : IFloatingPoint<T>

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<T>

Type Parameters

T

The type this terminal returns. Must implement IFloatingPoint<TSelf>.

Remarks

This terminal matches non-empty sequences of decimal digits, separated by a dot, and optionally followed by an exponent of the form [eE][+-]?[0-9]+.

The set of accepted strings has changed in Farkle 7. Previously the dot, and digits either only before or only after it, were optional, which made the terminal match integer literals, but caused conflicts. Making them mandatory avoids these conflicts and improves simplicity and predictability.

UnsignedInteger<T>(string)

Creates a terminal that matches an unsigned integer.

public static IGrammarSymbol<T> UnsignedInteger<T>(string name) where T : INumberBase<T>

Parameters

name string

The terminal's name.

Returns

IGrammarSymbol<T>

Type Parameters

T

The type this terminal returns. Must implement INumberBase<TSelf>.

Remarks

This terminal matches non-empty sequences of decimal digits. Leading zeroes are not prohibited.