Farkle


ProductionBuilder Type

The base, untyped class of the production builders.

A production builder is an object that helps to fluently construct Production{T}s by aggregating the types of its significant members. The types of the production's significant members are indicated by the type parameters. For example, a ProductionBuilder has no significant members, and a ProductionBuilder{int, string} has two significant members: an integer and a string.

Production builders have these common methods.

Append returns a production builder with the same significant members, but the given DesigntimeFarkle at the end of it. Alternatively, it can accept a string which will be appended to the production as a literal.

Extend returns a production builder with one more significant member, whose type is determined by the given DesigntimeFarkle{T} that will be appended to it.

Finish accepts a function that converts all the builder's significant members into the eventual type of the returned Production{T}. It comes in two editions: one that takes an F# function and another one that takes a delegate.

WithPrecedence accepts a unique object which will represent the production in operator scopes, providing contextual precedence. An overload of this method accepts a reference to a variable that will hold the object, which will be created by Farkle. It allows C# programmers to use out var instead of creating their own object.

Constructors

Constructor Description

ProductionBuilder(members)

Full Usage: ProductionBuilder(members)

Parameters:
    members : obj[]

Returns: ProductionBuilder

Creates a production builder whose members are the given objects. The objects must be either strings or characters (where they will be interpreted as literals), or designtime Farkles. Passing an object of different type will raise an exception.

members : obj[]
Returns: ProductionBuilder

Instance members

Instance member Description

this.Append

Full Usage: this.Append

Parameters:
    lit : string

Returns: ProductionBuilder

Creates a production builder from this one with the given string added to the end as a literal.

lit : string
Returns: ProductionBuilder

this.Append

Full Usage: this.Append

Parameters:
Returns: ProductionBuilder

Creates a production builder from this one with the given untyped designtime Farkle added to the end as a not significant member.

sym : DesigntimeFarkle
Returns: ProductionBuilder

this.Extend

Full Usage: this.Extend

Parameters:
Returns: ProductionBuilder<'T1>

Creates a production builder from this one with the given typed designtime Farkle added to the end as a significant member. Up to sixteen significant members can be added to a production builder.

df : DesigntimeFarkle<'T1>
Returns: ProductionBuilder<'T1>

this.Finish

Full Usage: this.Finish

Parameters:
    f : Func<'TOutput>

Returns: Production<'TOutput>

Finishes the production's construction and returns it. This method accepts a delegate that returns the production's output.

f : Func<'TOutput>
Returns: Production<'TOutput>

this.FinishConstant

Full Usage: this.FinishConstant

Parameters:
    v : 'TOutput

Returns: Production<'TOutput>

Creates a Production{T} that always returns a constant value.

v : 'TOutput
Returns: Production<'TOutput>

this.FinishFSharp

Full Usage: this.FinishFSharp

Parameters:
    f : unit -> 'TOutput

Returns: Production<'TOutput>

Finishes the production's construction and returns it. This method accepts an F# function that returns the production's output.

f : unit -> 'TOutput
Returns: Production<'TOutput>

this.FinishRaw

Full Usage: this.FinishRaw

Parameters:
    fuser : F<'TOutput>

Returns: Production<'TOutput>

Like Finish, but the given function accepts a read-only span of all the production's members as objects.

This method is intended to be used when finishing a production with many significant members.

fuser : F<'TOutput>
Returns: Production<'TOutput>

this.WithPrecedence

Full Usage: this.WithPrecedence

Parameters:
    cpTokenRef : outref<obj> - The reference that will be assigned a newly created object which will serve as the production's contextual precedence token.

Returns: ProductionBuilder

Returns a production builder with a unique contextual precedence token assigned to it, which is also returned by reference.

This method allows a simpler experience for C# users.

cpTokenRef : outref<obj>

The reference that will be assigned a newly created object which will serve as the production's contextual precedence token.

Returns: ProductionBuilder

this.WithPrecedence

Full Usage: this.WithPrecedence

Parameters:
    cpToken : obj - An object that identifies the production when defining operator precedence and associativity.

Returns: ProductionBuilder

Returns a production builder with the given contextual precedence token.

cpToken : obj

An object that identifies the production when defining operator precedence and associativity.

Returns: ProductionBuilder
ArgumentNullException cpToken is .

Static members

Static member Description

x .>> literal

Full Usage: x .>> literal

Parameters:
Returns: ProductionBuilder
Modifiers: inline

The Append(string) method as an F# operator.

x : ProductionBuilder
literal : string
Returns: ProductionBuilder

x .>> df

Full Usage: x .>> df

Parameters:
Returns: ProductionBuilder
Modifiers: inline

The Append(DesigntimeFarkle) method as an F# operator.

x : ProductionBuilder
df : DesigntimeFarkle
Returns: ProductionBuilder

x .>>. df

Full Usage: x .>>. df

Parameters:
Returns: ProductionBuilder<'a>
Modifiers: inline
Type parameters: 'a

The Extend method as an F# operator.

x : ProductionBuilder
df : DesigntimeFarkle<'a>
Returns: ProductionBuilder<'a>

x => f

Full Usage: x => f

Parameters:
Returns: Production<'a>
Modifiers: inline
Type parameters: 'a

The FinishFSharp method as an F# operator.

x : ProductionBuilder
f : unit -> 'a
Returns: Production<'a>

ProductionBuilder.Empty

Full Usage: ProductionBuilder.Empty

Returns: ProductionBuilder

A production builder with no members.

Returns: ProductionBuilder