define(`noun',`cats',`dogs',`people') define(`verb',`love',`hate',`ignore') noun verb nounThis script, when given to m4r, would yield a potentially infinite number of randomized (but syntactically valid) sentences such as cats hate dogs, people ignore cats, and so on. All of the generated sentences will have the general form noun verb noun as called for by the m4r script shown above.
define(`digit',`0',`1',`2',`3',`4',`5',`6',`7',`8',`9') define(`digits',`digit',`digit`'digits') define(`literal',`digits') define(`atom',`literal',`( expression )') define(`primary',`atom',`primary ^ atom') define(`factor',`primary',`factor * atom',`factor / atom') define(`term',`factor',`term + factor',`term - factor') define(`expression',`term') srandom expression(The direct correspondence between the m4r input shown above and the BNF syntax rules for the equivalent subset of the bc(1) input language will undoubtedly be noted by those accustomed to dealing with BNF specifications of context-free grammars.)