automate
This commit is contained in:
@ -38,13 +38,15 @@ namespace Yavsc.Abstract.IT
|
|||||||
var candide = new CharArray(letter);
|
var candide = new CharArray(letter);
|
||||||
|
|
||||||
// TODO build new denied letters: compute the automate
|
// TODO build new denied letters: compute the automate
|
||||||
|
// and check it is determinised
|
||||||
|
// Automate a = new Automate();
|
||||||
Add(candide);
|
Add(candide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
{
|
{
|
||||||
|
// this is a n*n task
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,5 +60,39 @@ namespace Yavsc.Abstract.IT
|
|||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Automate
|
||||||
|
{
|
||||||
|
int State { get; set; }
|
||||||
|
|
||||||
|
Dictionary<int, Dictionary<int,int>> Transitions { get; set; }
|
||||||
|
|
||||||
|
CodeFromChars Code { get; set; }
|
||||||
|
|
||||||
|
void Compute(CharArray chars)
|
||||||
|
{
|
||||||
|
if (!Code.Contains(chars)) {
|
||||||
|
State = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Transitions.ContainsKey(State)) {
|
||||||
|
State = -2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var states = Transitions[State];
|
||||||
|
|
||||||
|
int letter = Code.IndexOf(chars);
|
||||||
|
|
||||||
|
if (!states.ContainsKey(letter))
|
||||||
|
{
|
||||||
|
State = -3;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
State = states[letter];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user