Re: Is XML context-free?

From: Alfred Einstead (whopkins_at_csd.uwm.edu)
Date: 03/16/04


Date: 16 Mar 2004 10:41:21 -0800


"Dan" <addr@host.org> wrote:
> I've read in a number of places that XML is context-free[...]

Programming languages are not context-free since, among other
things, they have to incorporate constraints such as type-matching
conditions or other operator-operand consistency conditions ...
as well as other constraints, such as run-time conditions or
limitations.

Instead, an enveloping context-free syntax is usually stated for
a programming language inside of which the actual language can be
fit. The grammar, which is context-free, overspecifies the language,
and the constraints are then used to filter out all the stuff the
grammar allows for which the language forbids.

This separates out the context-free part of the language from
the context-sensitive part -- which is generally regarded as
good practice (a kind of modular "programming" discipline for
language design).