RegularDFADefinition.cs
43 lines
| 1.4 KiB
| text/x-csharp
|
CSharpLexer
cin
|
r164 | using System; | ||
namespace Implab.Automaton.RegularExpressions { | ||||
public class RegularDFADefinition<TInput, TTag> : DFATransitionTable<TTag>, IDFATransitionTable<TTag> { | ||||
readonly IAlphabet<TInput> m_alphabet; | ||||
cin
|
r165 | public RegularDFADefinition(IAlphabet<TInput> alphabet) { | ||
cin
|
r164 | Safe.ArgumentNotNull(alphabet, "aplhabet"); | ||
m_alphabet = alphabet; | ||||
} | ||||
public IAlphabet<TInput> InputAlphabet { | ||||
get { | ||||
return m_alphabet; | ||||
} | ||||
} | ||||
protected override DFAStateDescriptior<TTag>[] ConstructTransitionTable() { | ||||
if (InputAlphabet.Count != m_alphabet.Count) | ||||
throw new InvalidOperationException("The alphabet doesn't match the transition table"); | ||||
return base.ConstructTransitionTable(); | ||||
} | ||||
/// <summary> | ||||
/// Optimize the specified alphabet. | ||||
/// </summary> | ||||
cin
|
r165 | /// <param name = "dfaTable"></param> | ||
cin
|
r164 | /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param> | ||
cin
|
r165 | public void Optimize(IDFATableBuilder<TTag> dfaTable, IAlphabetBuilder<TInput> alphabet) { | ||
cin
|
r164 | Safe.ArgumentNotNull(alphabet, "alphabet"); | ||
cin
|
r165 | Safe.ArgumentNotNull(dfaTable, "dfaTable"); | ||
cin
|
r164 | |||
cin
|
r165 | Optimize(dfaTable, InputAlphabet, alphabet, new DummyAlphabet(StateCount), new MapAlphabet<int>()); | ||
cin
|
r164 | } | ||
} | ||||
} | ||||