Xython - XML-Formed Python

Steve Horne steve at lurking.demon.co.uk
Tue Feb 5 12:39:44 EST 2002


On 5 Feb 2002 07:51:10 -0800, alanmk at hotmail.com (Alan Kennedy) wrote:

>Steve Horne <steve at lurking.demon.co.uk> wrote in message 
>> I haven't looked at their site, but XML (using tags for structures,
>> statements etc) may have considerable benefits over plain text as a
>> source code representation - the only problem being the need for good
>> XML editors...
>
>This has been raked over quite a few times in the past on xml-dev.
>Although it seems like a good idea at first, it rapidly degrades when
>you start looking at details.
>
>For example, how do you represent the following simple python function
>in XML, in a way that is either
>
>A: simpler to read (or write) than it already is?
>B: simpler to process than it already is, using the python compiler,
>or a parsing toolkit like SPARK?
>
>#------------
>import math
>
>def sphereVol(r):
>    return 4/3*math.pi*r*r*r
>#------------
>
>one-abstract-syntax-tree-to-rule-them-all-ly-yrs
>
>Alan.

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.
2.  Classifying words as identifiers or keywords, particularly where
    this depends on 'from __future__'.
3.  Awkward lexical handling such as recognition of indentation.

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.

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.

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.

-- 
Steve Horne
steve at lurking.demon.co.uk



More information about the Python-list mailing list