next up previous contents
Next: REC/C data flow Up: The rectbl.h header and Previous: The rectbl.h header and

REC header

The header file seems excessively long when only a handful of definitions are actually stated, but in keeping with the tradition of using single ASCII characters as symbols, conserving the full list helps browsers and inspectors work uniformly.

Moreover, insertions or deletions to the table are confined to the locations already alloted for them. Such systematics often reduce error and increase programming convenience. In fact, for some of the more common variants, such as floating point numbers, comments in the form of quoted strings, or frequently used operators, including both forms in the table with the unused line neutralized by making it into a comment can reduce confusion and save programming effort.

This header file is also the place to declare all the REC functions which it introduces -- at least the compiling and executing functions -- if not all their satellites. Those can probably be accounted for in the REC implementation file with less overall effort.

/* rectbl.h -- G. Cisneros, 4.91; rev. 2.10.91 */
/* Mandatory declarations */

# include "rec.h"

int r_lpar();           /* compilation of a left parenthesis            */
int r_rpar();           /* compilation of a right parenthesis           */
int r_colon();          /* compilation of a colon                       */
int r_semicol();        /* compilation of a semicolon                   */
int r_code();           /* compilation of a simple operator             */
int r_oper1();          /* compilation of an operator with an ASCII arg */
int r_pred();           /* compilation of a simple predicate            */
int r_pred1();          /* compilation of a predicate with an ASCII arg */
int r_noopc();          /* compilation of no-op                         */
int r_comment();        /* compilation of a (bracket enclosed) comment  */
int r_ubrack();         /* compilation of an unbalanced right bracket   */
int r_lbrace();         /* compilation of a (brace enclosed) program    */
int r_ubrace();         /* compilation of an unbalanced right brace     */

int r_call();           /* execution of predicate @x (call subr. x)     */
int r_quit();           /* execution of operator _ (exit to O.S.)       */
int r_xbrace();         /* execution of brace-enclosed program          */

/* Optional: Counter predicate */

 int r_ctrc();          /* compilation of a counter */
 int r_ctrx();          /* execution of a counter   */

/* Optional declarations, needed only in versions using quotes and
   numbers (see cnum.c and cquo.c); r_ld, r_ldch and r_xstr must
   be provided by user */

// int r_dquote(); /* compile doubly quoted string into symbol table */
// int r_squote(); /* compile singly quoted char into the program array */
// int r_cmin();   /* compile '-' as simple operator, call r_cnum if followed 
//                    by digit or period */
// int r_cnum();   /* compile a number (WORD, LONG or REAL) into sym. table */

// int r_ld();	        /* execution of compiled numbers */
// int r_ldch();        /* execution of apostrophe (single quote op.) */
// int r_xstr();        /* execution of quoted strings */

int r_cdblp(), r_ldblp();

/* Declarations of user-provided execution subroutines */

void roplb(), roplc(), ropue(), roplf(), roplg();
void roplh(), roplj(), roplm(), ropln(), roplo();
void roplp(), roplq(), ropls(), roplr(), ropls();
void roplu(), roplv(), roplx(), roply(), roplz();

void ropub(), ropuc(), ropuf(), ropug(), ropuh(), ropuk();
void ropul(), ropum(), ropun(), ropuo();
void ropup(), ropuq(), ropur(), ropus(), roput(), ropuu();
void ropux(), ropuy(), ropuz();

int  rprua(), rprla(), rprll(), rprui(), rprli(); 

void ropqm(), roppl(), ropmi(), ropti(), ropdi(), ropam();
int  rprns(), rprps();

int  rprze(), rpron(), rprtw(), rprth();

/* Table of compiling/executing function definitions,
   a triple [compile, execute, comment] for each printing ASCII character */

struct fptbl dtbl[] = {
    r_noopc,  FALSE,    " space (separator)",                     /* [blank] */
    r_ctrc,   r_ctrx,   " !n! - count to n   ",                         /* ! */
//  r_dquote, r_xstr,   "",                               /* " quoted string */
    r_noopc,  FALSE,    "",                               /* " quoted string */
    r_pred,   rprns,    " # - random predicate, probability 1/2  ",     /* # */
    r_cdblp,  r_ldblp,  " $xxx.x$ - floating point number ",            /* $ */
    r_pred,   rprps,    " % - random predicate, probability 1/10 ",     /* % */
    r_code,   ropam,    " & - exchange top two items on stack",         /* & */
//  r_squote, r_ldch,   " quoted character",                            /* ' */
    r_noopc,  FALSE,    "",                                /* '  quoted char */
    r_lpar,   FALSE,    " ( - start of expression",                     /* ( */
    r_rpar,   FALSE,    " ) - end of expression",                       /* ) */
    r_code,   ropti,    " * - multiply top of list, leave product ",    /* * */
    r_code,   roppl,    " + - add top of list, leave sum",              /* + */
    r_noopc,  FALSE,    " , ",                                /* , separator */
//  r_cmin,   FALSE,    " - ",                                          /* - */
    r_code,   ropmi,    " - - subtract top of list, leave difference",  /* - */
//  r_cnum,    r_ld,    " , ",                              /* . f.p. number */
    r_noopc,  FALSE,    " . ",                                          /* . */
    r_code,   ropdi,    " /  - divide top of list, leave quotient",     /* / */
//  r_cnum,     r_ld,    " 0 ",    /* 0 number */
//  r_cnum,     r_ld,    " 1 ",    /* 1 number */
//  r_cnum,     r_ld,    " 2 ",    /* 2 number */
//  r_cnum,     r_ld,    " 3 ",    /* 3 number */
//  r_cnum,     r_ld,    " 4 ",    /* 4 number */
//  r_cnum,     r_ld,    " 5 ",    /* 5 number */
//  r_cnum,     r_ld,    " 6 ",    /* 6 number */
//  r_cnum,     r_ld,    " 7 ",    /* 7 number */
//  r_cnum,     r_ld,    " 8 ",    /* 8 number */
//  r_cnum,     r_ld,    " 9 ",    /* 9 number */
    r_pred,    rprze,    " 0 - switch ",    /* 0 */
    r_pred,    rpron,    " 1 - switch ",    /* 1 */
    r_pred,    rprtw,    " 2 - switch ",    /* 2 */
    r_pred,    rprth,    " 3 - switch ",    /* 3 */
    r_noopc,   FALSE,    " 4 ",    /* 4 number */
    r_noopc,   FALSE,    " 5 ",    /* 5 number */
    r_noopc,   FALSE,    " 6 ",    /* 6 number */
    r_noopc,   FALSE,    " 7 ",    /* 7 number */
    r_noopc,   FALSE,    " 8 ",    /* 8 number */
    r_noopc,   FALSE,    " 9 ",    /* 9 number */
    r_colon,   FALSE,    " : - repeat from opening lparen ",  /* : iteration */
    r_semicol, FALSE,    " ; - T exit at closing rparen ",    /* ; true exit */
    r_noopc,   FALSE,    " < ",                                         /* < */
    r_noopc,   FALSE,    " = ",                                         /* = */
    r_noopc,   FALSE,    " > ",                                         /* > */
    r_code,    ropqm,    " ? - print register values",                  /* ? */
    r_pred1,   r_call,   " @x - call subroutine x",                     /* @ */
    r_pred,    rprua,    " A - Is angle a multiple of 90 degrees?",     /* A */
    r_code,    ropub,    " B - ",                                       /* B */
    r_code,    ropuc,    " C - hyperbolic cosine ",                     /* C */
    r_noopc,   FALSE,    " D ",                                         /* D */
    r_code,    ropue,    " E - complex exponential",                    /* E */
    r_code,    ropuf,    " F - fractional linear mapping (z+1)/(z-1) ", /* F */
    r_code,    ropug,    " G - move to first point of a drawn line",    /* G */
    r_code,    ropuh,    " H - ",                                       /* H */
    r_pred,    rprui,    " I - Is real part an integer?",               /* I */
    r_noopc,   FALSE,    " J - ",                                       /* J */
    r_code,    ropuk,    " K -        ",                                /* K */
    r_code,    ropul,    " L - complex logarithm ",                     /* L */
    r_code,    ropum,    " M - graphic multiplier: $10.0$ M, default",  /* M */
    r_code,    ropun,    " N - ",                                       /* N */
    r_code,    ropuo,    " O - ",                                       /* O */
    r_code,    ropup,    " P - push (duplicate) top of the stack",      /* P */
    r_oper1,   ropuq,    " Qk - draw a colored square (one argument)",  /* Q */
    r_oper1,   ropur,    " R - Rn to recover nth constant ",            /* R */
    r_oper1,   ropus,    " S - Sn to save nth constant ",               /* S */
    r_code,    roput,    " T - hyperbolic tangent",                     /* T */
    r_code,    ropuu,    " U - ",                                       /* U */
    r_noopc,   FALSE,    " V ",                                         /* V */
    r_noopc,   FALSE,    " W ",                                         /* W */
    r_code,    ropux,    " X - push 1 ",                                /* X */
    r_code,    ropuy,    " Y - push i ",                                /* Y */
    r_code,    ropuz,    " Z - push 0 ",                                /* Z */
    r_comment, FALSE,    " [begin comment]",                            /* [ */
    r_noopc,   FALSE,    "",                                            /* \ */
    r_ubrack,  FALSE,    " [end comment]   ",                           /* ] */
    r_noopc,   FALSE,    " ^ - ",                                       /* ^ */
    r_code,    r_quit,   " _ - abandon program",                        /* _ */
    r_noopc,   FALSE,    " ` - ",                                       /* ` */
    r_pred,    rprla,    " a - Is angle a multiple of 15 degrees?",     /* a */
    r_noopc,   FALSE,    " b ",                                         /* b */
    r_code,    roplc,    " c - compression threshold (nominal 0.15) ",  /* c */
    r_noopc,   FALSE,    " d - ",                                       /* d */
    r_noopc,   FALSE,    " e - ",                                       /* e */
    r_code,    roplf,    " f - multiply by real factor: $xx.x$ f ",     /* f */
    r_code,    roplg,    " g - continue line to additional points",     /* g */
    r_code,    roplh,    " h -    ",                                    /* h */
    r_pred,    rprli,    " i - Is real part a multiple of 0.1?",        /* I */
    r_code,    roplj,    " j - complex conjugate",                      /* j */
    r_noopc,   FALSE,    " k - ",                                       /* k */
    r_pred1,   rprll,    " lx - pushdown management; (lk deep; ok;)",   /* l */
    r_code,    roplm,    " m - square size: $1.25$ m, default",         /* m */
    r_code,    ropln,    " n - negative",                               /* n */
    r_code,    roplo,    " o - ",                                       /* o */
    r_code,    roplp,    " p - pop the stack = discard top element ",   /* p */
    r_oper1,   roplq,    " qk - draw a small colored square (2 args)",  /* q */
    r_code,    roplr,    " r - complex square root",                    /* r */
    r_code,    ropls,    " s - draw a small stereo square",             /* s */
    r_noopc,   FALSE,    " t - ",                                       /* t */
    r_code,    roplu,    " u - push 0.1",                               /* u */
    r_code,    roplv,    " v - push 0.1 i ",                            /* v */
    r_noopc,   FALSE,    " w - ",                                       /* w */
    r_code,    roplx,    " x - push 0.01",                              /* x */
    r_code,    roply,    " y - push 0.01 i ",                           /* y */
    r_code,    roplz,    " z - draw a small circle",                    /* z */
    r_lbrace,  r_xbrace, " { - start of program",                       /* { */
    r_noopc,   FALSE,    " | - ",                                       /* | */
    r_ubrace,  FALSE,    " } - end of program",                         /* } */
    r_noopc,   FALSE,    " ~ - "                                        /* ~ */
};



Microcomputadoras
2001-02-12