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
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
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
this[int]
Gets the LrState of the LrStateMachine with the specified index.
public LrState this[int index] { get; }
Parameters
index
intThe state's index, starting from zero.
Property Value
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()