Giter VIP home page Giter VIP logo

dfa2cfg's Introduction

dfa2cfg

dfa2cfg's People

Contributors

chadlr avatar chesterlbtan avatar kvrigor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dfa2cfg's Issues

DFA.IsValid() method

To determine if an instance of a DFA object is valid, these properties need to be checked:

  • States: not null and no duplicates
  • InputSymbols: not null and no duplicates
  • StartState: not null and must belong to States
  • AccepStates: must belong to States; can be null
  • Transitions: Each element in States should map exactly once to every element in InputSymbols

Print DFA transition table in a nice tabular format

Provide code to the method below found on DFA.vb:

Protected Function PrintTransitionTable() As String
            'TODO: Display transition functions in tabular format 
            Return ""
End Function

Will be useful in pretty-printing the DFA 5-tuple definition!

new DFA object

Unable to AddState on a newly initialized DFA.

'_states is NULL at _states.Contains

Public Overridable Sub AddStates(ByVal s As String)
            If _states.Contains(s) Then
                Throw New ArgumentException($"The set of states already contains '{s}'.")
            Else
                _states.Add(s)
            End If
End Sub

'My sample code in C#

myDFA = new Codecs.Languages.Regular.DFA();
            myDFA.InputSymbols = new string[2] { "1", "2" };
            myDFA.AddStates(State.StateCollection.Keys.ToArray());
            foreach (KeyValuePair<string,State> item in State.StateCollection)
            {
                StatesViewer.Rows.Add(item.Key, item.Value.m_TargetOne.Name, item.Value.m_TargetZero.Name);
                Codecs.Languages.Regular.TransFunc trans1 = new Codecs.Languages.Regular.TransFunc();
                trans1.PrevState = item.Key;
                trans1.Input = "1";
                trans1.NextState = item.Value.m_TargetOne.Name;
                myDFA.AddTransitions(trans1);
                Codecs.Languages.Regular.TransFunc trans0 = new Codecs.Languages.Regular.TransFunc();
                trans0.PrevState = item.Key;
                trans0.Input = "0";
                trans0.NextState = item.Value.m_TargetZero.Name;
                myDFA.AddTransitions(trans0);
                if (item.Value.IsAccept)
                    myDFA.AddFinalStates(item.Key);
            }
            Codecs.Languages.ContextFree.CFG sa = Codecs.Utils.DFAExtensions.ToCFG(myDFA, "CFG1");
            richTextBox1.Text = myDFA.ToString();
            richTextBox2.Text = sa.ToString();

CFG.IsValid() method

To determine if an instance of a CFG object is valid, these properties need to be checked:

  • Variables: not null and no duplicates
  • Terminals: not null and no duplicates
  • StartVariable: not null and must belong to Variables
  • GrammarRules: not null; substitutions must contain elements found in Variables or Terminals; empty string substitution (ε) is allowed

Have I missed anything?

Test DFA class usage in Automata GUI

Check ConsolApp.vb for sample usage

To better isolate different features of our software, how about adding a reference to Codecs.dll instead of including its project source code to your solution? With this you'll need to build the binaries first from Codecs.vbproj.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.