C# 클래스 Microsoft.Automata.Grammars.ContextFreeGrammar

Symbolic Context Free Grammar
파일 보기 프로젝트 열기: AutomataDotNet/Automata 1 사용 예제들

공개 메소드들

메소드 설명
ContextFreeGrammar ( Nonterminal startSymbol, IEnumerable productions ) : System
Display ( TextWriter tw ) : void

Writes the productions 'E -> alpha_1 | alpha_2 | ... | alpha_n' to tw with the set of productions for each nonterminal E (variable) per line.

GetNonVariableSymbols ( ) : IEnumerable
GetProductions ( ) : IEnumerable
GetProductions ( Nonterminal v ) : IList
GetUsefulNonterminals ( ) : HashSet

Return all useful nonterminal symbols.

GetUsefulNonterminals ( bool checkBackwardsOnly ) : HashSet

Return all useful nonterminal symbols. If checkBackwardsOnly is true, assume that all symbols are reachable from the start symbol.

IsValidVariable ( Nonterminal v ) : bool
MkCNF ( ContextFreeGrammar g ) : ContextFreeGrammar

Returns MkCNF(g, true)

MkCNF ( ContextFreeGrammar g, bool removeEpsilonsUselessSymbolsUnitsProductions ) : ContextFreeGrammar

Produces the CNF (Chomsky Normal Form) for the grammar g. It first eliminates epsilons, useless symbols, and unit productions. If Assumes that there are no epsilons, useless symbols or unit productions

MkEGNF ( ContextFreeGrammar g ) : ContextFreeGrammar

Produces the EGNF (Extended Greibach Normal Form) for the grammar g. The grammar g can be arbitrary. First removes epsilons and useless symbols from g. Implements a variation of the Blum-Koch algorithm. (Inf. and Comp. vol.150, pp.112-118, 1999)

MkEGNF ( ContextFreeGrammar g, bool removeEpsilonsAndUselessSymbols ) : ContextFreeGrammar

Produces the EGNF (Extended Greibach Normal Form) for the grammar g. Implements a variation of the Blum-Koch algorithm. (Inf. and Comp. vol.150, pp.112-118, 1999)

MkGNF ( ContextFreeGrammar g ) : ContextFreeGrammar

Returns MkGNF(g, true)

MkGNF ( ContextFreeGrammar g, bool removeEpsilonsUselessSymbolsUnitsProductions ) : ContextFreeGrammar

Produces the GNF (Greibach Normal Form) for the grammar g. If g is not already in GNF, first makes CNF. Implements a variation of the Koch-Blum algorithm. (STACS 97, pp. 47-54)

RemoveEpsilonsAndUselessSymbols ( ) : ContextFreeGrammar

Removes epsilon productions and then removes useless symbols. Assumes that the grammar does not accept the empty string and that the language is nonempty.

RemoveUnitProductions ( ) : ContextFreeGrammar

Removes all productions of the form A->B where A and B are variables. Removes also all the useless symbols after the unit production elimination. Assumes that the grammar has no epsilon productions.

RemoveUselessSymbols ( ) : ContextFreeGrammar

Removes useless symbols from the grammar. Assumes that the language is nonempty.

RestrictToVariables ( HashSet varSet ) : ContextFreeGrammar

Restrict the grammar to the given variables.

ToString ( ) : string

Returns the value of Description

비공개 메소드들

메소드 설명
AllVariablesExceptTheStartSymbol ( ) : IEnumerable
ContextFreeGrammar ( List variables, Nonterminal startSymbol, Dictionary productionMap ) : System
DescribeProductions ( Nonterminal v ) : string
EliminateNullables ( Nonterminal v, HashSet nullables ) : IEnumerable
EnumerateNullableFreeVariations ( ConsList symbols, HashSet nullables ) : IEnumerable>
FinalStateHasVariableMoves ( Automaton MB ) : bool
GetNullables ( ) : HashSet
GetUnitClosure ( Nonterminal v ) : HashSet
IsInCNF ( ) : bool
IsInGNF ( ) : bool
Lookup ( Nonterminal>.Dictionary vars, Nonterminal key, int &nonterminalID ) : Nonterminal
StartSymbolAppearsInRhs ( ) : bool

메소드 상세

ContextFreeGrammar() 공개 메소드

public ContextFreeGrammar ( Nonterminal startSymbol, IEnumerable productions ) : System
startSymbol Nonterminal
productions IEnumerable
리턴 System

Display() 공개 메소드

Writes the productions 'E -> alpha_1 | alpha_2 | ... | alpha_n' to tw with the set of productions for each nonterminal E (variable) per line.
public Display ( TextWriter tw ) : void
tw System.IO.TextWriter
리턴 void

GetNonVariableSymbols() 공개 메소드

public GetNonVariableSymbols ( ) : IEnumerable
리턴 IEnumerable

GetProductions() 공개 메소드

public GetProductions ( ) : IEnumerable
리턴 IEnumerable

GetProductions() 공개 메소드

public GetProductions ( Nonterminal v ) : IList
v Nonterminal
리턴 IList

GetUsefulNonterminals() 공개 메소드

Return all useful nonterminal symbols.
public GetUsefulNonterminals ( ) : HashSet
리턴 HashSet

GetUsefulNonterminals() 공개 메소드

Return all useful nonterminal symbols. If checkBackwardsOnly is true, assume that all symbols are reachable from the start symbol.
public GetUsefulNonterminals ( bool checkBackwardsOnly ) : HashSet
checkBackwardsOnly bool
리턴 HashSet

IsValidVariable() 공개 메소드

public IsValidVariable ( Nonterminal v ) : bool
v Nonterminal
리턴 bool

MkCNF() 공개 정적인 메소드

Returns MkCNF(g, true)
public static MkCNF ( ContextFreeGrammar g ) : ContextFreeGrammar
g ContextFreeGrammar
리턴 ContextFreeGrammar

MkCNF() 공개 정적인 메소드

Produces the CNF (Chomsky Normal Form) for the grammar g. It first eliminates epsilons, useless symbols, and unit productions. If Assumes that there are no epsilons, useless symbols or unit productions
public static MkCNF ( ContextFreeGrammar g, bool removeEpsilonsUselessSymbolsUnitsProductions ) : ContextFreeGrammar
g ContextFreeGrammar
removeEpsilonsUselessSymbolsUnitsProductions bool
리턴 ContextFreeGrammar

MkEGNF() 공개 정적인 메소드

Produces the EGNF (Extended Greibach Normal Form) for the grammar g. The grammar g can be arbitrary. First removes epsilons and useless symbols from g. Implements a variation of the Blum-Koch algorithm. (Inf. and Comp. vol.150, pp.112-118, 1999)
public static MkEGNF ( ContextFreeGrammar g ) : ContextFreeGrammar
g ContextFreeGrammar the grammar to be normalized
리턴 ContextFreeGrammar

MkEGNF() 공개 정적인 메소드

Produces the EGNF (Extended Greibach Normal Form) for the grammar g. Implements a variation of the Blum-Koch algorithm. (Inf. and Comp. vol.150, pp.112-118, 1999)
public static MkEGNF ( ContextFreeGrammar g, bool removeEpsilonsAndUselessSymbols ) : ContextFreeGrammar
g ContextFreeGrammar the grammar to be normalized
removeEpsilonsAndUselessSymbols bool if true, first removes epsilons and useless symbols, otherwise assumes that epsilons do not occur
리턴 ContextFreeGrammar

MkGNF() 공개 정적인 메소드

Returns MkGNF(g, true)
public static MkGNF ( ContextFreeGrammar g ) : ContextFreeGrammar
g ContextFreeGrammar
리턴 ContextFreeGrammar

MkGNF() 공개 정적인 메소드

Produces the GNF (Greibach Normal Form) for the grammar g. If g is not already in GNF, first makes CNF. Implements a variation of the Koch-Blum algorithm. (STACS 97, pp. 47-54)
public static MkGNF ( ContextFreeGrammar g, bool removeEpsilonsUselessSymbolsUnitsProductions ) : ContextFreeGrammar
g ContextFreeGrammar
removeEpsilonsUselessSymbolsUnitsProductions bool
리턴 ContextFreeGrammar

RemoveEpsilonsAndUselessSymbols() 공개 메소드

Removes epsilon productions and then removes useless symbols. Assumes that the grammar does not accept the empty string and that the language is nonempty.
public RemoveEpsilonsAndUselessSymbols ( ) : ContextFreeGrammar
리턴 ContextFreeGrammar

RemoveUnitProductions() 공개 메소드

Removes all productions of the form A->B where A and B are variables. Removes also all the useless symbols after the unit production elimination. Assumes that the grammar has no epsilon productions.
public RemoveUnitProductions ( ) : ContextFreeGrammar
리턴 ContextFreeGrammar

RemoveUselessSymbols() 공개 메소드

Removes useless symbols from the grammar. Assumes that the language is nonempty.
public RemoveUselessSymbols ( ) : ContextFreeGrammar
리턴 ContextFreeGrammar

RestrictToVariables() 공개 메소드

Restrict the grammar to the given variables.
public RestrictToVariables ( HashSet varSet ) : ContextFreeGrammar
varSet HashSet
리턴 ContextFreeGrammar

ToString() 공개 메소드

Returns the value of Description
public ToString ( ) : string
리턴 string