Table of Contents

Class ParserStateContext<TChar, T>

Namespace
Farkle.Parser
Assembly
Farkle.dll

Extends ParserStateContext<TChar> with the ability to return a result and some user-facing extensibility points.

public abstract class ParserStateContext<TChar, T> : ParserStateContext<TChar>, IParserStateBox, IBufferWriter<TChar>

Type Parameters

TChar

The type of characters that are parsed. Usually it is char or byte (not supported by Farkle's built-in parsers).

T

The type of result the parser produces in case of success.

Inheritance
ParserStateContext<TChar, T>
Implements
Inherited Members

Remarks

Unlike ParserStateContext<TChar> this class can be inherited but user code rarely needs to do it. To create a ParserStateContext<TChar, T> use the Create<TChar, T>(IParser<TChar, T>, ParserStateContextOptions?) method.

Constructors

ParserStateContext(ParserStateContextOptions?)

protected ParserStateContext(ParserStateContextOptions? options = null)

Parameters

options ParserStateContextOptions

Options to configure the context. Optional.

Properties

IsCompleted

Whether the parsing operation has completed.

public override sealed bool IsCompleted { get; }

Property Value

bool

Result

The result of the parsing operation.

public ParserResult<T> Result { get; }

Property Value

ParserResult<T>

Exceptions

InvalidOperationException

IsCompleted is false.

See Also

Methods

OnReset()

Provides an extensibility point for the ParserStateContext<TChar, T>'s resetting logic. This method gets called by Reset().

protected virtual void OnReset()

Reset()

Resets the ParserStateContext<TChar>, allowing it to be reused for another parsing operation.

public override sealed void Reset()

Remarks

This method cannot be overridden by user code. To provide custom resetting logic override OnReset() instead.

Run(ref ParserInputReader<TChar>, ref ParserCompletionState<T>)

Invokes the parsing logic of the ParserStateContext<TChar, T>.

protected abstract void Run(ref ParserInputReader<TChar> input, ref ParserCompletionState<T> completionState)

Parameters

input ParserInputReader<TChar>

Used to access the characters and the operation's ParserState.

completionState ParserCompletionState<T>

Used to set that the operation has completed.

See Also