DEF/syntax

Uit Werkplaats
< DEF
Versie door Boudewijn Geijtenbeek (overleg | bijdragen) op 10 feb 2008 om 21:45
(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Ga naar: navigatie, zoeken
Similar terms and concepts

grammar

see language

In the first years of Computer Science, "syntax" often meant what could be described by a context-free grammar; the rest was called "semantics". Later, attribute grammars and affix grammars were invented, which allow an elegant definition of "non context-free syntax", which was then called "context conditions".

Definition

DEF/syntax

A set of rules that deciede which texts belong to the language and define for each such text one or more "syntax trees".

Explanation

{{{explanation}}}

Relations with other concepts

In →formal languages, semantics is defined along the syntax tree.

Machine translation is purely syntactic.

Pragmatics

The syntax of a good formal language is defined in such a way that semantically equivalent expressions can be derived from each other by simple textual transformations.

Examples

The expression

a+b+c

can have two different syntax trees, coresponding to (a+b)*c and a+(b+c), respectively. Many programming languages resolve this syntactically by defining that a+b+c always means one and not the other. Lambert Meertens pointed out that this is not necessary: multiple syntax trees are no problem as long as they give rise to the same semantics. In our example, this is the case thanks to the associativity of addition.

Open questions

Is there a distinct border between syntax and semantics? Or is semantics "syntax expressed verbally"?

In his beautiful book "What every programmer should know about syntax" (?) Bob Uzgalis showed that all syntax of a programming language can be defined by means of two level grammars - including all operational semantics!


This is a definition from Taxonomy of Computer Science (Hanno Wupper et al. 2008).