Giter Club home page Giter Club logo

regex-parser's Introduction

Regex/NFA/DFA Converter

Developer(s)

  • Apolinar Ortega

About

The purpose of this program is to allow you to input in regular expressions, DFA's, and NFA's to then convert them into an executable finite-state machine, which would let you run tests against it.

Compiling

Make sure that when compiling and running the program that you are in the same directory as this README. Make sure to have the mono compiler installed and the latest version of Java:

make

Possible Commands

./program ${ARG1} ${ARG2}...${ARGN}
./program regex '(b)+a' aa bba b
  • ARG1: "regex", "NFA", or "DFA", depending on which machine you want to emulate
  • ARG2...ARGN: input strings to test the regular expression with
    • Note that if the "NFA" or "DFA" option was selected, then ARG2 is dedicated to the file containing the DFA definition with alphabet speecification
    • See files under /demos for examples of NFA and DFA definition syntax

Notes

  • Note that when running the regex parser, the alphabet is implicitly defined through the unique characters found in the regex pattern.
    • For example regex 'a+ba' has an alphabet of {a, b}
    • The program fails if you enter characters out of the alphabet for testing. For example, testing 'abc' on the above fails since 'c' is not in the defined alphabet
    • This has the same restriction with the NFA and DFA conversion

DFA File Format

The demos are located in the /demos sub-directory. The first line is a string of characters that will be the alphabet.

The second line lists the names of the states. The starting state is preceded by a > and the end states are preceeded by a *.

The next set of rows consists of transitions for each of those states. The line starts with the state name, then a |, and then a comma-separated list. Each item in that list contains a symbol in the alphabet, then a :, and finally the state in which it transitions to.

See input.txt as a simple example of this.

Possible future notes

  • Allow the usage of wildcard '.'
  • When running the regex program, allow test input with characters outside of the dictionary

regex-parser's People

Contributors

apolinaro avatar

Watchers

James Cloos avatar  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.