Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 1.28 KB

README.md

File metadata and controls

61 lines (40 loc) · 1.28 KB

pyCFG is an application and library for working with context free grammars (CFG) in Python. It uses tkinter for it's graphical interface.

pyCFG app screenshot

Installing application

Prerequisites

Running

$ python pycfg.py

Windows

You can download pyCFG's binary for windows from Here.

Using library

pyCFG library is in cfg.py module and can be imported and be used easily. For example:

from cfg import CFG

g = CFG(terminals={'a', 'b', 'c', 'λ'},
        rules={'S': ['aSa', 'bSb', 'cSc', 'λ']}
        )

string = input("Enter a string: ")

if g.cyk(string):
    print("Grammar can generate the string!")
else:
    print("Grammar cannot generate the string!")

Above program gets a string from input and tells if the defined grammer can generate the string or not.

Tests

If you want to test, make sure that pytest is installed, then run:

pytest test.py

Author

Hamidreza Mahdavipanah

Contributors

  • Lucas Seiki Oshiro

License

MIT