Table of Contents

Class LrStateMachine

Namespace
Farkle.Grammars.StateMachines
Assembly
Farkle.dll

Represents an LR(1) state machine stored in a Grammar. It is used by parsers to parse tokens produced by tokenizers.

public abstract class LrStateMachine : IReadOnlyList<LrState>, IReadOnlyCollection<LrState>, IEnumerable<LrState>, IEnumerable
Inheritance
LrStateMachine
Implements

Properties

Count

The number of states in the LrStateMachine.

public int Count { get; }

Property Value

int

HasConflicts

Whether there might be at least one state in the LrStateMachine with more than one possible actions for the same terminal, or the end of input.

public bool HasConflicts { get; }

Property Value

bool

Remarks

Parsers can use this property to quickly determine if the state machine is usable for parsing.

Note that on some pathological grammar files it is possible for a state machine to not have conflicts and this property to have a value of true, but a value of false guarantees that it doesn't have conflicts. Farkle does not treat such state machines as suitable for parsing.

InitialState

The number of the LrStateMachine's initial state.

public int InitialState { get; }

Property Value

int

this[int]

Gets the LrState of the LrStateMachine with the specified index.

public LrState this[int index] { get; }

Parameters

index int

The state's index, starting from zero.

Property Value

LrState

Exceptions

ArgumentOutOfRangeException

index is less than zero or greater than or equal to Count.

Methods

GetEnumerator()

Gets the enumerator of the LrStateMachine's states.

public LrStateMachine.Enumerator GetEnumerator()

Returns

LrStateMachine.Enumerator