Mercurial > pub > ImplabNet
diff Implab/Automaton/EDFADefinition.cs @ 162:0526412bbb26 ref20160224
DFA refactoring
author | cin |
---|---|
date | Wed, 24 Feb 2016 08:39:53 +0300 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab/Automaton/EDFADefinition.cs Wed Feb 24 08:39:53 2016 +0300 @@ -0,0 +1,29 @@ +using Implab; +using System; + +namespace Implab.Parsing { + public class EDFADefinition<T> : DFADefinition where T : struct, IConvertible { + readonly EnumAlphabet<T> m_alphabet; + + public EnumAlphabet<T> Alphabet { + get { return m_alphabet; } + } + + public EDFADefinition(EnumAlphabet<T> alphabet) : base(alphabet.Count) { + m_alphabet = alphabet; + } + + public void DefineTransition(int s1, int s2, T input) { + DefineTransition(s1, s2, m_alphabet.Translate(input)); + } + + public EDFADefinition<T> Optimize() { + + return (EDFADefinition<T>)Optimize(alphabet => new EDFADefinition<T>((EnumAlphabet<T>)alphabet), m_alphabet, new EnumAlphabet<T>()); + } + + public void PrintDFA() { + PrintDFA(m_alphabet); + } + } +}