Re: Is XML context-free?

From: Alfred Einstead (
Date: 03/16/04

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

"Dan" <> 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

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).