ArticleslgStudy

science

Affix grammar

Affix grammar is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Affix grammar rather than just read about it. In short: An affix grammar is a two-level grammar formalism used to describe the syntax of languages, mainly computer languages, using an approach based on how natural language is typically described. The formalism was invented in 1962 by Lambert Meertens while developing a grammar for generating English sentences.

Key takeaways

  • Affix grammar belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Affix grammar to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Affix grammar from memory before moving on to harder problems.

Reference excerpt

An affix grammar is a two-level grammar formalism used to describe the syntax of languages, mainly computer languages, using an approach based on how natural language is typically described. The formalism was invented in 1962 by Lambert Meertens while developing a grammar for generating English sentences. Meertens also applied affix grammars to the description and composition of music, and obtained a special prize from the jury at the 1968 International Federation for Information Processing (IFIP) Congress in Edinburgh for his computer-generated string quartet, Quartet No. 1 in C major for 2 violins, viola and violoncello, based on the first non-context-free affix grammar. The string quartet was published in 1968, as Mathematical Centre Report MR 96. 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.

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

Sentence → Subject Predicate Subject → Noun Predicate → Verb Object Object → Noun

Noun → John Noun → Mary Noun → children Noun → parents

Verb → like Verb → likes Verb → help Verb → helps This context-free grammar describes simple sentences such as

John likes children Mary helps John children help parents parents like John 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

John like children children helps parents These sentences are wrong: in English, subject and verb have a grammatical number, which must agree. An affix grammar can express this directly:

Sentence → Subject + number Predicate + number Subject + number → Noun + number Predicate + number → Verb + number Object Object → Noun + number Noun + singular → John Noun + singular → Mary Noun + plural → children Noun + plural → parents

Verb + singular → likes Verb + plural → like Verb + singular → helps Verb + plural → help This grammar only describes correct English sentences, although it could be argued that

John likes John is still incorrect and should instead read

John likes himself 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.

Types 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. Extended Affix Grammars, developed in the 1980s, are a more restricted version of the same idea. They were mainly applied to describe the grammar of natural language, e.g. English. Another possibility is to allow the values of affixes to be computed by code written in some programming language. Two basic approaches have been used:

In attribute grammars, the affixes (called attributes) can take values from arbitrary domains (e.g. integer or real numbers, complex data structures) and arbitrary functions can be specified, written in a language of choice, to describe how affix values in rules are derived from each other. In CDL (the Compiler Description Language) and its successor CDL2, developed in the 1970s, fragments of source code (usually in assembly language) can be used in rules instead of normal right-hand sides, allowing primitives for input scanning and affix value computations to be expressed directly. Designed as a basis for practical compiler construction, this approach was used to write compilers, and other software, e.g. a text editor.

References

Worked examples

Example 1 — a first encounter with Affix grammar

Start with the simplest possible case. Write down what Affix grammar claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Affix grammar before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Affix grammar ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Affix grammar

In research
Affix grammar appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Affix grammar in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Affix grammar is common in secondary-school and first-year university syllabi. It links to neighbouring topics Compiler construction, Formal languages, Grammar frameworks, so understanding it makes those chapters shorter.
In everyday life
Look for Affix grammar outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Affix grammar” →

How to study Affix grammar in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Affix grammar means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Affix grammar out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Affix grammar in simple terms?

An affix grammar is a two-level grammar formalism used to describe the syntax of languages, mainly computer languages, using an approach based on how natural language is typically described. The formalism was invented in 1962 by Lambert Meertens while developing a grammar for generating English sen…

Why does Affix grammar matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Affix grammar?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Affix grammar.

Tags

  • Compiler construction
  • Formal languages
  • Grammar frameworks
  • Syntax

Keep exploring