Beispiel #1
0
 public void TestCase()
 {
     FSA fsa = new FSA ("0", "1");
     fsa.AddTransition ("0", "a", "1");
     IList<string> state = fsa.GetTransitions ("0", "a");
     Assert.IsTrue (state.Contains("1"));
     Assert.IsTrue(fsa.Recognize (new string[] {"a"}));
 }
        public void TestSeparatorInLookupTerm()
        {
            FSA fsa = FSA.Read(GetType().getResourceAsStream("test-separator-in-lookup.fsa"));

            DictionaryMetadata metadata = new DictionaryMetadataBuilder()
                                          .Separator('+')
                                          .Encoding("iso8859-1")
                                          .Encoder(EncoderType.Infix)
                                          .Build();

            DictionaryLookup s = new DictionaryLookup(new Dictionary(fsa, metadata));

            assertEquals(0, s.Lookup("l+A").Count);
        }
        /// <summary>
        /// Creates a new object of this class using the given FSA for word lookups
        /// and encoding for converting characters to bytes.
        /// </summary>
        /// <param name="dictionary">The dictionary to use for lookups.</param>
        /// <exception cref="ArgumentException">If FSA's root node cannot be acquired (dictionary is empty).</exception>
        public DictionaryLookup(Dictionary dictionary)
        {
            this.formsList = new ArrayViewList <WordData>(forms, 0, forms.Length);

            this.dictionary         = dictionary;
            this.dictionaryMetadata = dictionary.Metadata;
            this.sequenceEncoder    = dictionary.Metadata.SequenceEncoderType.Get();
            this.rootNode           = dictionary.FSA.GetRootNode();
            this.fsa                 = dictionary.FSA;
            this.matcher             = new FSATraversal(fsa);
            this.finalStatesIterator = new ByteSequenceEnumerator(fsa, fsa.GetRootNode());

            if (dictionaryMetadata == null)
            {
                throw new ArgumentNullException(nameof(dictionaryMetadata),
                                                "Dictionary metadata must not be null.");
            }

            decoder       = dictionary.Metadata.Decoder;
            encoder       = dictionary.Metadata.Encoder;
            separatorChar = dictionary.Metadata.SeparatorAsChar;
        }
Beispiel #4
0
 public void AddExistedTransitionThrowsException()
 {
     FSA fsa = new FSA ("0", "1");
     fsa.AddTransition ("0", "a", "1");
     fsa.AddTransition ("0", "a", "1");
 }
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);

            int i;
            SettingsFile = new Xml("gecko.xml");
            SettingsFile.RootName = "gecko";

            MainControl.TabPages.Remove(GCTPage);
            MainControl.TabPages.Remove(BreakpointPage);
            MainControl.TabPages.Remove(shotPage);

            gamename = "";
            gecko = new TCPGecko(Properties.Settings.Default.hostname, 7331);
            gecko.chunkUpdate += transfer;
            hostTextBox.DataBindings.Add("Text", gecko, "Host", false, DataSourceUpdateMode.OnPropertyChanged);

            exceptionHandling = new ExceptionHandler(this);

            if (!Directory.Exists("DumpHistory"))
                Directory.CreateDirectory("DumpHistory");

            search = new MemSearch(gecko, SearchResults,
                PrvPage, NxtPage, ResList, UpDownSearchResultPage, exceptionHandling);

            viewer = new MemoryViewer(gecko, ValidMemory.ValidAreas[0].low, memViewGrid,
                memViewPAddress, memViewPValue, MemViewFPValue, exceptionHandling);

            #if MONO
            disassembler = new Disassembly(gecko, "./vdappc", DisAssBox, DisScroll,
                DisRegion, AsAddress, AsText, exceptionHandling);
            #else
            disassembler = new Disassembly(gecko, "vdappc.exe", DisAssBox, DisScroll,
                DisRegion, AsAddress, AsText, exceptionHandling);
            #endif

            bpHandler = new Breakpoints(gecko, BPList, this, disassembler, BPDiss, BPClassic, BPCondList, exceptionHandling);
            //bpHandler = new Breakpoints(gecko, BPList, this, disassembler, richTextBox1, BPClassic, BPCondList, exceptionHandling);
            foreach (String reg in BPList.longRegNames)
                BPConditionRegSelect.Items.Add(reg.Trim());
            BPConditionRegSelect.Items.Add("VoA");

            BPConditionRegSelect.SelectedIndex = 0;
            BPConditionCompare.SelectedIndex = 0;

            bpHandler.BPSkip += BPSkipped;

            watcher = new WatchList(gecko, WatchList, WatchIntervalSet, exceptionHandling);
            addWatchDialog = null;
            watchValueInput = null;

            fsa = new FSA(gecko, FSATreeView, extractFsaToolStripMenuItem, FSACodeData, exceptionHandling);

            GCTCodeContents = new CodeController(GCTCodeList, GCTCodeValues);
            GCTCodeContents.codesModified += GCTModified;

            bpHandler.BPStop += BPStopped;

            for (i = 0; i < ValidMemory.ValidAreas.Length; i++)
            {
                memRange.Items.Add(
                    GlobalFunctions.toHex(ValidMemory.ValidAreas[i].id, 2));
                MemViewARange.Items.Add(
                    GlobalFunctions.toHex(ValidMemory.ValidAreas[i].id, 2));
                ToolsDumpRegions.Items.Add(
                    GlobalFunctions.toHex(ValidMemory.ValidAreas[i].id, 2));
            }

            codeWizard = new GCTWizard(GCTCodeContents);

            memRange.SelectedIndex = 0;
            MemViewARange.SelectedIndex = 0;
            MemViewShowMode.SelectedIndex = 0;
            MemViewSearchType.SelectedIndex = 0;
            ToolsDumpRegions.SelectedIndex = 0;

            comboBoxSearchDataType.SelectedIndex = 2;

            //UpperEnable.SelectedIndex = 0;

            //BPType.SelectedIndex = 0;
            comboBoxDisplayType.SelectedIndex = 0;

            WasAlreadyDisabled = new List<Control>();
            searchComparisons = new List<SearchComparisonInfo>();
            searchComparisons.Add(new SearchComparisonInfo());
            comboBoxComparisonType.SelectedIndex = 0;
            comboBoxComparisonRHS.SelectedIndex = 0;
            buttonCancelSearch.Enabled = false;
            SteppingOut = false;
            buttonUndoSearch.Enabled = search.CanUndo();

            TabLock = null;
            BPStepLogWriter = null;

            comboBoxPokeOperation.SelectedIndex = 0;

            SetComboboxValue("Screenshots", "Format", 0, ImgFormat);
            SetComboboxValue("Screenshots", "Sizing", 0, ShotSizingType);

            int value = SettingsFile.GetValue("Screenshots", "JPEGQuality", 85);
            if (value < 0 || value > 100)
                value = 85;
            JPGQual.Value = value;

            multiPokeAddr = new List<UInt32>();

            FormStop(false);
            CTCPGecko.Enabled = true;

            codesModified = false;

            AbtText.Text = "tcpGecko dotNET Beta 0.1 by Chadderz\n"
                          + "based on gecko dotNET Beta 0.63 by Link and dcx2\n\n"
                          + "Special thanks to:\n\n"
                          + "kenobi: for original WiiRd GUI!\n"
                          + "Nuke: for the USB Gecko!\n"
                          + "brkirch: for continuing Gecko OS!\n"
                          + "Y.S.: for the original code handler!\n"
                          + "Team Twiizers for bringing homebrew to the Wii\n"
                          + "DevKitPro team: No homebrew without them!\n"
                          + "Frank Wille: vdappc developer!\n"
                          + "various beta testers!\n"
                          + "and you!";

            notes = new NoteSheets();

            // Restore previous settings
            checkBoxAlwaysOnTop.Checked = GeckoApp.Properties.Settings.Default.AlwaysOnTop;
            numericUpDownFPS.Value = GeckoApp.Properties.Settings.Default.FPS;
            BPAddress.Text = GeckoApp.Properties.Settings.Default.BPAddr;
            memViewAValue.Text = GeckoApp.Properties.Settings.Default.MemViewAddr;
            BPType.SelectedIndex = GeckoApp.Properties.Settings.Default.BPType;
            checkBoxBPNext.Checked = GeckoApp.Properties.Settings.Default.BPNext;
            checkBoxPauseCodes.Checked = GeckoApp.Properties.Settings.Default.PauseCodes;
            Size = GeckoApp.Properties.Settings.Default.LastSize;
            int oldSplitter = GeckoApp.Properties.Settings.Default.LastSplitterSize;
            // The splitter gets moved when the breakpoint page is entered
            // so artificially force it to move
            MainControl.SelectedTab = BreakpointPage;
            MainControl.SelectedTab = searchPage;
            splitContainerRegASM.SplitterDistance = oldSplitter;
            toolStripTextBoxMemViewFontSize.Text = GeckoApp.Properties.Settings.Default.MemViewFontSize.ToString();
            toolStripTextBoxMemViewFontSize_KeyDown(null, new KeyEventArgs(Keys.Enter));
            viewFloatsInHexToolStripMenuItem.Checked = GeckoApp.Properties.Settings.Default.ViewFloatsInHex;
            //addressTextBox1.CopyStringToHistory(GeckoApp.Properties.Settings.Default.addressHistory);
            //addressTextBox1.AutoHistory = true;
        }
Beispiel #6
0
 /// <summary>
 /// It is strongly recommended to use static methods in this class for
 /// reading dictionaries.
 /// </summary>
 /// <param name="fsa">An instantiated <see cref="Morfologik.Fsa.FSA"/> instance.</param>
 /// <param name="metadata">
 /// A map of attributes describing the compression format and
 /// other settings not contained in the FSA automaton. For an
 /// explanation of available attributes and their possible values,
 /// see <see cref="DictionaryMetadata"/>.
 /// </param>
 public Dictionary(FSA fsa, DictionaryMetadata metadata)
 {
     this.FSA      = fsa;
     this.Metadata = metadata;
 }
Beispiel #7
0
 /// <summary>
 /// Attempts to load a dictionary from opened streams of FSA dictionary data
 /// and associated metadata. Input streams are not disposed automatically.
 /// </summary>
 /// <param name="fsaStream">The stream with FSA data.</param>
 /// <param name="metadataStream">The stream with metadata.</param>
 /// <returns>Returns an instantiated <see cref="Dictionary"/>.</returns>
 /// <exception cref="IOException">IOException if an I/O error occurs.</exception>
 public static Dictionary Read(Stream fsaStream, Stream metadataStream)
 {
     return(new Dictionary(FSA.Read(fsaStream), DictionaryMetadata.Read(metadataStream)));
 }