RE: Fwd: "Active XML"

Gavin Thomas Nicol (
Tue, 2 Nov 1999 16:23:57 -0500

> <p xml:xmlns="urn:lang:lisp"><s>defun</s><s>fact</s><p><s>n</s></p>
> <p><s>if<s><p><s>=</s><s>n</s><n>0</n></p>
> <n>1</n>
> <p><s>*</s><s>n</s>
> <p><s>fact</s><p><s>-</s><s>n</s><n>1</n></p></p>
> </p>
> </p>
> </p>
> I might call this language Lis<p>, for Lots of Irritating
> Silly <p>arentheses.

I did this recently: I had a need for an XML-based scripting
language, and an old scheme interpreter I wrote in Java. I
wrote a new Reader class (hey I wrote it befire Reader was in*), and voila! The encoding wasn't pure scheme though...
I would probably encode lisp using cdr-coding.

XMLScript is an expression language encoded using XML. It is
essentially the same as a scheme subset. The transformation
is roughly:

<add> (add
<const>1</const> 1
<var>a</var> a
</add> )

or in other words, the start and end tags are turned into a
procedure call *except* for the special cases of <const>
and <var> which are simply stripped and passed as atoms
and symbols to the procedure. These do not need to be marked
up explicitly.

Note: This is actually a little white lie... what really
happens in the implementation is simple string
substitution, so the PCDATA content of an argument
list is parsed as per the normal parsing rules of
<!-- Simple test -->
<write><sub>10 2 1</sub></write>

<!-- Test lambda and define -->
<lambda><args>a b</args>
<add> a b </add>
<define>a 1</define>
<define>b 2</define>
<define>c 3</define>
<add>1 2 3 4 <const>5</const> <test>20 20</test></add>

<!-- Test getprop and setprop -->
<setprop>foo <const>"bar"</const></setprop>

<!-- Test if -->
<gt>b a</gt>

<!-- Test cond -->
<args><gt>a b</gt> <write>"yes"</write></args>
<args><gt>b a</gt> <write>"no"</write></args>