GithubHelp home page GithubHelp logo

joeylemon / nfa-to-dfa Goto Github PK

View Code? Open in Web Editor NEW
72.0 1.0 12.0 1.6 MB

a visual NFA to DFA converter

Home Page: https://joeylemon.github.io/nfa-to-dfa/

JavaScript 84.62% HTML 12.84% CSS 2.17% Shell 0.37%
html5-canvas flexbox javascript github-actions mochajs shouldjs eslint

nfa-to-dfa's Introduction

Visual NFA to DFA Converter

Lint and Test

https://joeylemon.github.io/nfa-to-dfa/

Overview

Screenshot of the main application interface

This tool is used to convert non-deterministic finite automata (NFA) to deterministic finite automata (DFA) through an interactive and visual interface. More specifically, you can:

  • Create an NFA interactively or from a saved JSON file
  • Export an NFA to a JSON file
  • View the description of both the NFA and the DFA, including a full delta transition table
  • Convert the NFA to an equivalent DFA in three possible ways:
    • Step-by-step: the DFA is constructed in controlled increments
    • All at once: completely convert the NFA to the DFA in one leap
    • Animated: watch the conversion process take place automatically

Technology

image

Originally created by Alex Klibisz and Connor Minton, COSC 312, Spring 2015, University of Tennessee, Knoxville.

Rewritten and enhanced by Joey Lemon and Camille Williford, COSC 493, Fall 2021, University of Tennessee, Knoxville.

Contributing

Prerequisites

You must have Node.js v12.19.0+ and npm installed to run the application locally. Node versions below v12.19.0 are unable to run the unit tests.

Running Application

To set up the application locally, first clone this repository:

> git clone https://github.com/joeylemon/nfa-to-dfa.git

Then, install the dependencies:

> cd nfa-to-dfa
> npm install

Then, simply run the start script to create a local webserver:

> npm start

Running this script should give an output similar to below:

> [email protected] start ~/Desktop/nfa-to-dfa
> browser-sync start -s -f . --no-notify --host localhost --port 8000

[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:8000
    External: http://192.168.1.127:8000
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------
[Browsersync] Serving files from: ./
[Browsersync] Watching files...

You can now navigate to http://localhost:8000 in the browser to view the application. The website will automatically reload upon changes to the code.

Linting

Prior to adding changes to the repository, you should run the linter on the code to ensure there are no syntax errors and to maintain a uniform coding style:

> npm run lint

To automatically lint files before committing them, you should add a pre-commit hook. Copy the pre-commit.sample file to .git/hooks/pre-commit:

> cp pre-commit.sample .git/hooks/pre-commit

Now, git will automatically lint all changed files before committing them to the repository.

Testing

You should also test your changes before committing them to the repository:

> npm test

This will run all unit tests in the src/js/test directory and report any errors.

nfa-to-dfa's People

Contributors

awillif avatar joeylemon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nfa-to-dfa's Issues

About the Import file

Also one more thing. I can see at the index.js file that you have a querySelector about the import button. You are saving what the file has in a variable named “contents”. I can understand that the file has a specific type and format. Where do you define both of them?
I am trying to understand how we are going from the information of file (reading and analysing the information of the file) to the illustration of the NFA.
Thank you very much in advance!

do input from the table below

let user do input from table. i think it wil be really useful and fast to make the nfa by typing the state, transition, start, accept state, symbol from the table. First input the state name, then transition name, then select the start state from the list of state(using select or radio), then input the accept state from list of state. after that input the state transition direction in the table.

sorry if you confused with what i wrote here, i can't put words together well. you can ask for more detail. thank you

Object "transitions"

Hello, i wnat ask this:
I can only see that is the fa.js file in the constructor you have written in the comments that transitions is an object, but where do you define the properties of this object and where do you define what the form of the transition look like (for example [starting stete][symbol]=>[final states])?

Τhank you very much in advance.

Recursive / Multiple epsilon transitions can result in incorrect DFAs

While tinkering with the program, I noticed that an NFA representing the regex string a*b*c* is not transcribed correctly.
image
Specifically, the program does not recursively check what states can be reached by epsilon transitions; in this case, 1,2,3 should be reachable, but the program believes that 1,2 is correct:
image
This not only results in redundant states, but also means the resulting DFA can be incorrect. In this case, the DFA rejects the string ccccc, even though it is valid according to the original regex rule.

It seems the error stems from the lack of recursion in the epsilon closure function.

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.