Add better grammar definition

This is a better base grammar for the program. However, I have not fully tested all the branches of the text, because the program crashes for weird reasons. Will have a closer look at fixing some bugs.