picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

tab.c (9352B)


      1 /* 31jul13abu
      2  * (c) Software Lab. Alexander Burger
      3  */
      4 
      5 #include "pico.h"
      6 
      7 typedef struct symInit {fun code; char *name;} symInit;
      8 
      9 static symInit Symbols[] = {
     10    {doAbs, "abs"},
     11    {doAccept, "accept"},
     12    {doAdd, "+"},
     13    {doAdr, "adr"},
     14    {doAlarm, "alarm"},
     15    {doAll, "all"},
     16    {doAnd, "and"},
     17    {doAny, "any"},
     18    {doAppend, "append"},
     19    {doApply, "apply"},
     20    {doArg, "arg"},
     21    {doArgs, "args"},
     22    {doArgv, "argv"},
     23    {doArrow, "->"},
     24    {doAs, "as"},
     25    {doAsoq, "asoq"},
     26    {doAssoc, "assoc"},
     27    {doAt, "at"},
     28    {doAtom, "atom"},
     29    {doBind, "bind"},
     30    {doBitAnd, "&"},
     31    {doBitOr, "|"},
     32    {doBitQ, "bit?"},
     33    {doBitXor, "x|"},
     34    {doBool, "bool"},
     35    {doBox, "box"},
     36    {doBoxQ, "box?"},
     37    {doBreak, "!"},
     38    {doBy, "by"},
     39    {doBye, "bye"},
     40    {doBytes, "bytes"},
     41    {doCaaaar, "caaaar"},
     42    {doCaaadr, "caaadr"},
     43    {doCaaar, "caaar"},
     44    {doCaadar, "caadar"},
     45    {doCaaddr, "caaddr"},
     46    {doCaadr, "caadr"},
     47    {doCaar, "caar"},
     48    {doCadaar, "cadaar"},
     49    {doCadadr, "cadadr"},
     50    {doCadar, "cadar"},
     51    {doCaddar, "caddar"},
     52    {doCadddr, "cadddr"},
     53    {doCaddr, "caddr"},
     54    {doCadr, "cadr"},
     55    {doCall, "call"},
     56    {doCar, "car"},
     57    {doCase, "case"},
     58    {doCasq, "casq"},
     59    {doCatch, "catch"},
     60    {doCdaaar, "cdaaar"},
     61    {doCdaadr, "cdaadr"},
     62    {doCdaar, "cdaar"},
     63    {doCdadar, "cdadar"},
     64    {doCdaddr, "cdaddr"},
     65    {doCdadr, "cdadr"},
     66    {doCd, "cd"},
     67    {doCdar, "cdar"},
     68    {doCddaar, "cddaar"},
     69    {doCddadr, "cddadr"},
     70    {doCddar, "cddar"},
     71    {doCdddar, "cdddar"},
     72    {doCddddr, "cddddr"},
     73    {doCdddr, "cdddr"},
     74    {doCddr, "cddr"},
     75    {doCdr, "cdr"},
     76    {doChar, "char"},
     77    {doChain, "chain"},
     78    {doChop, "chop"},
     79    {doCirc, "circ"},
     80    {doCircQ, "circ?"},
     81    {doClip, "clip"},
     82    {doClose, "close"},
     83    {doCmd, "cmd"},
     84    {doCnt, "cnt"},
     85    {doCol, ":"},
     86    {doCommit, "commit"},
     87    {doCon, "con"},
     88    {doConc, "conc"},
     89    {doCond, "cond"},
     90    {doConnect, "connect"},
     91    {doCons, "cons"},
     92    {doCopy, "copy"},
     93    {doCtl, "ctl"},
     94    {doCtty, "ctty"},
     95    {doCut, "cut"},
     96    {doDate, "date"},
     97    {doDbck, "dbck"},
     98    {doDe, "de"},
     99    {doDec, "dec"},
    100    {doDef, "def"},
    101    {doDefault, "default"},
    102    {doDel, "del"},
    103    {doDelete, "delete"},
    104    {doDelq, "delq"},
    105    {doDiff, "diff"},
    106    {doDir, "dir"},
    107    {doDiv, "/"},
    108    {doDm, "dm"},
    109    {doDo, "do"},
    110    {doE, "e"},
    111    {doEcho, "echo"},
    112    {doEnv, "env"},
    113    {doEof, "eof"},
    114    {doEol, "eol"},
    115    {doEq, "=="},
    116    {doEq0, "=0"},
    117    {doEqT, "=T"},
    118    {doEqual, "="},
    119    {doErr, "err"},
    120    {doEval, "eval"},
    121    {doExt, "ext"},
    122    {doExtern, "extern"},
    123    {doExtQ, "ext?"},
    124    {doExtra, "extra"},
    125    {doExtract, "extract"},
    126    {doFifo, "fifo"},
    127    {doFile, "file"},
    128    {doFill, "fill"},
    129    {doFilter, "filter"},
    130    {doFin, "fin"},
    131    {doFinally, "finally"},
    132    {doFind, "find"},
    133    {doFish, "fish"},
    134    {doFlgQ, "flg?"},
    135    {doFlip, "flip"},
    136    {doFlush, "flush"},
    137    {doFold, "fold"},
    138    {doFor, "for"},
    139    {doFork, "fork"},
    140    {doFormat, "format"},
    141    {doFree, "free"},
    142    {doFrom, "from"},
    143    {doFull, "full"},
    144    {doFunQ, "fun?"},
    145    {doGc, "gc"},
    146    {doGe, ">="},
    147    {doGe0, "ge0"},
    148    {doGet, "get"},
    149    {doGetd, "getd"},
    150    {doGetl, "getl"},
    151    {doGlue, "glue"},
    152    {doGt, ">"},
    153    {doGt0, "gt0"},
    154    {doHash, "hash"},
    155    {doHead, "head"},
    156    {doHeap, "heap"},
    157    {doHear, "hear"},
    158    {doHide, "===="},
    159    {doHost, "host"},
    160    {doId, "id"},
    161    {doIdx, "idx"},
    162    {doIf, "if"},
    163    {doIf2, "if2"},
    164    {doIfn, "ifn"},
    165    {doIn, "in"},
    166    {doInc, "inc"},
    167    {doIndex, "index"},
    168    {doInfo, "info"},
    169    {doIntern, "intern"},
    170    {doIpid, "ipid"},
    171    {doIsa, "isa"},
    172    {doJob, "job"},
    173    {doJournal, "journal"},
    174    {doKey, "key"},
    175    {doKill, "kill"},
    176    {doLast, "last"},
    177    {doLe, "<="},
    178    {doLe0, "le0"},
    179    {doLength, "length"},
    180    {doLet, "let"},
    181    {doLetQ, "let?"},
    182    {doLieu, "lieu"},
    183    {doLine, "line"},
    184    {doLines, "lines"},
    185    {doLink, "link"},
    186    {doList, "list"},
    187    {doListen, "listen"},
    188    {doLit, "lit"},
    189    {doLstQ, "lst?"},
    190    {doLoad, "load"},
    191    {doLock, "lock"},
    192    {doLoop, "loop"},
    193    {doLowQ, "low?"},
    194    {doLowc, "lowc"},
    195    {doLt, "<"},
    196    {doLt0, "lt0"},
    197    {doLup, "lup"},
    198    {doMade, "made"},
    199    {doMake, "make"},
    200    {doMap, "map"},
    201    {doMapc, "mapc"},
    202    {doMapcan, "mapcan"},
    203    {doMapcar, "mapcar"},
    204    {doMapcon, "mapcon"},
    205    {doMaplist, "maplist"},
    206    {doMaps, "maps"},
    207    {doMark, "mark"},
    208    {doMatch, "match"},
    209    {doMax, "max"},
    210    {doMaxi, "maxi"},
    211    {doMember, "member"},
    212    {doMemq, "memq"},
    213    {doMeta, "meta"},
    214    {doMethod, "method"},
    215    {doMin, "min"},
    216    {doMini, "mini"},
    217    {doMix, "mix"},
    218    {doMmeq, "mmeq"},
    219    {doMul, "*"},
    220    {doMulDiv, "*/"},
    221    {doName, "name"},
    222    {doNand, "nand"},
    223    {doNEq, "n=="},
    224    {doNEq0, "n0"},
    225    {doNEqT, "nT"},
    226    {doNEqual, "<>"},
    227    {doNeed, "need"},
    228    {doNew, "new"},
    229    {doNext, "next"},
    230    {doNil, "nil"},
    231    {doNond, "nond"},
    232    {doNor, "nor"},
    233    {doNot, "not"},
    234    {doNth, "nth"},
    235    {doNumQ, "num?"},
    236    {doOff, "off"},
    237    {doOffset, "offset"},
    238    {doOn, "on"},
    239    {doOne, "one"},
    240    {doOnOff, "onOff"},
    241    {doOpen, "open"},
    242    {doOpid, "opid"},
    243    {doOpt, "opt"},
    244    {doOr, "or"},
    245    {doOut, "out"},
    246    {doPack, "pack"},
    247    {doPair, "pair"},
    248    {doPass, "pass"},
    249    {doPath, "path"},
    250    {doPatQ, "pat?"},
    251    {doPeek, "peek"},
    252    {doPick, "pick"},
    253    {doPipe, "pipe"},
    254    {doPoll, "poll"},
    255    {doPool, "pool"},
    256    {doPop, "pop"},
    257    {doPort, "port"},
    258    {doPr, "pr"},
    259    {doPreQ, "pre?"},
    260    {doPrin, "prin"},
    261    {doPrinl, "prinl"},
    262    {doPrint, "print"},
    263    {doPrintln, "println"},
    264    {doPrintsp, "printsp"},
    265    {doPrior, "prior"},
    266    {doProg, "prog"},
    267    {doProg1, "prog1"},
    268    {doProg2, "prog2"},
    269    {doProp, "prop"},
    270    {doPropCol, "::"},
    271    {doProtect, "protect"},
    272    {doProve, "prove"},
    273    {doPush, "push"},
    274    {doPush1, "push1"},
    275    {doPut, "put"},
    276    {doPutl, "putl"},
    277    {doPwd, "pwd"},
    278    {doQueue, "queue"},
    279    {doQuit, "quit"},
    280    {doRand, "rand"},
    281    {doRange, "range"},
    282    {doRank, "rank"},
    283    {doRaw, "raw"},
    284    {doRd, "rd"},
    285    {doRead, "read"},
    286    {doRem, "%"},
    287    {doReplace, "replace"},
    288    {doRest, "rest"},
    289    {doReverse, "reverse"},
    290    {doRewind, "rewind"},
    291    {doRollback, "rollback"},
    292    {doRot, "rot"},
    293    {doRun, "run"},
    294    {doSect, "sect"},
    295    {doSeed, "seed"},
    296    {doSeek, "seek"},
    297    {doSemicol, ";"},
    298    {doSend, "send"},
    299    {doSeq, "seq"},
    300    {doSet, "set"},
    301    {doSetCol, "=:"},
    302    {doSetq, "setq"},
    303    {doShift, ">>"},
    304    {doSigio, "sigio"},
    305    {doSize, "size"},
    306    {doSkip, "skip"},
    307    {doSort, "sort"},
    308    {doSpace, "space"},
    309    {doSplit, "split"},
    310    {doSpQ, "sp?"},
    311    {doState, "state"},
    312    {doStem, "stem"},
    313    {doStr, "str"},
    314    {doStrip, "strip"},
    315    {doStrQ, "str?"},
    316    {doSub, "-"},
    317    {doSubQ, "sub?"},
    318    {doSum, "sum"},
    319    {doSuper, "super"},
    320    {doSym, "sym"},
    321    {doSymQ, "sym?"},
    322    {doSync, "sync"},
    323    {doSys, "sys"},
    324    {doT, "t"},
    325    {doTail, "tail"},
    326    {doTell, "tell"},
    327    {doText, "text"},
    328    {doThrow, "throw"},
    329    {doTick, "tick"},
    330    {doTill, "till"},
    331    {doTime, "time"},
    332    {doTouch, "touch"},
    333    {doTrace, "$"},
    334    {doTrim, "trim"},
    335    {doTry, "try"},
    336    {doType, "type"},
    337    {doUdp, "udp"},
    338    {doUnify, "unify"},
    339    {doUnless, "unless"},
    340    {doUntil, "until"},
    341    {doUp, "up"},
    342    {doUppQ, "upp?"},
    343    {doUppc, "uppc"},
    344    {doUse, "use"},
    345    {doUsec, "usec"},
    346    {doVal, "val"},
    347    {doVersion, "version"},
    348    {doWait, "wait"},
    349    {doWhen, "when"},
    350    {doWhile, "while"},
    351    {doWipe, "wipe"},
    352    {doWith, "with"},
    353    {doWr, "wr"},
    354    {doXchg, "xchg"},
    355    {doXor, "xor"},
    356    {doYoke, "yoke"},
    357    {doZap, "zap"},
    358    {doZero, "zero"},
    359 };
    360 
    361 static any initSym(any v, char *s) {
    362    any x, *h;
    363 
    364    h = Intern + ihash(x = mkName(s));
    365    x = consSym(v,x);
    366    *h = cons(x,*h);
    367    return x;
    368 }
    369 
    370 void initSymbols(void) {
    371    int i;
    372 
    373    Nil = symPtr(Avail),  Avail = Avail->car->car;  // Allocate 2 cells for NIL
    374    val(Nil) = tail(Nil) = val(Nil+1) = tail(Nil+1) = Nil;
    375    Zero = box(0);
    376    One = box(2);
    377    for (i = 0; i < IHASH; ++i)
    378       Intern[i] = Transient[i] = Nil;
    379    for (i = 0; i < EHASH; ++i)
    380       Extern[i] = Nil;
    381    initSym(mkStr(_OS), "*OS");
    382    DB    = initSym(Nil, "*DB");
    383    Meth  = initSym(box(num(doMeth)), "meth");
    384    Quote = initSym(box(num(doQuote)), "quote");
    385    T     = initSym(Nil, "T"),  val(T) = T;  // Last protected symbol
    386 
    387    mkExt(val(DB) = DbVal = consStr(DbTail = box('1')));
    388    Extern['1'] = cons(DbVal, Nil);
    389 
    390    Solo   = initSym(Zero, "*Solo");
    391    PPid   = initSym(Nil, "*PPid");
    392    Pid    = initSym(boxCnt(getpid()), "*Pid");
    393    At     = initSym(Nil, "@");
    394    At2    = initSym(Nil, "@@");
    395    At3    = initSym(Nil, "@@@");
    396    This   = initSym(Nil, "This");
    397    Prompt = initSym(Nil, "*Prompt");
    398    Dbg    = initSym(Nil, "*Dbg");
    399    Zap    = initSym(Nil, "*Zap");
    400    Ext    = initSym(Nil, "*Ext");
    401    Scl    = initSym(Zero, "*Scl");
    402    Class  = initSym(Nil, "*Class");
    403    Run    = initSym(Nil, "*Run");
    404    Hup    = initSym(Nil, "*Hup");
    405    Sig1   = initSym(Nil, "*Sig1");
    406    Sig2   = initSym(Nil, "*Sig2");
    407    Up     = initSym(Nil, "^");
    408    Err    = initSym(Nil, "*Err");
    409    Msg    = initSym(Nil, "*Msg");
    410    Uni    = initSym(Nil, "*Uni");
    411    Led    = initSym(Nil, "*Led");
    412    Tsm    = initSym(Nil, "*Tsm");
    413    Adr    = initSym(Nil, "*Adr");
    414    Fork   = initSym(Nil, "*Fork");
    415    Bye    = initSym(Nil, "*Bye");  // Last unremovable symbol
    416 
    417    for (i = 0; i < (int)(sizeof(Symbols)/sizeof(symInit)); ++i)
    418       initSym(box(num(Symbols[i].code)), Symbols[i].name);
    419 }