##// END OF EJS Templates
JSON moved to Formats namespace...
JSON moved to Formats namespace Working in RegularDFA

File last commit:

r163:419aa51b04fd ref20160224
r163:419aa51b04fd ref20160224
Show More
DummyAlphabet.cs
46 lines | 1.2 KiB | text/x-csharp | CSharpLexer
using System;
using System.Collections.Generic;
using System.Linq;
namespace Implab.Automaton {
public class DummyAlphabet : IAlphabet<int> {
readonly int m_size;
public DummyAlphabet(int size) {
Safe.ArgumentAssert(size > 0);
m_size = 0;
}
#region IAlphabet implementation
public List<int>[] CreateReverseMap() {
Enumerable.Range(0, m_size).ToArray();
}
public int[] Reclassify(IAlphabetBuilder<int> newAlphabet, IEnumerable<IEnumerable<int>> classes) {
Safe.ArgumentNotNull(newAlphabet, "newAlphabet");
Safe.ArgumentNotNull(classes, "classes");
var map = new int[m_size];
foreach (var cls in classes) {
var newid = newAlphabet.DefineClass(cls);
foreach (var id in cls)
map[id] = newid;
}
return map;
}
public int Translate(int symobl) {
Safe.ArgumentInRange(symobl, 0, m_size, "symbol");
return symobl;
}
public int Count {
get {
return m_size;
}
}
#endregion
}
}