On Mar 10, 2025, at 7:26 PM, John Levine <johnl(a)taugh.com> wrote:
In my 1971 compiler course at Yale, Alan Perlis made us try to write a compiler
that translated a subset of APL into Basic. He suggested we write it in APL,
which was a terrible idea, so I wrote it in Trac, for which I happened to have
written my own interpreter.
I think my compiler was the only one that worked, and it was pretty clever,
turning the APL array expressions into structures with array boundaries and
example expressions, with no array temporaries. It only generated the loops to
evaluate the expressions when storing into another array.
Someone got a PhD in 1978 for a similar compiling technique but in 1971 I was a
17 year old twerp so what did I know?
R's,
John
Pretty impressive for a 17yo!
Isn’t APL syntax rather context sensitive[1]? Neither yacc nor
a RD parser would’ve helped! Unless the subset was limited to a
context free subset.
Tim Budd in his 1978 work made quite a few changes to APL to
ease compilation and used yacc. [I have the book somewhere....]
[1] I do not recall if Iverson's original APL had a context sensitive
grammar but modern APLs do.
Given an expression ‘x y z’, its parse depends on the types of
x, y & z. Example: y(x,z) if y is a dyadic verb, x & z are values,
x(y(z)) if x & y are monadic verbs, z a value etc.