An open source grammar analyzer that uses PLY under the hood. Its purpose is to serve as an educational aid for undergraduate students taking an introductory course on compilers.
- SLR(1) and LALR(1) grammar support.
- Augmented grammar.
- First and follow sets.
- Automaton state graph visualization.
- Parsing table.
- Parser simulator.
There is a demo hosted on a Heroku free instance: http://pygram.herokuapp.com.
Terminals
OPMULT OPDIV
OPADD OPSUB
FACTOR
Productions
expr: expr OPADD term
| expr OPSUB term
| term;
term: term OPMULT FACTOR
| term OPDIV FACTOR
| FACTOR;
The following are the main dependencies used by pygram, for the complete list refer to 'requirements.txt'.
- flask: http://flask.pocoo.org/.
- graphviz: http://www.graphviz.org/.
- ply: http://www.dabeaz.com/ply/.
- pydot: https://bitbucket.org/prologic/pydot/overview.
Note: pydot is included in the src folder 'pydot/'
$ virtualenv -p `which python3` pygram
$ source pygram/bin/activate
$ pip install -r requirements.txt
$ apt-get install graphviz
In order to install graphviz you need to use a custom buildpack. The easiest way to do it is to use the heroku-buildpack-multi together with the heroku-buildpack-python and the heroku-buildpack-graphviz buildpacks.
heroku login
heroku config:add BUILDPACK_URL:https://github.com/ddollar/heroku-buildpack-multi.git
heroku config:add PATH:/usr/local/bin:/usr/bin:/bin:/app/bin
- Add support for localization.
- Add support for LL(1) and LR(1) parsers.
The following is a list of other grammar analyzers. Please, feel free to add more references to the list below.
Pygram uses the MIT license. The dependencies used by Pygram are subject to their respective licenses.