[Aldor-l] Should this "parser" work?
Christian Aistleitner
tmgisi at gmx.at
Fri Oct 20 05:02:08 EDT 2006
Hello Martin,
as you addressed the mail directly to me, I feel obliged to comment,
although I cannot say anything new.
On Wed, 11 Oct 2006 11:43:01 +0200, Martin Rubey
<martin.rubey at univie.ac.at> wrote:
> Consider the following snippet from Aldor-Combinat-experiments
>
> -------------------------------------------------------------------------------
>
> parse(s: String): ExpressionTree == {
> ...
> }
>
> -- evaluate basically replaces expressions "Self1", "Self2", etc.
> appearing in
> -- t with the corresponding elements of selfList
> evaluate(
> t: ExpressionTree,
> selfList: List CombinatorialClass
> ): CombinatorialClass == {
> ...
> }
>
> grammar(p: List String): List CombinatorialClass == {
> macro CC == CombinatorialClass;
> import from MachineInteger, List CC;
> A: CC == Atom;
> res: List CC := [A for x in p];
>
> E(i: MachineInteger): CC == evaluate(parse(p.i), res) add;
>
> for i in 1..#p repeat res.i := E(i);
> res;
> }
>
> -------------------------------------------------------------------------------
>
> Consider for example the effect of
>
> grammar(["Union(Atom, Cross(Self1, Self1))"])
>
> * res is initialized to [b] with "b" being an instance of the
> CombinatorialClass Atom.
I am not to sure about whether or not “"b" being an instance of [...]
Atom” is correct. As your situation is quite tricky, and you seem to look
at the whole thing from a different angle than I am, can you explain to
me, what happens internally, so that your code is working?
From my point of view, your code looks like this in memory (I use the
format
Adress: Data
. All references to other entities are explicitely written down). It
translates
Definition of CombinatorialClass:
00001000: [...]
Definition of List( CombinatorialClass ):
00002000: [...] 00001000 [...]
Definition of Atom:
00003000: [...]
Definition of A:
00004000: [...] 00003000 [...]
Definition of res:
00005000: 00003000 00005010
00005010: 00003000 00000000
The grammar scope if the Universe (variable name, value, type) :
...
(A , 00004000, 00001000 )
(res, 00005000, 00002000 )
into something I am not too sure about. Can you plot your ideas of what is
going on in terms of such “virtual memory locations”. Especially the
output of E(1) and its relation to res.
--
Kind regards,
Christian
More information about the Aldor-l
mailing list