static public ListOfAllAutomates GetList() { List <Automate> result = new List <Automate>(); Automate automateId = GetAutomate("ID.txt"); result.Add(automateId); Automate automateInt = GetAutomate("INT.txt"); result.Add(automateInt); Automate automateBool = GetAutomate("BOOL.txt"); result.Add(automateBool); Automate automateOp = GetAutomate("OP.txt"); result.Add(automateOp); Automate automateKw = GetAutomate("KW.txt"); result.Add(automateKw); Automate automateSplit = GetAutomate("SPLIT.txt"); result.Add(automateSplit); Automate automateRf = GetAutomate("RF.txt"); result.Add(automateRf); return(new ListOfAllAutomates(result)); }
static public Automate GetAutomate(string fileName) { Automate automate = new Automate(); using (StreamReader streamReader = new StreamReader(fileName)) { string s = streamReader.ReadToEnd(); automate = JsonConvert.DeserializeObject <Automate>(s); } return(automate); }
public List <KeyValuePair <string, string> > Move(string inf, int offset) { var result = new List <KeyValuePair <string, string> >(); while (offset < inf.Length) { Automate automate = null; int Count = -1; string s = ""; bool IsItCorrect = false; foreach (var item in automates) { var resultAutomate = item.Move(inf, offset); if (resultAutomate.Value != 0) { IsItCorrect = true; if (resultAutomate.Value > Count) { Count = resultAutomate.Value; automate = item; s = inf.Substring(offset, resultAutomate.Value); } if (resultAutomate.Value == Count) { if (item.Priority > automate.Priority) { automate = item; s = inf.Substring(offset, resultAutomate.Value); } } } } if (IsItCorrect) { result.Add(new KeyValuePair <string, string>(lexems[automate], s)); offset += Count; } else { offset++; } } return(result); }