Beispiel #1
0
        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);
        }
Beispiel #2
0
        private void CreateView <T>(IAutomatonTable <T> Model)
        {
            GraphView view;

            view = new GraphView();
            views.Add(view);
            view.SetAutomatonTables(CreateGraph(Model));
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public AutomatonTableParser(IAutomatonTable <char> AutomatonTable)
 {
     this.automatonTable = AutomatonTable; this.stateIndex = 0;
 }
Beispiel #5
0
 public Automaton(IAutomatonTable <char> AutomatonTable) : base(AutomatonTable)
 {
 }
Beispiel #6
0
 public Automaton(IAutomatonTable <Token> AutomatonTable) : base(AutomatonTable)
 {
 }