Grammar generation algorithm applied