Transform concrete grammar into abstract algebra