*** Welcome to piglix ***

Affix grammar


An affix grammar is a kind of formal grammar; it is used to describe the syntax of languages, mainly computer languages, using an approach based on how natural language is typically described.

The grammatical rules of an affix grammar are those of a context-free grammar, except that certain parts in the nonterminals (the affixes) are used as arguments. If the same affix occurs multiple times in a rule, its value must agree, i.e. it must be the same everywhere. In some types of affix grammar, more complex relationships between affix values are possible.

We can describe an extremely simple fragment of English in the following manner:

This context-free grammar describes simple sentences such as

With more nouns and verbs, and more rules to introduce other parts of speech, a large range of English sentences can be described; so this is a promising approach for describing the syntax of English.

However, the given grammar also describes sentences such as

These sentences are wrong: in English, subject and verb have a grammatical number, which must agree.

An affix grammar can express this directly:

This grammar only describes correct English sentences, although it could be argued that

is still incorrect and should instead read

This, too, can be incorporated using affixes, if the means of describing the relationships between different affix values are powerful enough. As remarked above, these means depend on the type of affix grammar chosen.

In the simplest type of affix grammar, affixes can only take values from a finite domain, and affix values can only be related through agreement, as in the example. Applied in this way, affixes increase compactness of grammars, but do not add expressive power.

Another approach is to allow affixes to take arbitrary strings as values and allow concatenations of affixes to be used in rules. The ranges of allowable values for affixes can be described with context-free grammar rules. This produces the formalism of two-level grammars, also known as Van Wijngaarden grammars or 2VW grammars. These have been successfully used to describe complicated languages, in particular, the syntax of the Algol 68 programming language. However, it turns out that, even though affix values can only be manipulated with string concatenation, this formalism is Turing complete; hence, even the most basic questions about the language described by an arbitrary 2VW grammar are undecidable in general.


...
Wikipedia

...