internal void AddOutTransition(LTSTransition trans) { List <LTSTransition> list; if (!_outTransitions.TryGetValue(trans.Action, out list)) { list = _outTransitions[trans.Action] = new List <LTSTransition>(); } list.Add(trans); }
public static LTS Parse(string file) { // parse aldebran format var ret = new LTS(); var sr = new StreamReader(file, Encoding.Default); var lineRE = new Regex(@"\((\w+)\s*,\s*""([^\""]+?)""\s*,\s*(\w+)\s*\)"); string initial = string.Empty; while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.StartsWith("des")) { var m = Regex.Match(line, @"des\s*\((\w+?),(\w+?),(\w+?)\)"); if (m.Success) { initial = m.Groups[1].Captures[0].Value; } continue; } var match = lineRE.Match(line); if (match.Success) { string start = match.Groups[1].Captures[0].Value; string label = match.Groups[2].Captures[0].Value; string end = match.Groups[3].Captures[0].Value; LTSState startState = GetState(start, ret); LTSState endState = GetState(end, ret); LTSTransition trans = new LTSTransition(startState, label, endState); ret.Actions.Add(label); ret.Transitions.Add(trans); startState.AddOutTransition(trans); //endState.AddInTransition(trans); } else { int i = 0; } } ret.InitialState = GetState(initial, ret); return(ret); }
public static LTS Parse(string file) { // parse aldebran format var ret = new LTS(); var sr = new StreamReader(file, Encoding.Default); var lineRE = new Regex(@"\((\w+)\s*,\s*""([^\""]+?)""\s*,\s*(\w+)\s*\)"); string initial = string.Empty; while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.StartsWith("des")) { var m = Regex.Match(line, @"des\s*\((\w+?),(\w+?),(\w+?)\)"); if (m.Success) { initial = m.Groups[1].Captures[0].Value; } continue; } var match = lineRE.Match(line); if (match.Success) { string start = match.Groups[1].Captures[0].Value; string label = match.Groups[2].Captures[0].Value; string end = match.Groups[3].Captures[0].Value; LTSState startState = GetState(start, ret); LTSState endState = GetState(end, ret); LTSTransition trans = new LTSTransition(startState, label, endState); ret.Actions.Add(label); ret.Transitions.Add(trans); startState.AddOutTransition(trans); //endState.AddInTransition(trans); } else { int i = 0; } } ret.InitialState = GetState(initial, ret); return ret; }
internal void AddOutTransition(LTSTransition trans) { List<LTSTransition> list; if (!_outTransitions.TryGetValue(trans.Action, out list)) { list = _outTransitions[trans.Action] = new List<LTSTransition>(); } list.Add(trans); }