Xython - XML-Formed Python

Alan Kennedy alanmk at hotmail.com
Tue Feb 5 16:48:22 EST 2002


Steve Horne <steve at lurking.demon.co.uk> wrote:
> XML is bound to be easier to parse for the compiler than the existing
> Python language, because it avoids the following issues...
> 
> 1.  Resolution of ambiguities using associativity, precedence and
>     preference for shift over reduce.

But creates a whole new problem in that a DTD/Schema/RelaxNG has to 
be created that validates the structure of the xython program ....

It's been too long since I did compiler theory (1989 in fact, undergrad
course), so I don't even know if it would be possible to express the
necessary constraints for xython in an XML DTD.....

> 2.  Classifying words as identifiers or keywords, particularly where
>     this depends on 'from __future__'.

This is a good point, but to my mind, not enough of a benefit to justify 
a whole new syntax. And "from __future__" seems to do the job quite well.

> 3.  Awkward lexical handling such as recognition of indentation.

Let's not start on the pros and cons of indentation :-) Personally,
I like it, I think its one of python great features.

> Error reporting should also be simpler. In fact, syntax errors should
> be impossible (assuming the editor is configured properly) - only
> semantic errors should get as far as the compiler.

See above about creating a DTD. If you don't have a DTD, then all you're
guaranteed by your editor is a well-formed xython file, but it might
still contain meaningless *structures*

> The XML would certainly not be easy for people to edit, but it's not
> meant to be - the presentation is an issue for the editor.

Hand-editing would be a PITA. One of the xython proponents seems to be
focussed more on the ability to autogenerate python/xython from XSLT,
but for the life of me, I can't think of a use case for this that would
not be better served with a dedicated code manipulation/generation tool.

> But yes, I can see problems. For instance, the error reports would
> relate to the XML AST - not to the visible representation of the
> source code.

And don't forget that speedwise, an XML parser would be extemely unlikely
to be faster than a dedicated parser, even just checking for well-formedness,
let alone validity.....

Alan, the push-down automaton....



More information about the Python-list mailing list