algorithm grammar