home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol162 / init.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1984-04-29  |  3.3 KB  |  137 lines

  1.  
  2. module symbol_table_initialization;
  3.  
  4. {$I global.inc}        { include global constants & types }
  5.  
  6. var
  7.    key: external array
  8.       [1.. nkw] of alfa;
  9.    ksy: external array
  10.       [1.. nkw] of symbol;
  11.    sps: external array
  12.       [char]    of symbol;            {special symbols}
  13.  
  14.    t, a, b, sx, c1, c2: external integer;    {identifier table}
  15.    tab: external  array
  16.       [0.. tmax] of                 {identifier table}
  17.    packed record
  18.           name: alfa;
  19.           link: index;
  20.           obj: object;
  21.           typ: types;
  22.           ref: index;
  23.           normal: boolean;
  24.           lev: 0.. lmax;
  25.           adr: integer;
  26.        end;
  27.  
  28. procedure enterstandardids(x0: alfa; x1: object; x2: types; x3: integer);
  29.  
  30.    begin
  31.       t := t +    1;
  32.       with tab[t] do
  33.       begin
  34.          name := x0;
  35.          link := t - 1;
  36.          obj := x1;
  37.          typ := x2;
  38.          ref := 0;
  39.          normal := true;
  40.          lev := 0;
  41.          adr := x3
  42.       end
  43.    end    {enter};
  44.  
  45.  
  46. procedure init_reserved_words;
  47.  
  48. begin
  49.    key[1] :=    'and       ';
  50.    key[2] :=    'array       ';
  51.    key[3] :=    'begin       ';
  52.    key[4] :=    'cobegin   ';
  53.    key[5] :=    'coend       ';
  54.    key[6] :=    'const       ';
  55.    key[7] :=    'div       ';
  56.    key[8] :=    'do       ';
  57.    key[9] :=    'else       ';
  58.    key[10] :=   'end       ';
  59.    key[11] :=   'for       ';
  60.    key[12] :=   'function  ';
  61.    key[13] :=   'if        ';
  62.    key[14] :=   'mod       ';
  63.    key[15] :=   'not       ';
  64.    key[16] :=   'of        ';
  65.    key[17] :=   'or        ';
  66.    key[18] :=   'procedure ';
  67.    key[19] :=   'program   ';
  68.    key[20] :=   'repeat    ';
  69.    key[21] :=   'then       ';
  70.    key[22] :=   'to       ';
  71.    key[23] :=   'type       ';
  72.    key[24] :=   'until       ';
  73.    key[25] :=   'var       ';
  74.    key[26] :=   'while     ';
  75.    ksy[1] :=    andsy;
  76.    ksy[2] :=    arraysy;
  77.    ksy[3] :=    beginsy;
  78.    ksy[4] :=    beginsy;
  79.    ksy[5] :=    endsy;
  80.    ksy[6] :=    constsy;
  81.    ksy[7] :=    idiv;
  82.    ksy[8] :=    dosy;
  83.    ksy[9] :=    elsesy;
  84.    ksy[10] := endsy;
  85.    ksy[11] := forsy;
  86.    ksy[12] := functionsy;
  87.    ksy[13] := ifsy;
  88.    ksy[14] := imod;
  89.    ksy[15] := notsy;
  90.    ksy[16] := ofsy;
  91.    ksy[17] := orsy;
  92.    ksy[18] := proceduresy;
  93.    ksy[19] := programsy;
  94.    ksy[20] := repeatsy;
  95.    ksy[21] := thensy;
  96.    ksy[22] := tosy;
  97.    ksy[23] := typesy;
  98.    ksy[24] := untilsy;
  99.    ksy[25] := varsy;
  100.    ksy[26] := whilesy;
  101.    sps['+'] := plus;
  102.    sps['-'] := minus;
  103.    sps['('] := lparent;
  104.    sps[')'] := rparent;
  105.    sps['='] := eql;
  106.    sps[','] := comma;
  107.    sps['[']:=lbrack;     
  108.    sps[']']:=rbrack;
  109.    sps['#'] := neq;
  110.    sps['&'] := andsy;
  111.    sps[';'] := semicolon;
  112.    sps['*'] := times;
  113. end;
  114.  
  115. procedure init_predefined_identifiers;
  116.  
  117. begin
  118.    enterstandardids('          ',variable, notyp, 0);    {sentinel}
  119.    enterstandardids('false     ',konstant, bools, 0);
  120.    enterstandardids('true      ',konstant, bools, 1);
  121.    enterstandardids('char      ',type1, chars, 1);
  122.    enterstandardids('boolean   ',type1, bools, 1);
  123.    enterstandardids('integer   ',type1, ints, 1);
  124.    enterstandardids('semaphore ',type1, ints, 1);
  125.    enterstandardids('eof       ',funktion, bools, 17);
  126.    enterstandardids('eoln      ',funktion, bools, 18);
  127.    enterstandardids('read      ',prozedure, notyp, 1);
  128.    enterstandardids('readln    ',prozedure, notyp, 2);
  129.    enterstandardids('write     ',prozedure, notyp, 3);
  130.    enterstandardids('writeln   ',prozedure, notyp, 4);
  131.    enterstandardids('wait      ',prozedure, notyp, 5);
  132.    enterstandardids('signal    ',prozedure, notyp, 6);
  133.    enterstandardids('          ',prozedure, notyp, 0);
  134. end;
  135.  
  136. modend.
  137.