creating a tree grammar