Giter VIP home page Giter VIP logo

regex2dfa's Introduction

Regular Expression to DFA

Introduction:

This project converts and arbitrary regular expression (Regex) to a DFA that recognizes the language of this regex using a Syntax Tree and conducting the following steps:

  1. Converting the Regex to post-order format
  2. Creating the Annotated Syntax Tree of the Regex
  3. Creating the DFA based on the tree.

Documentation

The code is documented using Google Style Docstring but for a detailed documentation on the algorithm and code, read the documentation.md

Requirements

  • Python Version 3+
  • General Knowledge of Regular Expressions and Finite State Automatas

Running:

Run the project by running Regex2DFA.py

Here is the results for Input1.txt located in the inputs directory:

a*+b*
.
|
|___+
|   |
|   |___*___b
|   |
|   |___*___a
|
|___#

->  1   a : 2   b : 3   Final State
    2   a : 2   b : 4   Final State
    3   a : 4   b : 3   Final State
    4   a : 4   b : 4

and Input4.txt:

(a+b)*.a.(a+b)
.
|
|___.
|   |
|   |___.
|   |   |
|   |   |___+
|   |   |   |
|   |   |   |___b
|   |   |   |
|   |   |   |___a
|   |   |
|   |   |___a
|   |
|   |___*___+
|           |
|           |___b
|           |
|           |___a
|
|___#

->  1   a : 2   b : 2
    2   a : 3   b : 4
    3   a : 3   b : 3   Final State
    4   a : 4   b : 4

For more detail on the format of input and output please refer to InOut_Formatting.md

License

The MIT License. Copyright (c) 2017 Amin Fadaee

About Author

Amin Fadaee

regex2dfa's People

Contributors

aminfadaee avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

regex2dfa's Issues

DFA built after reversed expression?

Hi Amin,

Thanks for the project you shared.

Is it possible that the DFA is built after the reversed expression and not the one that is given in the input?
I tried to follow the code and see why, but I couldn't.

Could you help?
Thank you,
Oana

I read the chapter on 'Compilers: Principles, Techniques and Tools by Aho, Ullman, Sethi and Lam'. I have an understanding of what the algorithm should do, but not so deep

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.