Parser: add a check so it doesn't crash on certain conditions

Fixes #284, but I don't really understand why :)

(I'm sure this isn't the ideal fix, but it works for now.)