Table of Contents

Class ProductionBuilder

Namespace
Farkle.Builder
Assembly
Farkle.dll

Provides an API for fluently building productions.

public sealed class ProductionBuilder : IProductionBuilder<ProductionBuilder>, IProduction
Inheritance
ProductionBuilder
Implements
Extension Methods

Remarks

A production builder constructs IProduction<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.

Constructors

ProductionBuilder(params object[])

Creates a production builder with the given members.

public ProductionBuilder(params object[] members)

Parameters

members object[]

An array of the production's members.

Exceptions

ArgumentException

members has an item whose type is not IGrammarSymbol, string or char.

Properties

Empty

A production builder with no members.

public static ProductionBuilder Empty { get; }

Property Value

ProductionBuilder

Methods

Append(IGrammarSymbol)

Appends an IGrammarSymbol to the production.

public ProductionBuilder Append(IGrammarSymbol symbol)

Parameters

symbol IGrammarSymbol

The symbol to append.

Returns

ProductionBuilder

A production builder with symbol added to the production's end.

Remarks

If symbol's actual type is a typed IGrammarSymbol<T>, appending it to a production will not prevent its semantic actions from being executed.

Extend<T1>(IGrammarSymbol<T1>)

Extends the production with a new significant member.

public ProductionBuilder<T1> Extend<T1>(IGrammarSymbol<T1> symbol)

Parameters

symbol IGrammarSymbol<T1>

The new significant member.

Returns

ProductionBuilder<T1>

A production builder with symbol added to its end as a significant member.

Type Parameters

T1

The type of the new significant member.

FinishConstant<T>(T)

Finishes building a production, making it return a constant value.

public IProduction<T> FinishConstant<T>(T value)

Parameters

value T

The value to return from the production.

Returns

IProduction<T>

Type Parameters

T

The type of the production's return value.

Finish<T>(Func<T>)

Finishes building a production, making it return a value produced by a function.

public IProduction<T> Finish<T>(Func<T> fuser)

Parameters

fuser Func<T>

A function that produces the value of the production.

Returns

IProduction<T>

Type Parameters

T

The type of the production's return value.

WithPrecedence(object)

Changes the precedence token of the production.

public ProductionBuilder WithPrecedence(object precedenceToken)

Parameters

precedenceToken object

An object that represents the production in associativity groups.

Returns

ProductionBuilder

A production builder with the precedence token changed to precedenceToken.