Class ProductionBuilderExtensions
Provides extension methods to manipulate and create production builders and productions.
public static class ProductionBuilderExtensions
- Inheritance
-
ProductionBuilderExtensions
Methods
Append<T>(T, string)
Appends a literal to the production.
public static T Append<T>(this T builder, string literal) where T : IProductionBuilder<T>
Parameters
builder
TThe production builder.
literal
stringThe literal to append.
Returns
- T
A production builder with
literal
added to the production's end.
Type Parameters
T
The type of the production builder.
- See Also
Appended(IGrammarSymbol)
Starts a production builder with a symbol.
public static ProductionBuilder Appended(this IGrammarSymbol symbol)
Parameters
symbol
IGrammarSymbolThe symbol to start the production with.
Returns
Appended(string)
Starts a production builder with a literal.
public static ProductionBuilder Appended(this string literal)
Parameters
literal
stringThe literal to start the production with.
Returns
AsProduction<T>(IGrammarSymbol<T>)
Creates a production made of a symbol, that produces the same value as the symbol.
public static IProduction<T> AsProduction<T>(this IGrammarSymbol<T> symbol)
Parameters
symbol
IGrammarSymbol<T>The symbol comprising the production.
Returns
- IProduction<T>
Type Parameters
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Appended(IGrammarSymbol) and Farkle.Builder.ProductionBuilders.ProductionBuilder<T1>.AsIs().
Extended<T1>(IGrammarSymbol<T1>)
Starts a production builder with a symbol as a significant member.
public static ProductionBuilder<T1> Extended<T1>(this IGrammarSymbol<T1> symbol)
Parameters
symbol
IGrammarSymbol<T1>The symbol to start the production with.
Returns
Type Parameters
T1
The type of values the symbol will produce.
FinishConstant<T>(IGrammarSymbol, T)
Creates a production made of a symbol, that produces a constant value.
public static IProduction<T> FinishConstant<T>(this IGrammarSymbol symbol, T value)
Parameters
symbol
IGrammarSymbolThe symbol comprising the production.
value
TThe value the production will produce.
Returns
- IProduction<T>
Type Parameters
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Appended(IGrammarSymbol) and FinishConstant<T>(T).
FinishConstant<T>(string, T)
Creates a production made of a literal, that produces a constant value.
public static IProduction<T> FinishConstant<T>(this string literal, T value)
Parameters
literal
stringThe literal comprising the production.
value
TThe value the production will produce.
Returns
- IProduction<T>
Type Parameters
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Appended(string) and FinishConstant<T>(T).
Finish<T>(IGrammarSymbol, Func<T>)
Creates a production made of a symbol, that produces a value.
public static IProduction<T> Finish<T>(this IGrammarSymbol symbol, Func<T> fuser)
Parameters
symbol
IGrammarSymbolThe symbol comprising the production.
fuser
Func<T>The function to call when this production is reduced.
Returns
- IProduction<T>
Type Parameters
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Appended(string) and Finish<T>(Func<T>).
Finish<T>(string, Func<T>)
Creates a production made of a literal, that produces a value.
public static IProduction<T> Finish<T>(this string literal, Func<T> fuser)
Parameters
literal
stringThe literal to convert.
fuser
Func<T>A function that produces the value of the production.
Returns
- IProduction<T>
Type Parameters
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Appended(string) and Finish<T>(Func<T>).
Finish<T1, T>(IGrammarSymbol<T1>, Func<T1, T>)
Creates a production made of a symbol, that produces a value transformed from the symbol's value.
public static IProduction<T> Finish<T1, T>(this IGrammarSymbol<T1> symbol, Func<T1, T> fuser)
Parameters
symbol
IGrammarSymbol<T1>The symbol comprising the production.
fuser
Func<T1, T>The function to call when this production is reduced.
Returns
- IProduction<T>
Type Parameters
T1
The type of values the symbol will produce.
T
The type of values the production will produce.
Remarks
This method is a shortcut that combines Extended<T1>(IGrammarSymbol<T1>) and Finish<T>(Func<T1, T>).
WithPrecedence<T>(T, out object)
Changes the precedence token of the production. This method provides an API more friendly to C#.
public static T WithPrecedence<T>(this T builder, out object precedenceToken) where T : IProductionBuilder<T>
Parameters
builder
TThe production builder.
precedenceToken
objectA reference where the precedence token will be written to.
Returns
- T
Type Parameters
T
The type of the production builder.
- See Also