private static Graph CreateGraph <T>(IAutomatonTable <T> Automaton) { Node n; Graph graph = new Graph("graph"); graph.GraphAttr.Orientation = Microsoft.Glee.Drawing.Orientation.Landscape; foreach (State <T> state in Automaton.States) { n = graph.AddNode(Automaton.IndexOf(state).ToString()); n.UserData = string.Join(" ", state.ReduceActions.Select(item => $"{item.Name}:{item.Input}")); //:{item.TargetStateIndex}:{item.Value} if (state.ReduceActions.Count() > 0) { n.Attr.Shape = Microsoft.Glee.Drawing.Shape.DoubleCircle; } else { n.Attr.Shape = Microsoft.Glee.Drawing.Shape.Circle; } //if (state.AcceptActions.Count > 0) n.Attr.Color = Microsoft.Glee.Drawing.Color.Blue; } foreach (State <T> state in Automaton.States) { foreach (Shift <T> action in state.ShiftActions) { graph.AddEdge(Automaton.IndexOf(state).ToString(), action.Input.ToString(), action.TargetStateIndex.ToString()); } } return(graph); }
private void CreateView <T>(IAutomatonTable <T> Model) { GraphView view; view = new GraphView(); views.Add(view); view.SetAutomatonTables(CreateGraph(Model)); }
private IAutomatonTableTuple <T> DevelopSituationsAndCreateTupleIfNotExists(IAutomatonTable <T> AutomatonTable, ISituationCollectionFactory <T> SituationCollectionFactory, Stack <IAutomatonTableTuple <T> > OpenList, ISituationDictionary <T> SituationDictionary, IEnumerable <ISituation <T> > Situations) { IAutomatonTableTuple <T> nextTuple; State <T> state; ISituationCollection <T> developpedSituations; developpedSituations = SituationCollectionFactory.Develop(Situations); nextTuple = SituationDictionary.GetTuple(developpedSituations); if (nextTuple == null) { state = new State <T>(); AddReductionsToState(state, developpedSituations); AutomatonTable.Add(state); nextTuple = SituationDictionary.CreateTuple(state, developpedSituations); OpenList.Push(nextTuple); } return(nextTuple); }
public AutomatonTableParser(IAutomatonTable <char> AutomatonTable) { this.automatonTable = AutomatonTable; this.stateIndex = 0; }
public Automaton(IAutomatonTable <char> AutomatonTable) : base(AutomatonTable) { }
public Automaton(IAutomatonTable <Token> AutomatonTable) : base(AutomatonTable) { }