Implement grammer tree