start to code dynamic grammar

start to code dynamic grammar, fix some bugs at first.