Table of Contents

Class CharParser

Namespace
Farkle
Assembly
Farkle.dll

Provides factory methods to create CharParser<T>s.

public static class CharParser
Inheritance
CharParser

Methods

CreateReloadable<T>(Func<CharParser<T>>)

Creates a CharParser<T> that wraps the result of a factory function, and refreshes it when Hot Reload is performed.

public static CharParser<T> CreateReloadable<T>(Func<CharParser<T>> parserFactory)

Parameters

parserFactory Func<CharParser<T>>

The factory to create the parser.

Returns

CharParser<T>

Type Parameters

T

The type of objects the parser will produce in case of success.

Remarks

This method calls parserFactory before returning and caches the result to the returned parser. When Hot Reload gets performed, the cache gets cleared, and the next use of the returned parser will call parserFactory again. Modifications to the returned parser's tokenizer and semantic provider will be applied again after fetching the updated parser.

The returned parser remains thread-safe and can be reloaded safely while a parser operation via ParserStateContext<TChar, T> is underway.

If Hot Reload is not supported, this method is equivalent to calling parserFactory.

CreateSyntaxChecker(Grammar)

Creates a CharParser<T> that does not perform any semantic analysis.

public static CharParser<object?> CreateSyntaxChecker(Grammar grammar)

Parameters

grammar Grammar

The Grammar the syntax checker will use.

Returns

CharParser<object>

Remarks

Syntax checkers always return null in case of success.

CreateSyntaxChecker<T>(Grammar)

Creates a CharParser<T> that does not perform any semantic analysis.

public static CharParser<T?> CreateSyntaxChecker<T>(Grammar grammar) where T : class?

Parameters

grammar Grammar

The Grammar the syntax checker will use.

Returns

CharParser<T>

Type Parameters

T

The type of objects the syntax checker will return in case of success. Must be a reference type and usually it is object or Microsoft.FSharp.Core.Unit.

Remarks

Syntax checkers always return null in case of success.

Exceptions

ArgumentNullException

grammar is null.

Create<T>(Grammar, ISemanticProvider<char, T>)

Creates a CharParser<T>.

public static CharParser<T> Create<T>(Grammar grammar, ISemanticProvider<char, T> semanticProvider)

Parameters

grammar Grammar

The Grammar the parser will use.

semanticProvider ISemanticProvider<char, T>

The ISemanticProvider<TChar, T> the parser will use.

Returns

CharParser<T>

Type Parameters

T

The type of objects the parser will produce in case of success.

Exceptions

ArgumentNullException

grammar or semanticProvider is null.