Giter Club home page Giter Club logo

re2nfa2dfa2mfa's Introduction

RE--NFA--DFA--MFA

  1. Use Thompson algorithm to convert the regular expression to NFA
  2. Use the subset construct to convert NFA to DFA
  3. Minimize DFA to MFA
  4. Use MFA to match strings

How to run

src\main\test.java is the main funnciton.

Attention

Use an equal width font, otherwise the output table will not be aligned

Details

1. RE2NFA

  • NFA nfa = new NFA(re);

Creat a NFA by Thompson algorithm


  • nfa.add_join_symbol();

Add join symbol between regular expression
The join symbol is '.'
for example:

    re = "(a|bc)*d";
    re_add_join_symbol = "(a|b.c)*.d" ;

  • nfa.postfix();
    Converts an infix expression to a postfix expression for example:
    re_add_join_symbol = "(a|b.c)*.d";
    re_postfix = "abc.|*d."

avatar


  • nfa.re2nfa();
    Using Thompson algorithm constructs NFA

  • nfa.print();
    Print out NFA (depth-first traversal)

avatar avatar

2. NFA2DFA

  • DFA dfa = new DFA(nfa.getPair(),nfa.getLetter());
    dfa.createDFA();
    Construct the DFA using the subset construct

  • dfa.printDFA();
    avatar

3. DFA2MFA

  • MFA mfa = new MFA(dfa.getDFA(),dfa.getEndState(),dfa.getLetter());
    mfa.minimize();
    Creat a MFA

  • mfa.merge();
    merge

  • mfa.printMFA();
    avatar

4. Match

avatar

re2nfa2dfa2mfa's People

Contributors

solawhite avatar

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.