1.2. The Grammar Checking Process

The first version of An Gramadóir was written as a (pretty simple-minded) sed script consisting entirely of substitutions:

s/de [bcdfgmpt][^h][^ ]*/<E msg="lenition">&<E>/g;
s/de s[lnraeiouáéíóú][^ ]*/<E msg="lenition">&<E>/g;
s/mo [aeiouáéíóú][^h][^ ]*/<E msg="apostrophe">&<E>/g;
s/mo [bcdfgmpt][^h][^ ]*/<E msg="lenition">&<E>/g;
s/mo s[lnraeiouáéíóú][^ ]*/<E msg="lenition">&<E>/g;
s/sa [bcfgmp][^h][^ ]*/<E msg="lenition">&<E>/g;
	

The latest versions are written in Perl and are infinitely more intelligent, though I've maintained this essentially "stateless" design. [1] The input text is passed through a series of filters, each of which adds some XML markup. I'll illustrate this with a trivial English language example.

Notes

[1]

"Stateless" isn't exactly the right word; the program maintains plenty of state, it is just carried around in the text stream itself vs. in so-called "variables", risky abstractions which I'm told are used widely in certain programming languages.