Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Internals of an APL Interpreter

106 views
Skip to first unread message

Charles Richmond

unread,
Nov 21, 2009, 5:29:39 AM11/21/09
to
Where could I get information on how APL works *inside*??? I know
it's a massive undertaking, but I think it would be fun to *try*
creating an APL system myself.

Are most interpreters table driven??? How is the APL function text
stored???

--
+----------------------------------------+
| Charles and Francis Richmond |
| |
| plano dot net at aquaporin4 dot com |
+----------------------------------------+

Bob Smith

unread,
Nov 21, 2009, 1:33:28 PM11/21/09
to
On 11/21/2009 5:29 AM, Charles Richmond wrote:
> Where could I get information on how APL works *inside*??? I know
> it's a massive undertaking, but I think it would be fun to *try*
> creating an APL system myself.
>
> Are most interpreters table driven??? How is the APL function text
> stored???

For a work-in-progress free open source modern APL interpreter, see
http://www.nars2000.org. Don't spend much time on the syntax analyzer
as it is in the process of being completely rewritten.

--
_________________________________________
Bob Smith -- bsm...@sudleydeplacespam.com

To reply to me directly, delete "despam".

Melvin Cowznofski

unread,
Dec 9, 2009, 3:11:58 PM12/9/09
to
Although it's simplistic, you might want to have a look at Ken
Iverson's parser in APL Press pamphlet called APL in Exposition.

You can type it in, play around with it, see how it works, and try to
extend it. There is no lexical analysis (it only works with ordinary
primitive functions one character each, variables one character long,
and parentheses. No square brackets, indexing or operators, etc.)

It is available on line at:

http://www.softwarepreservation.org/projects/apl/paper/197201_APL%20In%20Exposition_320-3010.pdf

As an exercise, you might try writing a simple lexical analyzer in APL
(a one evening project) such that you can pass to the PARSE function a
nested vector of strings. Then extend the parser to handle multiple
character names, basic operators (+/, +.x, etc.). And maybe later, if
you feel up to it, traditional APL indexing A[B] and axis operators +/
[16]MAT.

marcelor

unread,
Dec 9, 2009, 3:41:26 PM12/9/09
to
Besides what was already suggested, you may also want have a look at a
compiler. See Tim Budd's An APL compiler, Springer-Verlag, 1987.


Bob Smith

unread,
Dec 9, 2009, 9:59:37 PM12/9/09
to
On 12/9/2009 3:11 PM, Melvin Cowznofski wrote:
> Although it's simplistic, you might want to have a look at Ken
> Iverson's parser in APL Press pamphlet called APL in Exposition.

Thanks for the reference.

The syntax analyzer I'm using for testing comes from Bunda/Gerth's APL84
paper "APL Two By Two -- Syntax Analysis By Pairwise Reduction". This
analyzer can be changed easily to model a language with different
characteristics such as binding strengths. For example, it's easy to
define a syntax analyzer with these binding strengths:

A B C[I] ←→ (A) (B) (C[I])
+op2 A B C ←→ (+op2 A) B C

where op2 is a dyadic operator.

It is this code on which I plan to base my next APL syntax analyzer,
largely because it's easy to understand and modify.

The APL code may be found at one of the following places

http://www.nars2000.org/download/workspaces/2by2.atf (ATF file)
http://www.nars2000.org/download/workspaces/2by2.ws.nars (NARS2000 ws)

Richard Nabavi

unread,
Dec 10, 2009, 5:07:22 AM12/10/09
to
On 10 Dec, 02:59, Bob Smith <bsm...@sudleydeplacespam.com> wrote:
>
> The syntax analyzer I'm using for testing comes from Bunda/Gerth's APL84
> paper "APL Two By Two -- Syntax Analysis By Pairwise Reduction".

We followed that method when we wrote APL.68000 Level II and its
successor APLX. I vaguely remember that there were some errors in the
tables, but it's a good approach.

Bob Smith

unread,
Dec 10, 2009, 7:43:32 AM12/10/09
to

Yes, and there were some errors in the functions, too, which I corrected
in the files I referenced. I'm glad to see you used it successfully.

Melvin Cowznofski

unread,
Dec 12, 2009, 7:30:49 AM12/12/09
to
PS: One very good thing about the Ken Iverson's article in APL in
Exposition is that he gives you a simple introduction to several
Compilers and Interpreters 101 topics such as Polish notation, parse
trees, three address code, and so on. The text starts on p.51 of the
APL in Exposition book. Iverson's few pages here are a far better
introduction to language processor basics than I have seen in any of
the introductory texts.

One can even experiment with a different order of execution and
operation precedence, just to see how it would look.

Björn Helgason, j-programming

unread,
Dec 12, 2009, 12:40:41 PM12/12/09
to
On Nov 21, 10:29 am, Charles Richmond <friz...@tx.rr.com> wrote:
> Where could I get information on how APL works *inside*??? I know
> it's a massive undertaking, but I think it would be fun to *try*
> creating an APL system myself.
>
> Are most interpreters table driven??? How is the APL function text
> stored???

There used to be sources available for some APL systems as well as
older versions of J.

I guess you would be better off with some of those rather than trying
to figure everything out for yourself from scratch.

The latest version of J is to be more or less completely open and
written in J

"JFEs become open source J code and can be developed cooperatively by
the community."

I guess it would be interesting for you to join that effort.

There is a lot of disscussions in the Beta Forums
http://www.jsoftware.com/forums.htm
http://old.nabble.com/J-f24193.html

0 new messages