Update grammar.py

To enable the support to optionally parse entire string passed to the grammar