C# Класс Antlr4.Runtime.Dfa.DFAState

A DFA state represents a set of possible ATN configurations.
A DFA state represents a set of possible ATN configurations. As Aho, Sethi, Ullman p. 117 says "The DFA uses its state to keep track of all possible states the ATN can be in after reading each input symbol. That is to say, after reading input a1a2..an, the DFA is in a state that represents the subset T of the states of the ATN that are reachable from the ATN's start state along some path labeled a1a2..an." In conventional NFA→DFA conversion, therefore, the subset T would be a bitset representing the set of states the ATN could be in. We need to track the alt predicted by each state as well, however. More importantly, we need to maintain a stack of states, tracking the closure operations as they jump from rule to rule, emulating rule invocations (method calls). I have to add a stack to simulate the proper lookahead sequences for the underlying LL grammar from which the ATN was derived.

I use a set of ATNConfig objects not simple states. An ATNConfig is both a state (ala normal conversion) and a RuleContext describing the chain of rules (if any) followed to arrive at that state.

A DFA state may have multiple references to a particular state, but with different ATN contexts (with same or different alts) meaning that state was reached via a different set of rule invocations.

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
stateNumber int

Открытые методы

Метод Описание
DFAState ( DFA dfa, ATNConfigSet configs ) : System
DFAState ( EmptyEdgeMap emptyEdges, EmptyEdgeMap emptyContextEdges, ATNConfigSet configs ) : System
Equals ( object o ) : bool

Two DFAState instances are equal if their ATN configuration sets are the same. This method is used to see if a state already exists.

Because the number of alternatives and number of ATN configurations are finite, there is a finite number of DFA states that can be processed. This is necessary to show that the algorithm terminates.

Cannot test the DFA state numbers here because in Antlr4.Runtime.Atn.ParserATNSimulator.AddDFAState(DFA, Antlr4.Runtime.Atn.ATNConfigSet, Antlr4.Runtime.Atn.PredictionContextCache) we need to know if any other state exists that has this exact set of ATN configurations. The stateNumber is irrelevant.

GetContextTarget ( int invokingState ) : DFAState
GetHashCode ( ) : int
GetTarget ( int symbol ) : DFAState
IsContextSymbol ( int symbol ) : bool
SetContextSensitive ( ATN atn ) : void
SetContextSymbol ( int symbol ) : void
SetContextTarget ( int invokingState, DFAState target ) : void
SetTarget ( int symbol, DFAState target ) : void
ToString ( ) : string

Описание методов

DFAState() публичный метод

public DFAState ( DFA dfa, ATNConfigSet configs ) : System
dfa DFA
configs ATNConfigSet
Результат System

DFAState() публичный метод

public DFAState ( EmptyEdgeMap emptyEdges, EmptyEdgeMap emptyContextEdges, ATNConfigSet configs ) : System
emptyEdges EmptyEdgeMap
emptyContextEdges EmptyEdgeMap
configs ATNConfigSet
Результат System

Equals() публичный метод

Two DFAState instances are equal if their ATN configuration sets are the same. This method is used to see if a state already exists.

Because the number of alternatives and number of ATN configurations are finite, there is a finite number of DFA states that can be processed. This is necessary to show that the algorithm terminates.

Cannot test the DFA state numbers here because in Antlr4.Runtime.Atn.ParserATNSimulator.AddDFAState(DFA, Antlr4.Runtime.Atn.ATNConfigSet, Antlr4.Runtime.Atn.PredictionContextCache) we need to know if any other state exists that has this exact set of ATN configurations. The stateNumber is irrelevant.

public Equals ( object o ) : bool
o object
Результат bool

GetContextTarget() публичный метод

public GetContextTarget ( int invokingState ) : DFAState
invokingState int
Результат DFAState

GetHashCode() публичный метод

public GetHashCode ( ) : int
Результат int

GetTarget() публичный метод

public GetTarget ( int symbol ) : DFAState
symbol int
Результат DFAState

IsContextSymbol() публичный метод

public IsContextSymbol ( int symbol ) : bool
symbol int
Результат bool

SetContextSensitive() публичный метод

public SetContextSensitive ( ATN atn ) : void
atn Antlr4.Runtime.Atn.ATN
Результат void

SetContextSymbol() публичный метод

public SetContextSymbol ( int symbol ) : void
symbol int
Результат void

SetContextTarget() публичный метод

public SetContextTarget ( int invokingState, DFAState target ) : void
invokingState int
target DFAState
Результат void

SetTarget() публичный метод

public SetTarget ( int symbol, DFAState target ) : void
symbol int
target DFAState
Результат void

ToString() публичный метод

public ToString ( ) : string
Результат string

Описание свойств

stateNumber публичное свойство

public int stateNumber
Результат int