refactored formal grammar code into an object, fixed NaN bug by making rectangle.width and height nullary functions