Implemented packrat algorithm