Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahdavipanah/pycfg
Context Free Grammar(CFG) parser library and application written in Python.
https://github.com/mahdavipanah/pycfg
algorithm automata cfg python tkinter
Last synced: 25 days ago
JSON representation
Context Free Grammar(CFG) parser library and application written in Python.
- Host: GitHub
- URL: https://github.com/mahdavipanah/pycfg
- Owner: mahdavipanah
- License: mit
- Created: 2017-01-07T08:52:05.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T15:44:50.000Z (about 1 year ago)
- Last Synced: 2024-04-09T16:42:43.493Z (9 months ago)
- Topics: algorithm, automata, cfg, python, tkinter
- Language: Python
- Homepage:
- Size: 97.7 KB
- Stars: 18
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pyCFG is an application and library for working with context free grammars (CFG) in [Python](https://www.python.org/).
It uses [tkinter](https://wiki.python.org/moin/TkInter) for it's graphical interface.
## Installing application
### Prerequisites
- [Python3.5+](https://www.python.org/)
- [tkinter](https://wiki.python.org/moin/TkInter)### Running
```bash
$ python pycfg.py
```### Windows
You can download pyCFG's binary for windows from [Here](https://github.com/mahdavipanah/pyCFG/releases).
## Using library
pyCFG library is in `cfg.py` module and can be imported and be used easily. For example:
```Python
from cfg import CFGg = 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:
~~~bash
pytest test.py
~~~## Author
Hamidreza Mahdavipanah
### Contributors
- Lucas Seiki Oshiro
## License
[MIT](./LICENSE)