Concrete and abstract syntax [0175]

Syntax comes in two forms: there is concrete syntax, and this is what people are talking about when they say things like:

I prefer the syntax of Rust to C++.
I (can’t stand, love) the way that Haskell and Python have indentation-sensitive syntax.

Concrete syntax is usually defined in terms of strings of symbols. In general, concrete syntax may use a variety of tools (including brackets, whitespace, etc.) to disambiguiate what would not be ambiguous in a structured representation, e.g. as a syntax tree. The structured representation of syntax as trees or a similar data structure (like a directed acyclic graph) is called abstract syntax. The process of converting concrete syntax to abstract syntax is called parsing.

Here is an example of concrete syntax, in the OCaml language:

if x > 100
  then x - 10
  else f (f (x + 11))

The OCaml parser then converts this into a tree, with vertices labelled by syntactic forms and subtrees given by arguments. Parenthesisation and operator precedence is now replaced by the parent-child relationship.