Updated grammar.h and grammar.cpp

90% sure that all the logic for queries is done/works