parser: rewrote some grammer rules to be more simpler and cleaned up some code to be more readable