Example #1
0
        public FABarButtonItem(FA icon, string title, UIColor fontColor, EventHandler handler)
            : base()
        {
            UIView view = new UIView (new CGRect (0, 0, 32, 32));

            _iconButton = new UIButton (new CGRect (0, 0, 32, 21)) {
                Font = icon.Font (20),
            };
            _iconButton.SetTitleColor (fontColor, UIControlState.Normal);
            _iconButton.TouchUpInside += handler;

            _titleLabel = new UILabel (new CGRect (0, 18, 32, 10)) {
                TextColor = fontColor,
                Font = UIFont.SystemFontOfSize(10f),
                TextAlignment = UITextAlignment.Center
            };

            this.Title = title;
            this.Icon = icon.String();

            view.Add (_iconButton);
            view.Add (_titleLabel);

            CustomView = view;
        }
Example #2
0
 public CHopcroftAlgorithm(FA dfa)
 {
     m_DFA                     = dfa;
     m_minimizedDFA            = new FA();
     m_nodeConfiguration       = new HopcroftInputGraphQueryInfo(m_DFA, m_HOPCROFTCONFIGURATIONKEY);
     m_minDFANodeConfiguration = new HopcroftOutputGraphQueryInfo(m_minimizedDFA, m_HOPCROFTCONFIGURATIONKEY);
     m_reporting               = new CHopcroftReporting(m_minDFANodeConfiguration, m_nodeConfiguration);
 }
 public CConfigurations(FA DFA, FA NFA)
 {
     m_DFA          = DFA;
     m_NFA          = NFA;
     m_mappings     = new Dictionary <CGraphNode, HashSet <CGraphNode> >();
     m_NFAStateInfo = new FAGraphQueryInfo(m_NFA, FA.m_FAINFOKEY);
     m_DFAStateInfo = new FAGraphQueryInfo(m_DFA, FA.m_FAINFOKEY);
 }
Example #4
0
 public FAButton(FA icon, UIColor fontColor, float iconSize = 20)
     : base()
 {
     Icon = icon;
     IconSize = iconSize;
     SetTitleColor (fontColor, UIControlState.Normal);
     SetTitleColor (fontColor.ColorWithAlpha(100), UIControlState.Highlighted);
 }
Example #5
0
            public static FA Plus(FA fa)
            {
                var clone = fa.ToNfa(true);

                clone.Final.Add(clone.Start);

                return(clone);
            }
Example #6
0
            public static FA Optional(FA fa)
            {
                var clone = fa.ToNfa(true);

                clone.Start.Add(clone.Final);

                return(clone);
            }
    private FA CreateNewFA(FA synth)
    {
        CGraphNode oldEntryNode, oldExitNode;
        FA         m_currentFA = new FA();

        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);
        m_ThompsonInfo.InitFAInfo(new ThompsonFAInfo());

        //2.Merge graph
        m_mergeOperation = m_currentFA.Merge(synth, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        // Create boundary nodes
        m_newFASource = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFASource, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_newFASource, m_mergeOperation.GetMirrorNode(synth.M_Initial), GraphType.GT_DIRECTED);
        m_newFATarget = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFATarget, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]), m_newFATarget, GraphType.GT_DIRECTED);

        //4.Create the initial and the final node
        oldEntryNode          = m_mergeOperation.GetMirrorNode(synth.M_Initial);
        oldExitNode           = m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]);
        m_currentFA.M_Initial = m_newFASource;
        m_currentFA.SetFinalState(m_newFATarget);
        m_currentFA.UpdateAlphabet();

        // Update closure information from operand closure
        FAInfo currentFAInfo = UpdateClosureInformation(synth, m_currentFA, m_mergeOperation);

        // Update closure information from current closure
        m_currentFAloop             = new FALoop();
        m_currentFAloop.MEntryNode  = oldEntryNode;
        m_currentFAloop.MExitNode   = oldExitNode;
        m_currentFAloop.MLoopSerial = m_currentClosureSerial;
        CIt_GraphNodes it = new CIt_GraphNodes(m_currentFA);

        for (it.Begin(); !it.End(); it.Next())
        {
            if (it.M_CurrentItem != m_currentFA.M_Initial &&
                it.M_CurrentItem != m_currentFA.GetFinalStates()[0])
            {
                m_currentFAloop.MParticipatingNodes.Add(it.M_CurrentItem);
            }
        }
        // Add new closure to the current FA
        currentFAInfo.AddFALoop(m_currentFAloop);

        return(m_currentFA);
    }
        public static CDeltaAlgorithm Init(FA g, Int32 c, HashSet <CGraphNode> set)
        {
            //Make some checks on the input arguments

            // Create algorithm
            CDeltaAlgorithm newObjectAlgorithm = new CDeltaAlgorithm(g, c, set);

            return(newObjectAlgorithm);
        }
        public static CSubsetConstructionAlgorithm Init(FA g)
        {
            //Make some checks on the input arguments

            // Create algorithm
            CSubsetConstructionAlgorithm newObjectAlgorithm = new CSubsetConstructionAlgorithm(g);

            return(newObjectAlgorithm);
        }
Example #10
0
    internal FA Sythesize(FA l, FA r, CGraph.CMergeGraphOperation.MergeOptions options)
    {
        //1.Create FA
        m_currentFA    = new FA();
        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);

        //2.Merge left graph
        CGraph.CMergeGraphOperation lmerge = m_currentFA.Merge(l, options);
        //Console.WriteLine(l.ToString());
        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        lmerge.MergeGraphInfo(l, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        lmerge.MergeGraphInfo(l, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode il = lmerge.GetMirrorNode(l.M_Initial);
        CGraphNode fl = lmerge.GetMirrorNode(l.GetFinalStates()[0]);

        //3.Merge right graph
        CGraph.CMergeGraphOperation rmerge = m_currentFA.Merge(r, options);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        rmerge.MergeGraphInfo(r, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        rmerge.MergeGraphInfo(r, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        CGraphNode ir = rmerge.GetMirrorNode(r.M_Initial);
        CGraphNode fr = rmerge.GetMirrorNode(r.GetFinalStates()[0]);

        //4.Create the initial and the final node
        CGraphNode FAinit  = m_currentFA.CreateGraphNode <CGraphNode>();
        CGraphNode FAfinal = m_currentFA.CreateGraphNode <CGraphNode>();

        m_ThompsonInfo.InitNodeInfo(FAinit, new ThompsonNodeFAInfo());
        m_ThompsonInfo.InitNodeInfo(FAfinal, new ThompsonNodeFAInfo());

        m_currentFA.M_Initial = FAinit;
        m_currentFA.SetFinalState(FAfinal);
        m_currentFA.UpdateAlphabet();

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, il, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(FAinit, ir, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fr, FAfinal, GraphType.GT_DIRECTED);
        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(fl, FAfinal, GraphType.GT_DIRECTED);

        // Update closure information from operand closure
        // Update closure information from operand closure
        UpdateClosureInformation(l, m_currentFA, lmerge);
        UpdateClosureInformation(r, m_currentFA, rmerge);

        //7.Return result
        return(m_currentFA);
    }
Example #11
0
            public static FA Single(Codepoints terminal)
            {
                var start = new State();
                var end   = new State();

                start.Add(terminal, end);

                return(FA.From(start, end));
            }
Example #12
0
    internal FA SynthesizeOneOrNone(FA synth)
    {
        m_currentFA = CreateNewFA(synth);

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_newFASource, m_newFATarget, GraphType.GT_DIRECTED);

        //7.Return result
        return(m_currentFA);
    }
Example #13
0
 //Correction Env. Fact
 private void FA_corr(object sender, EventArgs e)
 {
     if (FA != 0)
     {
         FA             = FA / 1.225;
         label24.Text   = FA.ToString("0.000");
         textBox10.Text = label24.Text;
     }
 }
Example #14
0
        public override FA GetFA()
        {
            if (From.IsSingleCodePoint() && To.IsSingleCodePoint())
            {
                return(FA.From(From.GetSingleCodePoint(), To.GetSingleCodePoint()));
            }

            throw new System.NotImplementedException();
        }
Example #15
0
            public static FA Concat(FA fa, FA other)
            {
                var first = fa.ToNfa(true);

                other = other.ToNfa(true);

                first.Final.Add(other.Start);

                return(FA.From(first.Start, other.Final));
            }
Example #16
0
        public void Init(FA icon, nfloat width)
        {
            var text  = icon.ToString();
            var image = icon.String();

            _label.Text = text;
            _image.Text = image;

            _image.Font = FA.Empty.Font(width);
        }
Example #17
0
        /// <summary>
        /// Add an intermediate NFA to the list of NFA produced during the
        /// execution of the algorithm
        /// </summary>
        /// <param name="NFA"></param>
        /// <param name="infokey"></param>
        /// <param name="generateReport"></param>
        public void AddThompsonStepToReporting(FA NFA, object infokey, bool generateReport = false)
        {
            ThompsonGraphVizPrinter gp1 = new ThompsonGraphVizPrinter(NFA, new UOPCore.Options <ThompsonOptions>(ThompsonOptions.TO_COMBINEGRAPHS), infokey);

            m_ThomsonStepsPrinter.Add(gp1);
            if (generateReport)
            {
                m_ThomsonStepsPrinter.Generate();
            }
        }
Example #18
0
 /// <summary>
 /// Extracts the outcome of one of the steps of the Thompson algorithm to a file
 /// </summary>
 public void ExctractThompsonStep(FA NFA, string filename, object key, bool overrideEnableLoggingSwitch = false)
 {
     if (mb_enableLogging || overrideEnableLoggingSwitch)
     {
         ThompsonGraphVizPrinter gp =
             new ThompsonGraphVizPrinter(NFA, new UOPCore.Options <ThompsonOptions>(), key);
         NFA.RegisterGraphPrinter(gp);
         NFA.Generate(filename, true);
     }
 }
Example #19
0
            public static FA Complement(FA dfa)
            {
                EnsureDfa(dfa);

                for (var i = 0; i < dfa.States.Count; ++i)
                {
                    dfa.States[i].Final = !dfa.States[i].Final;
                }

                return(dfa);
            }
Example #20
0
        public static UILabel Label(this FA fa, UIColor color, float size)
        {
            var label = new UILabel();

            label.Font          = fa.Font(size);
            label.TextColor     = color;
            label.Text          = fa.String();
            label.TextAlignment = UITextAlignment.Center;

            return(label);
        }
Example #21
0
        public static string String(this FA value)
        {
            byte b1 = (byte)value;
            byte b2 = (byte)((int)value >> 8);

            byte[] bs = new byte[] { b1, b2 };

            string result = Encoding.Unicode.GetString(bs);

            return(result);
        }
Example #22
0
        private static Matcher MakeMatcher()
        {
            // [0]|[1-9][0-9]*
            var nfa = FA.Or(
                FA.From('0'),
                FA.And(FA.From('1', '9'), FA.From('0', '9').Star()));

            var dfa = nfa.ToDfa().Minimize();

            return(new Matcher(dfa));
        }
        public static CEclosureAlgorithm Init(FA g, HashSet <CGraphNode> set)
        {
            //Make some checks on the input arguments

            // Create algorithm
            CEclosureAlgorithm newObjectAlgorithm = new CEclosureAlgorithm(g, set);



            return(newObjectAlgorithm);
        }
Example #24
0
        public static List <FA> Values(this FA value)
        {
            var values = Enum.GetValues(typeof(FA));
            var result = new List <FA> ();

            foreach (FA item in values)
            {
                result.Add(item);
            }
            return(result);
        }
Example #25
0
        private static Matcher MakeMatcher()
        {
            // a?b?c?
            var aaa = FA.From('a').Opt();
            var bbb = FA.From('b').Opt();
            var ccc = FA.From('c').Opt();

            var nfa = FA.And(FA.From('a').Opt(), FA.From('b').Opt(), FA.From('c').Opt());

            return(new Matcher(nfa.ToDfa().Minimize()));
        }
Example #26
0
        /*
         *
         * static bool IdentifierCheck(string input)
         * {
         *  Regex rgx = new Regex("(^[a-zA-Z][a-zA-Z0-9_]{0,7}$)");
         *  return rgx.IsMatch(input);
         * }
         * static bool ConstantCheck(string input)
         * {
         *
         *  Regex rgx = new Regex($"(^[\\+$|^\\-]?[1-9][0-9]*$|^0$|^[\\+$|^\\-]?[1 - 9][0 - 9] *[.][0 - 9][1 - 9] *$|^[\\+$|^\\-] ? 0[.][0 - 9][1 - 9] *$)");
         *  return rgx.IsMatch(input);
         * }*/


        static string LongestPrefix(FA fa, string input)
        {
            var longestPrefix = fa.longestPrefix(input);

            if (!fa.accept(longestPrefix))
            {
                Console.WriteLine("Input not accepted by {0} FA: {1}", fa.Name, input);
                return("");
            }
            return(longestPrefix);
            //return fa.accept(input) ? longestPrefix : "";
        }
Example #27
0
        /// <summary>
        /// Writing Data to specific TagStream
        /// </summary>
        /// <param name="writer">TagStream to write data</param>
        /// <param name="MinorVersion">ID3 minor version</param>
        protected override void OnWritingData(int MinorVersion)
        {
            byte[] Buf;

            TStream.FS.WriteByte(_AdjustmentBits);

            foreach (FrequencyAdjustmentFrame FA in _Frequensies.ToArray())
            {
                Buf = FA.GetBytes(_AdjustmentBits);
                TStream.FS.Write(Buf, 0, Buf.Length);
            }
        }
Example #28
0
        public FABarButtonItem(FA icon, UIColor fontColor, EventHandler handler) : base()
        {
            _iconButton = new UIButton(new CGRect(0, 0, 32, 32))
            {
                Font = icon.Font(25)
            };
            _iconButton.SetTitleColor(fontColor, UIControlState.Normal);
            _iconButton.TouchUpInside += handler;

            this.Icon = icon.String();

            CustomView = _iconButton;
        }
Example #29
0
        public FABarButtonItem(FA icon, UIColor fontColor, EventHandler handler)
            : base()
        {
            _iconButton = new UIButton (new CGRect (0, 0, 32, 32)) {
                Font = icon.Font (25)
            };
            _iconButton.SetTitleColor (fontColor, UIControlState.Normal);
            _iconButton.TouchUpInside += handler;

            this.Icon = icon.String();

            CustomView = _iconButton;
        }
Example #30
0
        private FA EvenB()
        {
            var start = new State(true);
            var count = new State(false);
            var a     = Integers.From('a');
            var b     = Integers.From('b');

            start.Add(a, start);
            start.Add(b, count);
            count.Add(a, count);
            count.Add(b, start);

            return(FA.From(start));
        }
Example #31
0
        public void Automata3()
        {
            // [0]|[1-9][0-9]*
            var nfa = FA.Or(
                FA.From('0'),
                FA.And(FA.From('1', '9'), FA.From('0', '9').Star()));


            var dfa = nfa.ToDfa();

            dfa = dfa.Minimize();

            Assert.AreEqual(3, dfa.States.Count);
        }
Example #32
0
            public static FA Or(FA fa, FA other)
            {
                var first  = fa.ToNfa(true);
                var second = other.ToNfa(true);
                var newEnd = new State();

                first.Start.Add(second.Start);

                first.Final.Add(newEnd);
                second.Final.Add(newEnd);


                return(FA.From(first.Start, newEnd));
            }
Example #33
0
            public static FA From(string sequence)
            {
                var start   = new State();
                var current = start;
                var next    = (State)null;

                foreach (var ch in sequence)
                {
                    next = new State();
                    current.Add(Codepoints.From(ch), next);
                    current = next;
                }

                return(FA.From(start, next));
            }
Example #34
0
        public void Init(FA icon, nfloat width)
        {
            var text = icon.ToString();
            var image = icon.String();
            _label.Text = text;
            _image.Text = image;

            _image.Font = FA.Empty.Font (width);
        }