From J Wiki
Jump to: navigation, search


An Implementation of J

  • main
    • jinit2
    • immloop
      • prompt
      • jgets
      • immex
  • tokens
  • wordil
  • enqueue
  • parse
  • monad
  • dyad
  • adv
  • conj
  • trident
  • bident
  • is
  • punc
  • move
  • jpr
      • tpop

The system is organized as diagrammed above. The main function main calls jinit2 for initializations, then immloop ("immediate execution" loop), which repeats the following steps:

prompt and jgets prompt and accept an input sentence.

immex is the heart of the execution loop. The argument is a string of the input sentence. The processing is divided into three parts: tokens — word formation — applies the rhematic rules to partition the sentence into words. parse interprets the sentence according to the parsing rules. Parsing is controlled by a table of (pattern,action) pairs; the eleven possible actions are embodied as the function listed under parse in the diagram. jpr displays the result of the sentence. Finally, tpop frees the temporary storage used in an iteration.

The fundamental data structure is the APL array (an object of data type A), used to represent all the possible objects in J. Most functions in the implementation accepts arrays as argument and return them as result. Functions tend to be short and compact, and functions which implement J primitives are used freely. Extensive use is made of C preprocessor definitions and macros. Although the implementation language is C, the programming style is unmistakably APL.

This document is organized along the lines of the dictionary: Chapter 1 describes the interpretation of a sentence. Chapters 2, 3, and 4 describe nouns, verbs, and adverbs and conjunctions. Chapter 5 presents alternative representations. Chapter 6 describes display. Chapter 7, the final chapter, describes comparisons.

The remainder of the document contains various useful bits. In particular, the Appendix contains a system summary, a means of quickly locating a primitive in the program files.

Next • Previous • Index • Table of Contents