Uses Python nltk to generate abstract syntax trees for a given giraffe programme, as defined in the Elements of programming languages course at The University of Edinburgh.
- python
- nltk
git clone https://github.com/livecodealex/giraffe-viewer.git
$ python
python> from ast import *
python> draw()
(This will assume the filename of the grammar is grammar and the filename of the program is program.gir)
python> parse_file_with_grammar(<filename>, <grammar_filename>)
- The giraffe file must be free of quotes. Please remove them, strings will be treated as literals
- The giraffe file must not contain empty strings. If it does, please replace the "" with EMPTY_STRING or another name of your choice (you need not edit the grammar)
- The tokens in the giraffe file must be space separated (i.e.
func(a:int,b:int)
is illegal, it must befunc ( a : int , b : int )
)