Пример #1
0
        public WindowSimpleCanvas(PartialExpression parseTree)
        {
            this.parseTree = parseTree;

            DataContext = this;
            InitializeComponent();

            ParseTreeDrawing.Draw(ParseTreeCanvas, parseTree);
        }
Пример #2
0
        public WindowUserHelp(PhiniteSettings settings, object machineOperationsLock, FiniteStateMachine machine)
        {
            if (machineOperationsLock == null)
            {
                throw new ArgumentNullException("machineOperationsLock");
            }
            if (machine == null)
            {
                throw new ArgumentNullException("machine");
            }

            this.settings = settings;

            fsmLock = machineOperationsLock;
            fsm     = machine;

            //lock (fsmLock)
            {
                states    = fsm.States;
                accepting = fsm.AcceptingStates;

                newExpression = fsm.NextNotLabeledState;

                parseTree = newExpression.ParseTree;

                newExpressionSimilarities = fsm.NextNotLabeledStateSimilarities;
            }

            newExpressionProcessed = false;
            expressionIsSelected   = false;
            selectedExpression     = -1;
            labeledExpressionsData = null;

            DataContext = this;
            InitializeComponent();

            ParseTreeDrawing.Draw(ParseTreeCanvas, parseTree);

            var data = new List <Tuple <RegularExpression, string, string, string> >();
            int i    = 0;

            foreach (var state in states)
            {
                var stateIsAccepting = accepting.Contains(state);

                StringBuilder s = new StringBuilder();
                if (i == 0)
                {
                    s.Append("initial state");
                }
                if (stateIsAccepting)
                {
                    if (i == 0)
                    {
                        s.Append(", ");
                    }
                    s.Append("accepting state");
                }

                //double similarity = newExpression.Similarity(state);

                data.Add(new Tuple <RegularExpression, string, string, string>(state, String.Format("q{0}", i), s.ToString(),
                                                                               String.Format("{0:0.00}%", newExpressionSimilarities[i] * 100)));

                ++i;
            }

            LabeledExpressionsData = data;
        }
Пример #3
0
        private void ButtonReduce_Click(object sender, RoutedEventArgs e)
        {
            parseTree.Reduce();

            ParseTreeDrawing.Draw(ParseTreeCanvas, parseTree);
        }