home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / MSWSRC35 / INIT.CPP < prev    next >
C/C++ Source or Header  |  1993-10-12  |  27KB  |  490 lines

  1. /*
  2.  *      init.c      logo init module            dvb
  3.  *
  4.  *    Copyright (C) 1989 The Regents of the University of California
  5.  *    This Software may be copied and distributed for educational,
  6.  *    research, and not for profit purposes provided that this
  7.  *    copyright and statement are included in all such copies.
  8.  *
  9.  */
  10.  
  11. #include "logo.h"
  12. #include "globals.h"
  13. #include <string.h>
  14.  
  15. #ifdef ibm
  16. #include <stdlib.h>
  17. #endif
  18.  
  19. typedef struct priminfo {
  20.     char *name;
  21.     short minargs;
  22.     short defargs;
  23.     short maxargs;
  24.     short priority;
  25.     NODE *(*prim) (NODE *);
  26. } PRIMTYPE;
  27.  
  28. typedef NODE *(*lexone)(NODE *);
  29. typedef NODE *(*lexzer)();
  30.  
  31. NODE *Truex, *Falsex, *Right_Paren, *Left_Paren, *Toplevel, *System, *Error,
  32.      *End, *Redefp, *Caseignoredp, *Erract, *Printdepthlimit,
  33.      *Printwidthlimit, *Pause,
  34.      *If, *Ifelse, *To, *Macro, *Unbound, *Not_Enough_Node,
  35.      *Minus_Sign, *Minus_Tight, *Startup, *Query, *Output, *Op, *Stop;
  36. NODE *Null_Word = NIL;
  37.  
  38. PRIMTYPE prims[] = {
  39.     {"*", 1, 1, 1, PREFIX_PRIORITY + 3, (lexone)lmul},
  40.     {"+", 1, 1, 1, PREFIX_PRIORITY + 2, (lexone)ladd},
  41.     {"-", 1, 1, 1, PREFIX_PRIORITY + 2, (lexone)lsub},
  42.     {"--", 1, 1, 1, PREFIX_PRIORITY + 4, (lexone)lsub},
  43.     {".defmacro", 2, 2, 2, PREFIX_PRIORITY, (lexone)ldefmacro},
  44.     {".eq", 2, 2, 2, PREFIX_PRIORITY, (lexone)l_eq},
  45.     {".macro", -1, -1, -1, PREFIX_PRIORITY, (lexone)lmacro},
  46.     {".maybeoutput", 1, 1, 1, TAIL_PRIORITY, (lexone)loutput},
  47.     {".setbf", 2, 2, 2, PREFIX_PRIORITY, (lexone)l_setbf},
  48.     {".setfirst", 2, 2, 2, PREFIX_PRIORITY, (lexone)l_setfirst},
  49.     {".setitem", 3, 3, 3, PREFIX_PRIORITY, (lexone)l_setitem},
  50.     {"/", 1, 1, 1, PREFIX_PRIORITY + 3, (lexone)ldivide},
  51.     {"<", 2, 2, 2, PREFIX_PRIORITY + 1, (lexone)llessp},
  52.     {"=", 2, 2, 2, PREFIX_PRIORITY + 1, (lexone)lequalp},
  53.     {">", 2, 2, 2, PREFIX_PRIORITY + 1, (lexone)lgreaterp},
  54.     {"?", 0, 0, 1, PREFIX_PRIORITY, (lexone)lqm},
  55.     {"activearea", 0, 0, 0, PREFIX_PRIORITY, (lexone)lactivearea},
  56.     {"setactivearea", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetactivearea},
  57.     {"allopen", 0, 0, 0, PREFIX_PRIORITY, (lexone)lallopen},
  58.     {"and", 0, 2, -1, PREFIX_PRIORITY, (lexone)land},
  59.     {"apply", 2, 2, 2, MACRO_PRIORITY, (lexone)lapply},
  60.     {"arc", 2, 2, 2, PREFIX_PRIORITY, (lexone)larc},
  61.     {"arctan", 1, 1, 2, PREFIX_PRIORITY, (lexone)latan},
  62.     {"array", 1, 1, 2, PREFIX_PRIORITY, (lexone)larray},
  63.     {"arrayp", 1, 1, 1, PREFIX_PRIORITY, (lexone)larrayp},
  64.     {"ascii", 1, 1, 1, PREFIX_PRIORITY, (lexone)lascii},
  65.     {"ashift", 2, 2, 2, PREFIX_PRIORITY, (lexone)lashift},
  66.     {"back", 1, 1, 1, PREFIX_PRIORITY, (lexone)lback},
  67.     {"backslashedp", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbackslashedp},
  68.     {"beforep", 2, 2, 2, PREFIX_PRIORITY, (lexone)lbeforep},
  69.     {"bf", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbutfirst},
  70.     {"bfs", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbfs},
  71.     {"bitand", 0, 2, -1, PREFIX_PRIORITY, (lexone)lbitand},
  72.     {"bitblock", 2, 2, 2, PREFIX_PRIORITY, (lexone)lbitblock},
  73.     {"bitcut", 2, 2, 2, PREFIX_PRIORITY, (lexone)lbitcut},
  74.     {"bitcopy", 2, 2, 2, PREFIX_PRIORITY, (lexone)lbitcopy},
  75.     {"bitfit", 2, 2, 2, PREFIX_PRIORITY, (lexone)lbitfit},
  76.     {"bitload", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbitload},
  77.     {"bitmode", 0, 0, 0, PREFIX_PRIORITY, (lexone)lbitmode},
  78.     {"setbitmode", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetbitmode},
  79.     {"bitindex", 0, 0, 0, PREFIX_PRIORITY, (lexone)lbitindex},
  80.     {"setbitindex", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetbitindex},
  81.     {"settimer", 3, 3, 3, PREFIX_PRIORITY, (lexone)lsettimer},
  82.     {"cleartimer", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcleartimer},
  83.     {"bitnot", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbitnot},
  84.     {"bitor", 0, 2, -1, PREFIX_PRIORITY, (lexone)lbitor},
  85.     {"bitpaste", 0, 0, 0, PREFIX_PRIORITY, (lexone)lbitpaste},
  86.     {"bitsave", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbitsave},
  87.     {"bitxor", 0, 2, -1, PREFIX_PRIORITY, (lexone)lbitxor},
  88.     {"bk", 1, 1, 1, PREFIX_PRIORITY, (lexone)lback},
  89.     {"bl", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbutlast},
  90.     {"buried", 0, 0, 0, PREFIX_PRIORITY, (lexone)lburied},
  91.     {"bury", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbury},
  92.     {"butfirst", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbutfirst},
  93.     {"butfirsts", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbfs},
  94.     {"butlast", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbutlast},
  95.     {"buttoncreate", 8, 8, 8, PREFIX_PRIORITY, (lexone)lbuttoncreate},
  96.     {"buttondelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lbuttondelete},
  97.     {"buttonp", 0, 0, 0, PREFIX_PRIORITY, (lexone)lbuttonp},
  98.     {"bye", 0, 0, 0, PREFIX_PRIORITY, (lexone)lbye},
  99.     {"catch", 2, 2, 2, MACRO_PRIORITY, (lexone)lcatch},
  100.     {"char", 1, 1, 1, PREFIX_PRIORITY, (lexone)lchar},
  101.     {"chdir", 1, 1, 1, PREFIX_PRIORITY, (lexone)lpushdir},
  102.     {"checkboxcreate", 8, 8, 8, PREFIX_PRIORITY, (lexone)lcheckboxcreate},
  103.     {"checkboxdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcheckboxdelete},
  104.     {"checkboxget", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcheckboxget},
  105.     {"checkboxset", 2, 2, 2, PREFIX_PRIORITY, (lexone)lcheckboxset},
  106.     {"clean", 0, 0, 0, PREFIX_PRIORITY, (lexone)lclean},
  107.     {"clearpalette", 0, 0, 0, PREFIX_PRIORITY, (lexone)lclearpalette},
  108.     {"clearscreen", 0, 0, 0, PREFIX_PRIORITY, (lexone)lclearscreen},
  109.     {"cleartext", 0, 0, 0, PREFIX_PRIORITY, (lexone)lcleartext},
  110.     {"close", 1, 1, 1, PREFIX_PRIORITY, (lexone)lclose},
  111.     {"co", OK_NO_ARG, 1, 1, PREFIX_PRIORITY, (lexone)lcontinue},
  112.     {"comboboxaddstring", 2, 2, 2, PREFIX_PRIORITY, (lexone)lcomboboxaddstring},
  113.     {"comboboxcreate", 6, 6, 6, PREFIX_PRIORITY, (lexone)lcomboboxcreate},
  114.     {"comboboxdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcomboboxdelete},
  115.     {"comboboxdeletestring", 2, 2, 2, PREFIX_PRIORITY, (lexone)lcomboboxdeletestring},
  116.     {"comboboxgettext", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcomboboxgettext},
  117.     {"comboboxsettext", 2, 2, 2, PREFIX_PRIORITY, (lexone)lcomboboxsettext},
  118.     {"contents", 0, 0, 0, PREFIX_PRIORITY, (lexone)lcontents},
  119.     {"continue", OK_NO_ARG, 1, 1, PREFIX_PRIORITY, (lexone)lcontinue},
  120.     {"copydef", 2, 2, 2, PREFIX_PRIORITY, (lexone)lcopydef},
  121.     {"cos", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcos},
  122.     {"count", 1, 1, 1, PREFIX_PRIORITY, (lexone)lcount},
  123.     {"cs", 0, 0, 0, PREFIX_PRIORITY, (lexone)lclearscreen},
  124.     {"ct", 0, 0, 0, PREFIX_PRIORITY, (lexone)lcleartext},
  125.     {"cursor", 0, 0, 0, PREFIX_PRIORITY, (lexone)lcursor},
  126.     {"debugwindows", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldebugwindows},
  127.     {"define", 2, 2, 2, PREFIX_PRIORITY, (lexone)ldefine},
  128.     {"definedp", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldefinedp},
  129.     {"dialogcreate", 8, 8, 8, PREFIX_PRIORITY, (lexone)ldialogcreate},
  130.     {"dialogdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldialogdelete},
  131.     {"dialogfileopen", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldialogfileopen},
  132.     {"dialogfilesave", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldialogfilesave},
  133.     {"windowfileedit", 2, 2, 2, PREFIX_PRIORITY, (lexone)lwindowfileedit},
  134.     {"difference", 2, 2, 2, PREFIX_PRIORITY, (lexone)lsub},
  135.     {"dir", 0, 0, 0, PREFIX_PRIORITY, (lexone)ldir},
  136.     {"dribble", 1, 1, 1, PREFIX_PRIORITY, (lexone)ldribble},
  137.     {"ed", OK_NO_ARG, 1, 1, PREFIX_PRIORITY, (lexone)ledit},
  138.     {"edit", OK_NO_ARG, 1, 1, PREFIX_PRIORITY, (lexone)ledit},
  139.     {"emptyp", 1, 1, 1, PREFIX_PRIORITY, (lexone)lemptyp},
  140.     {"eofp", 0, 0, 0, PREFIX_PRIORITY, (lexone)leofp},
  141.     {"equalp", 2, 2, 2, PREFIX_PRIORITY, (lexone)lequalp},
  142.     {"er", 1, 1, 1, PREFIX_PRIORITY, (lexone)lerase},
  143.     {"erase", 1, 1, 1, PREFIX_PRIORITY, (lexone)lerase},
  144.     {"erasefile", 1, 1, 1, PREFIX_PRIORITY, (lexone)lerasefile},
  145.     {"erf", 1, 1, 1, PREFIX_PRIORITY, (lexone)lerasefile},
  146.     {"error", 0, 0, 0, PREFIX_PRIORITY, (lexone)lerror},
  147.     {"exp", 1, 1, 1, PREFIX_PRIORITY, (lexone)lexp},
  148.     {"fd", 1, 1, 1, PREFIX_PRIORITY, (lexone)lforward},
  149.     {"fence", 0, 0, 0, PREFIX_PRIORITY, (lexone)lfence},
  150.     {"fill", 0, 0, 0, PREFIX_PRIORITY, (lexone)lfill},
  151.     {"first", 1, 1, 1, PREFIX_PRIORITY, (lexone)lfirst},
  152.     {"firsts", 1, 1, 1, PREFIX_PRIORITY, (lexone)lfirsts},
  153.     {"floodcolor", 0, 0, 0, PREFIX_PRIORITY, (lexone)lfloodcolor},
  154.     {"setfocus", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetfocus},
  155.     {"getfocus", 0, 0, 0, PREFIX_PRIORITY, (lexone)lgetfocus},
  156.     {"forever", 1, 1, 1, MACRO_PRIORITY, (lexone)lforever},
  157.     {"form", 3, 3, 3, PREFIX_PRIORITY, (lexone)lform},
  158.     {"forward", 1, 1, 1, PREFIX_PRIORITY, (lexone)lforward},
  159.     {"fput", 2, 2, 2, PREFIX_PRIORITY, (lexone)lfput},
  160.     {"fs", 0, 0, 0, PREFIX_PRIORITY, (lexone)lfullscreen},
  161.     {"fullscreen", 0, 0, 0, PREFIX_PRIORITY, (lexone)lfullscreen},
  162.     {"fulltext", 1, 1, 1, PREFIX_PRIORITY, (lexone)lfulltext},
  163.     {"gprop", 2, 2, 2, PREFIX_PRIORITY, (lexone)lgprop},
  164.     {"greaterp", 2, 2, 2, PREFIX_PRIORITY, (lexone)lgreaterp},
  165.     {"groupboxcreate", 6, 6, 6, PREFIX_PRIORITY, (lexone)lgroupboxcreate},
  166.     {"groupboxdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lgroupboxdelete},
  167.     {"halt", 0, 0, 0, PREFIX_PRIORITY, (lexone)lhalt},           
  168.     {"heading", 0, 0, 0, PREFIX_PRIORITY, (lexone)lheading},
  169.     {"help", OK_NO_ARG, 1, 1, PREFIX_PRIORITY, (lexone)lhelp},
  170.     {"hideturtle", 0, 0, 0, PREFIX_PRIORITY, (lexone)lhideturtle},
  171.     {"home", 0, 0, 0, PREFIX_PRIORITY, (lexone)lhome},
  172.     {"ht", 0, 0, 0, PREFIX_PRIORITY, (lexone)lhideturtle},
  173.     {"icon", 1, 1, 1, PREFIX_PRIORITY, (lexone)licon},
  174.     {"if", 2, 2, 3, MACRO_PRIORITY, (lexone)lif},
  175.     {"ifelse", 3, 3, 3, MACRO_PRIORITY, (lexone)lifelse},
  176.     {"iff", 1, 1, 1, MACRO_PRIORITY, (lexone)liffalse},
  177.     {"iffalse", 1, 1, 1, MACRO_PRIORITY, (lexone)liffalse},
  178.     {"ift", 1, 1, 1, MACRO_PRIORITY, (lexone)liftrue},
  179.     {"iftrue", 1, 1, 1, MACRO_PRIORITY, (lexone)liftrue},
  180.     {"int", 1, 1, 1, PREFIX_PRIORITY, (lexone)linteg},
  181.     {"item", 2, 2, 2, PREFIX_PRIORITY, (lexone)litem},
  182.     {"keyboardoff", 0, 0, 0, PREFIX_PRIORITY, (lexone)lkeyboardoff},
  183.     {"keyboardon", 1, 1, 2, PREFIX_PRIORITY, (lexone)lkeyboardon},
  184.     {"keyboardvalue", 0, 0, 0, PREFIX_PRIORITY, (lexone)lkeyboardvalue},
  185.     {"keyp", 0, 0, 0, PREFIX_PRIORITY, (lexone)lkeyp},
  186.     {"label", 1, 1, 1, PREFIX_PRIORITY, (lexone)llabel},
  187.     {"last", 1, 1, 1, PREFIX_PRIORITY, (lexone)llast},
  188.     {"left", 1, 1, 1, PREFIX_PRIORITY, (lexone)lleft},
  189.     {"lessp", 2, 2, 2, PREFIX_PRIORITY, (lexone)llessp},
  190.     {"list", 1, 2, -1, PREFIX_PRIORITY, (lexone)llist},
  191.     {"listboxaddstring", 2, 2, 2, PREFIX_PRIORITY, (lexone)llistboxaddstring},
  192.     {"listboxcreate", 6, 6, 6, PREFIX_PRIORITY, (lexone)llistboxcreate},
  193.     {"listboxdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)llistboxdelete},
  194.     {"listboxdeletestring", 2, 2, 2, PREFIX_PRIORITY, (lexone)llistboxdeletestring},
  195.     {"listboxgetselect", 1, 1, 1, PREFIX_PRIORITY, (lexone)llistboxgetselect},
  196.     {"listp", 1, 1, 1, PREFIX_PRIORITY, (lexone)llistp},
  197.     {"ln", 1, 1, 1, PREFIX_PRIORITY, (lexone)lln},
  198.     {"load", 1, 1, 1, PREFIX_PRIORITY, (lexone)lload},
  199.     {"local", 1, 1, -1, PREFIX_PRIORITY, (lexone)llocal},
  200.     {"log10", 1, 1, 1, PREFIX_PRIORITY, (lexone)llog10},
  201.     {"lowercase", 1, 1, 1, PREFIX_PRIORITY, (lexone)llowercase},
  202.     {"lput", 2, 2, 2, PREFIX_PRIORITY, (lexone)llput},
  203.     {"lshift", 2, 2, 2, PREFIX_PRIORITY, (lexone)llshift},
  204.     {"lt", 1, 1, 1, PREFIX_PRIORITY, (lexone)lleft},
  205.     {"macrop", 1, 1, 1, PREFIX_PRIORITY, (lexone)lmacrop},
  206.     {"make", 2, 2, 2, PREFIX_PRIORITY, (lexone)lmake},
  207.     {"mci", 1, 1, 2, PREFIX_PRIORITY, (lexone)lmci},
  208.     {"midiopen", 0, 0, 1, PREFIX_PRIORITY, (lexone)lmidiopen},
  209.     {"midiclose", 0, 0, 0, PREFIX_PRIORITY, (lexone)lmidiclose},
  210.     {"midimessage", 1, 1, 1, PREFIX_PRIORITY, (lexone)lmidimessage},
  211.     {"sound", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsound},
  212.     {"winhelp", 1, 1, 2, PREFIX_PRIORITY, (lexone)lwinhelp},
  213.     {"machine", 0, 0, 0, PREFIX_PRIORITY, (lexone)lmachine},
  214.     {"member", 2, 2, 2, PREFIX_PRIORITY, (lexone)lmember},
  215.     {"memberp", 2, 2, 2, PREFIX_PRIORITY, (lexone)lmemberp},
  216.     {"messagebox", 2, 2, 2, PREFIX_PRIORITY, (lexone)lmessagebox},
  217.     {"minus", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsub},
  218.     {"mkdir", 1, 1, 1, PREFIX_PRIORITY, (lexone)lmkdir},
  219.     {"mouseoff", 0, 0, 0, PREFIX_PRIORITY, (lexone)lmouseoff},
  220.     {"mouseon", 5, 5, 5, PREFIX_PRIORITY, (lexone)lmouseon},
  221.     {"mousepos", 0, 0, 0, PREFIX_PRIORITY, (lexone)lmousepos},
  222.     {"namep", 1, 1, 1, PREFIX_PRIORITY, (lexone)lnamep},
  223.     {"names", 0, 0, 0, PREFIX_PRIORITY, (lexone)lnames},
  224.     {"nodribble", 0, 0, 0, PREFIX_PRIORITY, (lexone)lnodribble},
  225.     {"norefresh", 0, 0, 0, PREFIX_PRIORITY, (lexone)lnorefresh},
  226.     {"nostatus", 0, 0, 0, PREFIX_PRIORITY, (lexone)lnostatus},
  227.     {"not", 1, 1, 1, PREFIX_PRIORITY, (lexone)lnot},
  228.     {"noyield", 0, 0, 0, PREFIX_PRIORITY, (lexone)lnoyield},           
  229.     {"numberp", 1, 1, 1, PREFIX_PRIORITY, (lexone)lnumberp},
  230.     {"op", 1, 1, 1, TAIL_PRIORITY, (lexone)loutput},
  231.     {"openappend", 1, 1, 1, PREFIX_PRIORITY, (lexone)lopenappend},
  232.     {"openread", 1, 1, 1, PREFIX_PRIORITY, (lexone)lopenread},
  233.     {"openupdate", 1, 1, 1, PREFIX_PRIORITY, (lexone)lopenupdate},
  234.     {"openwrite", 1, 1, 1, PREFIX_PRIORITY, (lexone)lopenwrite},
  235.     {"or", 0, 2, -1, PREFIX_PRIORITY, (lexone)lor},
  236.     {"output", 1, 1, 1, TAIL_PRIORITY, (lexone)loutput},
  237.     {"parse", 1, 1, 1, PREFIX_PRIORITY, (lexone)lparse},
  238.     {"pause", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpause},           
  239.     {"pd", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpendown},
  240.     {"pe", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenerase},
  241.     {"pixel", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpixel},
  242.     {"pencolor", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpencolor},
  243.     {"pendown", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpendown},
  244.     {"pendownp", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpendownp},
  245.     {"penerase", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenerase},
  246.     {"penmode", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenmode},
  247.     {"penpaint", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenpaint},
  248.     {"penpattern", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenpattern},
  249.     {"penreverse", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenreverse},
  250.     {"pensize", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpensize},
  251.     {"penup", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenup},
  252.     {"plist", 1, 1, 1, PREFIX_PRIORITY, (lexone)lplist},
  253.     {"plists", 0, 0, 0, PREFIX_PRIORITY, (lexone)lplists},
  254.     {"po", 1, 1, 1, PREFIX_PRIORITY, (lexone)lpo},
  255.     {"popdir", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpopdir},
  256.     {"portclose", 0, 0, 0, PREFIX_PRIORITY, (lexone)lportclose},
  257.     {"portflush", 1, 1, 1, PREFIX_PRIORITY, (lexone)lportflush},
  258.     {"portmode", 1, 1, 1, PREFIX_PRIORITY, (lexone)lportmode},
  259.     {"portopen", 1, 1, 1, PREFIX_PRIORITY, (lexone)lportopen},
  260.     {"portreadarray", 2, 2, 2, PREFIX_PRIORITY, (lexone)lportreadarray},
  261.     {"portreadchar", 0, 0, 0, PREFIX_PRIORITY, (lexone)lportreadchar},
  262.     {"portwritearray", 2, 2, 2, PREFIX_PRIORITY, (lexone)lportwritearray},
  263.     {"portwritechar", 1, 1, 1, PREFIX_PRIORITY, (lexone)lportwritechar},
  264.     {"pos", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpos},
  265.     {"pot", 1, 1, 1, PREFIX_PRIORITY, (lexone)lpot},
  266.     {"power", 2, 2, 2, PREFIX_PRIORITY, (lexone)lpower},
  267.     {"pprop", 3, 3, 3, PREFIX_PRIORITY, (lexone)lpprop},
  268.     {"ppt", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenpaint},
  269.     {"pr", 0, 1, -1, PREFIX_PRIORITY, (lexone)lprint},
  270.     {"primitivep", 1, 1, 1, PREFIX_PRIORITY, (lexone)lprimitivep},
  271.     {"print", 0, 1, -1, PREFIX_PRIORITY, (lexone)lprint},
  272.     {"procedurep", 1, 1, 1, PREFIX_PRIORITY, (lexone)lprocedurep},
  273.     {"procedures", 0, 0, 0, PREFIX_PRIORITY, (lexone)lprocedures},
  274.     {"product", 0, 2, -1, PREFIX_PRIORITY, (lexone)lmul},
  275.     {"pu", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenup},
  276.     {"px", 0, 0, 0, PREFIX_PRIORITY, (lexone)lpenreverse},
  277.     {"quotient", 1, 2, 2, PREFIX_PRIORITY, (lexone)ldivide},
  278.     {"radarctan", 1, 1, 2, PREFIX_PRIORITY, (lexone)lradatan},
  279.     {"radcos", 1, 1, 1, PREFIX_PRIORITY, (lexone)lradcos},
  280.     {"radiobuttoncreate", 8, 8, 8, PREFIX_PRIORITY, (lexone)lradiobuttoncreate},
  281.     {"radiobuttondelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lradiobuttondelete},
  282.     {"radiobuttonget", 1, 1, 1, PREFIX_PRIORITY, (lexone)lradiobuttonget},
  283.     {"radiobuttonset", 2, 2, 2, PREFIX_PRIORITY, (lexone)lradiobuttonset},
  284.     {"radsin", 1, 1, 1, PREFIX_PRIORITY, (lexone)lradsin},
  285.     {"random", 1, 1, 1, PREFIX_PRIORITY, (lexone)lrandom},
  286.     {"rc", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadchar},
  287.     {"rcs", 1, 1, 1, PREFIX_PRIORITY, (lexone)lreadchars},
  288.     {"readchar", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadchar},
  289.     {"readchars", 1, 1, 1, PREFIX_PRIORITY, (lexone)lreadchars},
  290.     {"reader", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreader},
  291.     {"readlist", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadlist},
  292.     {"readpos", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadpos},
  293.     {"readword", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadword},
  294.     {"refresh", 0, 0, 0, PREFIX_PRIORITY, (lexone)lrefresh},
  295.     {"remainder", 2, 2, 2, PREFIX_PRIORITY, (lexone)lremainder},
  296.     {"remprop", 2, 2, 2, PREFIX_PRIORITY, (lexone)lremprop},
  297.     {"repcount", 0, 0, 0, PREFIX_PRIORITY, (lexone)lrepcount},
  298.     {"repeat", 2, 2, 2, MACRO_PRIORITY, (lexone)lrepeat},
  299.     {"rerandom", 0, 0, 1, PREFIX_PRIORITY, (lexone)lrerandom},
  300.     {"right", 1, 1, 1, PREFIX_PRIORITY, (lexone)lright},
  301.     {"rl", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadlist},
  302.     {"rmdir", 1, 1, 1, PREFIX_PRIORITY, (lexone)lrmdir},
  303.     {"round", 1, 1, 1, PREFIX_PRIORITY, (lexone)lround},
  304.     {"rt", 1, 1, 1, PREFIX_PRIORITY, (lexone)lright},
  305.     {"run", 1, 1, 1, MACRO_PRIORITY, (lexone)lrun},
  306.     {"runparse", 1, 1, 1, PREFIX_PRIORITY, (lexone)lrunparse},
  307.     {"runresult", 1, 1, 1, MACRO_PRIORITY, (lexone)lrunresult},
  308.     {"rw", 0, 0, 0, PREFIX_PRIORITY, (lexone)lreadword},
  309.     {"save", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsave},
  310.     {"screencolor", 0, 0, 0, PREFIX_PRIORITY, (lexone)lscreencolor},
  311.     {"scrollbarcreate", 7, 7, 7, PREFIX_PRIORITY, (lexone)lscrollbarcreate},
  312.     {"scrollbardelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lscrollbardelete},
  313.     {"scrollbarget", 1, 1, 1, PREFIX_PRIORITY, (lexone)lscrollbarget},
  314.     {"scrollbarset", 4, 4, 4, PREFIX_PRIORITY, (lexone)lscrollbarset},
  315.     {"scrollx", 1, 1, 1, PREFIX_PRIORITY, (lexone)lscrollx},
  316.     {"scrolly", 1, 1, 1, PREFIX_PRIORITY, (lexone)lscrolly},
  317.     {"scrunch", 0, 0, 0, PREFIX_PRIORITY, (lexone)lscrunch},
  318.     {"se", 0, 2, -1, PREFIX_PRIORITY, (lexone)lsentence},
  319.     {"sentence", 0, 2, -1, PREFIX_PRIORITY, (lexone)lsentence},
  320.     {"setcursor", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetcursor},
  321.     {"setcursornowait", 0, 0, 0, PREFIX_PRIORITY, (lexone)lsetcursorarrow},
  322.     {"setcursorwait", 0, 0, 0, PREFIX_PRIORITY, (lexone)lsetcursorwait},
  323.     {"setfc", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetfloodcolor},
  324.     {"setfloodcolor", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetfloodcolor},
  325.     {"seth", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetheading},
  326.     {"setheading", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetheading},
  327.     {"setitem", 3, 3, 3, PREFIX_PRIORITY, (lexone)lsetitem},
  328.     {"setmargins", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetmargins},
  329.     {"setpc", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetpencolor},
  330.     {"setpencolor", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetpencolor},
  331.     {"setpenpattern", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetpenpattern},
  332.     {"setpensize", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetpensize},
  333.     {"setpos", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetpos},
  334.     {"setread", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetread},
  335.     {"setreadpos", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetreadpos},
  336.     {"setsc", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetscreencolor},
  337.     {"setscreencolor", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetscreencolor},
  338.     {"setscrunch", 2, 2, 2, PREFIX_PRIORITY, (lexone)lsetscrunch},
  339.     {"settextfont", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsettextfont},
  340.     {"textfont", 0, 0, 0, PREFIX_PRIORITY, (lexone)ltextfont},
  341.     {"setwrite", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetwrite},
  342.     {"setwritepos", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetwritepos},
  343.     {"setx", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsetx},
  344.     {"setxy", 2, 2, 2, PREFIX_PRIORITY, (lexone)lsetxy},
  345.     {"sety", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsety},
  346.     {"shell", 1, 1, 2, PREFIX_PRIORITY, (lexone)lshell},
  347.     {"show", 0, 1, -1, PREFIX_PRIORITY, (lexone)lshow},
  348.     {"shownp", 0, 0, 0, PREFIX_PRIORITY, (lexone)lshownp},
  349.     {"showturtle", 0, 0, 0, PREFIX_PRIORITY, (lexone)lshowturtle},
  350.     {"sin", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsin},
  351.     {"splitscreen", 0, 0, 0, PREFIX_PRIORITY, (lexone)lsplitscreen},
  352.     {"sqrt", 1, 1, 1, PREFIX_PRIORITY, (lexone)lsqrt},
  353.     {"ss", 0, 0, 0, PREFIX_PRIORITY, (lexone)lsplitscreen},
  354.     {"st", 0, 0, 0, PREFIX_PRIORITY, (lexone)lshowturtle},
  355.     {"standout", 1, 1, 1, PREFIX_PRIORITY, (lexone)lstandout},
  356.     {"staticcreate", 7, 7, 7, PREFIX_PRIORITY, (lexone)lstaticcreate},
  357.     {"staticdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lstaticdelete},
  358.     {"staticupdate", 2, 2, 2, PREFIX_PRIORITY, (lexone)lstaticupdate},
  359.     {"status", 0, 0, 0, PREFIX_PRIORITY, (lexone)lstatus},
  360.     {"step", 1, 1, 1, PREFIX_PRIORITY, (lexone)lstep},
  361.     {"stop", 0, 0, 0, TAIL_PRIORITY, (lexone)lstop},
  362.     {"sum", 0, 2, -1, PREFIX_PRIORITY, (lexone)ladd},
  363.     {"test", 1, 1, 1, PREFIX_PRIORITY, (lexone)ltest},
  364.     {"text", 1, 1, 1, PREFIX_PRIORITY, (lexone)ltext},
  365.     {"textscreen", 0, 0, 0, PREFIX_PRIORITY, (lexone)ltextscreen},
  366.     {"thing", 1, 1, 1, PREFIX_PRIORITY, (lexone)lthing},
  367.     {"throw", 1, 1, 2, PREFIX_PRIORITY, (lexone)lthrow},
  368.     {"time", 0, 0, 0, PREFIX_PRIORITY, (lexone)ltime},
  369.     {"to", -1, -1, -1, PREFIX_PRIORITY, (lexone)lto},
  370.     {"tone", 2, 2, 2, PREFIX_PRIORITY, (lexone)ltone},
  371.     {"towards", 1, 1, 1, PREFIX_PRIORITY, (lexone)ltowards},
  372.     {"trace", 1, 1, 1, PREFIX_PRIORITY, (lexone)ltrace},
  373.     {"ts", 0, 0, 0, PREFIX_PRIORITY, (lexone)ltextscreen},
  374.     {"type", 0, 1, -1, PREFIX_PRIORITY, (lexone)ltype},
  375.     {"unbury", 1, 1, 1, PREFIX_PRIORITY, (lexone)lunbury},
  376.     {"unicon", 1, 1, 1, PREFIX_PRIORITY, (lexone)lunicon},
  377.     {"unstep", 1, 1, 1, PREFIX_PRIORITY, (lexone)lunstep},
  378.     {"untrace", 1, 1, 1, PREFIX_PRIORITY, (lexone)luntrace},
  379.     {"uppercase", 1, 1, 1, PREFIX_PRIORITY, (lexone)luppercase},
  380.     {"wait", 1, 1, 1, PREFIX_PRIORITY, (lexone)lwait},
  381.     {"eventcheck", 0, 0, 0, PREFIX_PRIORITY, (lexone)leventcheck},
  382.     {"window", 0, 0, 0, PREFIX_PRIORITY, (lexone)lwindow},
  383.     {"windowcreate", 7, 7, 7, PREFIX_PRIORITY, (lexone)lwindowcreate},
  384.     {"windowdelete", 1, 1, 1, PREFIX_PRIORITY, (lexone)lwindowdelete},
  385.     {"word", 0, 2, -1, PREFIX_PRIORITY, (lexone)lword},
  386.     {"wordp", 1, 1, 1, PREFIX_PRIORITY, (lexone)lwordp},
  387.     {"wrap", 0, 0, 0, PREFIX_PRIORITY, (lexone)lwrap},
  388.     {"writepos", 0, 0, 0, PREFIX_PRIORITY, (lexone)lwritepos},
  389.     {"writer", 0, 0, 0, PREFIX_PRIORITY, (lexone)lwriter},
  390.     {"yield", 0, 0, 0, PREFIX_PRIORITY, (lexone)lyield},           
  391.     {"zoom", 1, 1, 1, PREFIX_PRIORITY, (lexone)lzoom},
  392.     {0, 0, 0, 0, 0, 0}
  393. };
  394.  
  395. NODE* valref(NODE *p) {
  396.     ref(p);
  397.     return p;
  398. }
  399.  
  400. void init()
  401. {
  402. //    extern long time();
  403.     int i = 0;
  404.     NODE *proc = NIL, *pname = NIL, *cnd = NIL;
  405.  
  406.     Unbound = newnode(PUNBOUND);
  407.  
  408. #ifdef bsd
  409.     srandom((int)time((long *)NULL));
  410. #else
  411. //    srand((int)time((long *)NULL));
  412. //    srand((int)12345);
  413. #endif
  414. #ifdef ecma
  415.     for (i=0; i<128; i++)
  416.     ecma_array[i] = i;
  417.     for (i=0; i<ecma_size; i++)
  418.     ecma_array[special_chars[i]] = '\200'+i;
  419. #endif
  420.  
  421. //    logolib = getenv("LOGOLIB");
  422. //    if (logolib == NULL) logolib = libloc;
  423. //    editor = getenv("EDITOR");
  424. //    if (editor == NULL) editor = "jove";
  425.  
  426.     editor = "jove";
  427.     editorname = strrchr(editor, (int)'/');
  428.     editorname = (editorname ? editorname+1 : editor);
  429.  
  430.     i = 0;
  431.     while (prims[i].name) {
  432.     if (prims[i].priority == MACRO_PRIORITY)
  433.         proc = reref(proc, newnode(MACRO));
  434.     else if (prims[i].priority == TAIL_PRIORITY)
  435.         proc = reref(proc, newnode(TAILFORM));
  436.         else if ((prims[i].priority & ~4) == PREFIX_PRIORITY)
  437.             proc = reref(proc, newnode(PRIM)); /* incl. -- */
  438.     else
  439.         proc = reref(proc, newnode(INFIX));
  440.     if (prims[i].priority < PREFIX_PRIORITY)
  441.         setprimpri(proc, PREFIX_PRIORITY);
  442.     else
  443.         setprimpri(proc, prims[i].priority);
  444.     setprimfun(proc, (lexzer)prims[i].prim);
  445.     setprimdflt(proc, prims[i].defargs);
  446.     setprimmax(proc, prims[i].maxargs);
  447.     setprimmin(proc, prims[i].minargs);
  448.     pname = reref(pname, make_static_strnode(prims[i].name));
  449.     cnd = reref(cnd, make_instance(pname, pname));
  450.     setprocnode__caseobj(cnd, proc);
  451.     if (nodetype(proc) == MACRO)
  452.         setflag__caseobj(cnd, PROC_MACRO);
  453.     i++;
  454.     }
  455.     deref(proc);
  456.     deref(cnd);
  457.     deref(pname);
  458.     Truex = intern(make_static_strnode("true"));
  459.     Falsex = intern(make_static_strnode("false"));
  460.     Left_Paren = intern(make_static_strnode("("));
  461.     Right_Paren = intern(make_static_strnode(")"));
  462.     Minus_Sign = intern(make_static_strnode("-"));
  463.     Minus_Tight = intern(make_static_strnode("--"));
  464.     Query = intern(make_static_strnode("?"));
  465.     Null_Word = intern(make_static_strnode("\0"));
  466.     To = intern(make_static_strnode("to"));
  467.     Macro = intern(make_static_strnode(".macro"));
  468.     Toplevel = intern(make_static_strnode("toplevel"));
  469.     System = intern(make_static_strnode("system"));
  470.     Error = intern(make_static_strnode("error"));
  471.     End = intern(make_static_strnode("end"));
  472.     If = intern(make_static_strnode("if"));
  473.     Ifelse = intern(make_static_strnode("ifelse"));
  474.     Redefp = intern(make_static_strnode("redefp"));
  475.     Caseignoredp = intern(make_static_strnode("caseignoredp"));
  476.     setvalnode__caseobj(Caseignoredp, Truex);
  477.     setflag__caseobj(Caseignoredp, VAL_BURIED);
  478.     Erract = intern(make_static_strnode("erract"));
  479.     Printdepthlimit = intern(make_static_strnode("printdepthlimit"));
  480.     Printwidthlimit = intern(make_static_strnode("printwidthlimit"));
  481.     Pause = intern(make_static_strnode("pause"));
  482.     Startup = intern(make_static_strnode("startup"));
  483.     Output = intern(make_static_strnode("output"));
  484.     Op = intern(make_static_strnode("op"));
  485.     Stop = intern(make_static_strnode("stop"));
  486.     the_generation = valref(cons(NIL, NIL));
  487.     Not_Enough_Node = valref(cons(NIL, NIL));
  488.  
  489. }
  490.