home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Applications / P4⁄Mac 1.0 / Mac source / block.p next >
Encoding:
Text File  |  1994-07-28  |  74.6 KB  |  3,116 lines  |  [TEXT/PJMM]

  1. unit block;
  2.  
  3. interface
  4.     uses
  5.         pcom1, block1;
  6.  
  7. {De flesta subprocedurer till block är utbrytna, och block lägger upp sina parametrar globalt.}
  8. {TYVÄRR duger inte detta, ty BLOCK ÄR REKURSIV!!!}
  9.     procedure block (fsys: setofsys; fsy: symbol; fprocp: ctp);
  10.  
  11. implementation
  12.  
  13.     procedure block (fsys: setofsys; fsy: symbol; fprocp: ctp);
  14.  
  15.         procedure procdeclaration (fsy: symbol);
  16.             var
  17.                 oldlev: 0..maxlevel;
  18.                 lcp, lcp1: ctp;
  19.                 lsp: stp;
  20.                 forw: boolean;
  21.                 oldtop: disprange;
  22.                 llc, lcm: addrrange;
  23.                 lbname: integer;
  24.                 markp: marktype;
  25.  
  26.             procedure parameterlist (fsy: setofsys; var fpar: ctp);
  27.                 var
  28.                     lcp, lcp1, lcp2, lcp3: ctp;
  29.                     lsp: stp;
  30.                     lkind: idkind;
  31.                     llc, lsize: addrrange;
  32.                     count: integer;
  33.             begin
  34.                 lcp1 := nil;
  35.                 if not (sy in fsy + [lparent]) then
  36.                     begin
  37.                         error(7);
  38.                         skip(fsys + fsy + [lparent])
  39.                     end;
  40.                 if sy = lparent then
  41.                     begin
  42.                         if forw then
  43.                             error(119);
  44.                         insymbol;
  45.                         if not (sy in [ident, varsy, procsy, funcsy]) then
  46.                             begin
  47.                                 error(7);
  48.                                 skip(fsys + [ident, rparent])
  49.                             end;
  50.                         while sy in [ident, varsy, procsy, funcsy] do
  51.                             begin
  52.                                 if sy = procsy then
  53.                                     begin
  54.                                         error(399);
  55.                                         repeat
  56.                                             insymbol;
  57.                                             if sy = ident then
  58.                                                 begin
  59.                                                     new(lcp, proc, declared, formal);
  60.                                                     with lcp^ do
  61.                                                         begin
  62.                                                             name := id;
  63.                                                             idtype := nil;
  64.                                                             next := lcp1;
  65.                                                             pflev := level; (*beware of parameter procedures*)
  66.                                                             klass := proc;
  67.                                                             pfdeckind := declared;
  68.                                                             pfkind := formal
  69.                                                         end;
  70.                                                     enterid(lcp);
  71.                                                     lcp1 := lcp;
  72.                                                     align(parmptr, lc);
  73.               (*lc := lc + some size *)
  74.                                                     insymbol
  75.                                                 end
  76.                                             else
  77.                                                 error(2);
  78.                                             if not (sy in fsys + [comma, semicolon, rparent]) then
  79.                                                 begin
  80.                                                     error(7);
  81.                                                     skip(fsys + [comma, semicolon, rparent])
  82.                                                 end
  83.                                         until sy <> comma
  84.                                     end
  85.                                 else
  86.                                     begin
  87.                                         if sy = funcsy then
  88.                                             begin
  89.                                                 error(399);
  90.                                                 lcp2 := nil;
  91.                                                 repeat
  92.                                                     insymbol;
  93.                                                     if sy = ident then
  94.                                                         begin
  95.                                                             new(lcp, func, declared, formal);
  96.                                                             with lcp^ do
  97.                                                                 begin
  98.                                                                     name := id;
  99.                                                                     idtype := nil;
  100.                                                                     next := lcp2;
  101.                                                                     pflev := level; (*beware param funcs*)
  102.                                                                     klass := func;
  103.                                                                     pfdeckind := declared;
  104.                                                                     pfkind := formal
  105.                                                                 end;
  106.                                                             enterid(lcp);
  107.                                                             lcp2 := lcp;
  108.                                                             align(parmptr, lc);
  109.                  (*lc := lc + some size*)
  110.                                                             insymbol;
  111.                                                         end;
  112.                                                     if not (sy in [comma, colon] + fsys) then
  113.                                                         begin
  114.                                                             error(7);
  115.                                                             skip(fsys + [comma, semicolon, rparent])
  116.                                                         end
  117.                                                 until sy <> comma;
  118.                                                 if sy = colon then
  119.                                                     begin
  120.                                                         insymbol;
  121.                                                         if sy = ident then
  122.                                                             begin
  123.                                                                 searchid([types], lcp);
  124.                                                                 lsp := lcp^.idtype;
  125.                                                                 if lsp <> nil then
  126.                                                                     if not (lsp^.form in [scalar, subrange, pointer]) then
  127.                                                                         begin
  128.                                                                             error(120);
  129.                                                                             lsp := nil
  130.                                                                         end;
  131.                                                                 lcp3 := lcp2;
  132.                                                                 while lcp2 <> nil do
  133.                                                                     begin
  134.                                                                         lcp2^.idtype := lsp;
  135.                                                                         lcp := lcp2;
  136.                                                                         lcp2 := lcp2^.next
  137.                                                                     end;
  138.                                                                 lcp^.next := lcp1;
  139.                                                                 lcp1 := lcp3;
  140.                                                                 insymbol
  141.                                                             end
  142.                                                         else
  143.                                                             error(2);
  144.                                                         if not (sy in fsys + [semicolon, rparent]) then
  145.                                                             begin
  146.                                                                 error(7);
  147.                                                                 skip(fsys + [semicolon, rparent])
  148.                                                             end
  149.                                                     end
  150.                                                 else
  151.                                                     error(5)
  152.                                             end
  153.                                         else
  154.                                             begin
  155.                                                 if sy = varsy then
  156.                                                     begin
  157.                                                         lkind := formal;
  158.                                                         insymbol
  159.                                                     end
  160.                                                 else
  161.                                                     lkind := actual;
  162.                                                 lcp2 := nil;
  163.                                                 count := 0;
  164.                                                 repeat
  165.                                                     if sy = ident then
  166.                                                         begin
  167.                                                             new(lcp, vars);
  168.                                                             with lcp^ do
  169.                                                                 begin
  170.                                                                     name := id;
  171.                                                                     idtype := nil;
  172.                                                                     klass := vars;
  173.                                                                     vkind := lkind;
  174.                                                                     next := lcp2;
  175.                                                                     vlev := level;
  176.                                                                 end;
  177.                                                             enterid(lcp);
  178.                                                             lcp2 := lcp;
  179.                                                             count := count + 1;
  180.                                                             insymbol;
  181.                                                         end;
  182.                                                     if not (sy in [comma, colon] + fsys) then
  183.                                                         begin
  184.                                                             error(7);
  185.                                                             skip(fsys + [comma, semicolon, rparent])
  186.                                                         end;
  187.                                                     test := sy <> comma;
  188.                                                     if not test then
  189.                                                         insymbol
  190.                                                 until test;
  191.                                                 if sy = colon then
  192.                                                     begin
  193.                                                         insymbol;
  194.                                                         if sy = ident then
  195.                                                             begin
  196.                                                                 searchid([types], lcp);
  197.                                                                 lsp := lcp^.idtype;
  198.                                                                 lsize := ptrsize;
  199.                                                                 if lsp <> nil then
  200.                                                                     if lkind = actual then
  201.                                                                         if lsp^.form <= power then
  202.                                                                             lsize := lsp^.size
  203.                                                                         else if lsp^.form = files then
  204.                                                                             error(121);
  205.                                                                 align(parmptr, lsize);
  206.                                                                 lcp3 := lcp2;
  207.                                                                 align(parmptr, lc);
  208.                                                                 lc := lc + count * lsize;
  209.                                                                 llc := lc;
  210.                                                                 while lcp2 <> nil do
  211.                                                                     begin
  212.                                                                         lcp := lcp2;
  213.                                                                         with lcp2^ do
  214.                                                                             begin
  215.                                                                                 idtype := lsp;
  216.                                                                                 llc := llc - lsize;
  217.                                                                                 vaddr := llc;
  218.                                                                             end;
  219.                                                                         lcp2 := lcp2^.next
  220.                                                                     end;
  221.                                                                 lcp^.next := lcp1;
  222.                                                                 lcp1 := lcp3;
  223.                                                                 insymbol
  224.                                                             end
  225.                                                         else
  226.                                                             error(2);
  227.                                                         if not (sy in fsys + [semicolon, rparent]) then
  228.                                                             begin
  229.                                                                 error(7);
  230.                                                                 skip(fsys + [semicolon, rparent])
  231.                                                             end
  232.                                                     end
  233.                                                 else
  234.                                                     error(5);
  235.                                             end;
  236.                                     end;
  237.                                 if sy = semicolon then
  238.                                     begin
  239.                                         insymbol;
  240.                                         if not (sy in fsys + [ident, varsy, procsy, funcsy]) then
  241.                                             begin
  242.                                                 error(7);
  243.                                                 skip(fsys + [ident, rparent])
  244.                                             end
  245.                                     end
  246.                             end; (*while*)
  247.                         if sy = rparent then
  248.                             begin
  249.                                 insymbol;
  250.                                 if not (sy in fsy + fsys) then
  251.                                     begin
  252.                                         error(6);
  253.                                         skip(fsy + fsys)
  254.                                     end
  255.                             end
  256.                         else
  257.                             error(4);
  258.                         lcp3 := nil;
  259.         (*reverse pointers and reserve local cells for copies of multiple}
  260. {         values*)
  261.                         while lcp1 <> nil do
  262.                             with lcp1^ do
  263.                                 begin
  264.                                     lcp2 := next;
  265.                                     next := lcp3;
  266.                                     if klass = vars then
  267.                                         if idtype <> nil then
  268.                                             if (vkind = actual) and (idtype^.form > power) then
  269.                                                 begin
  270.                                                     align(idtype, lc);
  271.                                                     vaddr := lc;
  272.                                                     lc := lc + idtype^.size;
  273.                                                 end;
  274.                                     lcp3 := lcp1;
  275.                                     lcp1 := lcp2
  276.                                 end;
  277.                         fpar := lcp3
  278.                     end
  279.                 else
  280.                     fpar := nil
  281.             end; (*parameterlist*)
  282.  
  283.         begin (*procdeclaration*)
  284.             llc := lc;
  285.             lc := lcaftermarkstack;
  286.             forw := false;
  287.             if sy = ident then
  288.                 begin
  289.                     searchsection(display[top].fname, lcp); (*decide whether forw.*)
  290.                     if lcp <> nil then
  291.                         begin
  292.                             if lcp^.klass = proc then
  293.                                 forw := lcp^.forwdecl and (fsy = procsy) and (lcp^.pfkind = actual)
  294.                             else if lcp^.klass = func then
  295.                                 forw := lcp^.forwdecl and (fsy = funcsy) and (lcp^.pfkind = actual)
  296.                             else
  297.                                 forw := false;
  298.                             if not forw then
  299.                                 error(160)
  300.                         end;
  301.                     if not forw then
  302.                         begin
  303.                             if fsy = procsy then
  304.                                 new(lcp, proc, declared, actual)
  305.                             else
  306.                                 new(lcp, func, declared, actual);
  307.                             with lcp^ do
  308.                                 begin
  309.                                     name := id;
  310.                                     idtype := nil;
  311.                                     externl := false;
  312.                                     pflev := level;
  313.                                     genlabel(lbname);
  314.                                     pfdeckind := declared;
  315.                                     pfkind := actual;
  316.                                     pfname := lbname;
  317.                                     if fsy = procsy then
  318.                                         klass := proc
  319.                                     else
  320.                                         klass := func
  321.                                 end;
  322.                             enterid(lcp)
  323.                         end
  324.                     else
  325.                         begin
  326.                             lcp1 := lcp^.next;
  327.                             while lcp1 <> nil do
  328.                                 begin
  329.                                     with lcp1^ do
  330.                                         if klass = vars then
  331.                                             if idtype <> nil then
  332.                                                 begin
  333.                                                     lcm := vaddr + idtype^.size;
  334.                                                     if lcm > lc then
  335.                                                         lc := lcm
  336.                                                 end;
  337.                                     lcp1 := lcp1^.next
  338.                                 end
  339.                         end;
  340.                     insymbol
  341.                 end
  342.             else
  343.                 begin
  344.                     error(2);
  345.                     lcp := ufctptr
  346.                 end;
  347.             oldlev := level;
  348.             oldtop := top;
  349.             if level < maxlevel then
  350.                 level := level + 1
  351.             else
  352.                 error(251);
  353.             if top < displimit then
  354.                 begin
  355.                     top := top + 1;
  356.                     with display[top] do
  357.                         begin
  358.                             if forw then
  359.                                 fname := lcp^.next
  360.                             else
  361.                                 fname := nil;
  362.                             flabel := nil;
  363.                             occur := blck
  364.                         end
  365.                 end
  366.             else
  367.                 error(250);
  368.             if fsy = procsy then
  369.                 begin
  370.                     parameterlist([semicolon], lcp1);
  371.                     if not forw then
  372.                         lcp^.next := lcp1
  373.                 end
  374.             else
  375.                 begin
  376.                     parameterlist([semicolon, colon], lcp1);
  377.                     if not forw then
  378.                         lcp^.next := lcp1;
  379.                     if sy = colon then
  380.                         begin
  381.                             insymbol;
  382.                             if sy = ident then
  383.                                 begin
  384.                                     if forw then
  385.                                         error(122);
  386.                                     searchid([types], lcp1);
  387.                                     lsp := lcp1^.idtype;
  388.                                     lcp^.idtype := lsp;
  389.                                     if lsp <> nil then
  390.                                         if not (lsp^.form in [scalar, subrange, pointer]) then
  391.                                             begin
  392.                                                 error(120);
  393.                                                 lcp^.idtype := nil
  394.                                             end;
  395.                                     insymbol
  396.                                 end
  397.                             else
  398.                                 begin
  399.                                     error(2);
  400.                                     skip(fsys + [semicolon])
  401.                                 end
  402.                         end
  403.                     else if not forw then
  404.                         error(123)
  405.                 end;
  406.             if sy = semicolon then
  407.                 insymbol
  408.             else
  409.                 error(14);
  410.             if sy = forwardsy then
  411.                 begin
  412.                     if forw then
  413.                         error(161)
  414.                     else
  415.                         lcp^.forwdecl := true;
  416.                     insymbol;
  417.                     if sy = semicolon then
  418.                         insymbol
  419.                     else
  420.                         error(14);
  421.                     if not (sy in fsys) then
  422.                         begin
  423.                             error(6);
  424.                             skip(fsys)
  425.                         end
  426.                 end
  427.             else
  428.                 begin
  429.                     lcp^.forwdecl := false;
  430.                     mark(markp);
  431.                     repeat
  432.                         block(fsys, semicolon, lcp);
  433.                         if sy = semicolon then
  434.                             begin
  435.                                 if prtables then
  436.                                     printtables(false);
  437.                                 insymbol;
  438.                                 if not (sy in [beginsy, procsy, funcsy]) then
  439.                                     begin
  440.                                         error(6);
  441.                                         skip(fsys)
  442.                                     end
  443.                             end
  444.                         else
  445.                             error(14)
  446.                     until (sy in [beginsy, procsy, funcsy]) or eof(input);
  447.                     release(markp); (* return local entries on runtime heap *)
  448.                 end;
  449.             level := oldlev;
  450.             top := oldtop;
  451.             lc := llc;
  452.         end; (*procdeclaration*)
  453.  
  454.         procedure body (fsys: setofsys);
  455.             const
  456.                 cstoccmax = 65;
  457.                 cixmax = 1000;
  458.             type
  459.                 oprange = 0..63;
  460.             var
  461.                 llcp: ctp;
  462.                 saveid: alpha;
  463.                 cstptr: array[1..cstoccmax] of csp;
  464.                 cstptrix: 0..cstoccmax;
  465.       (*allows referencing of noninteger constants by an index}
  466. {       (instead of a pointer), which can be stored in the p2-field}
  467. {       of the instruction record until writeout.}
  468. {       --> procedure load, procedure writeout*)
  469.                 entname, segsize: integer;
  470.                 stacktop, topnew, topmax: integer;
  471.                 lcmax, llc1: addrrange;
  472.                 lcp: ctp;
  473.                 llp: lbp;
  474.  
  475.  
  476.             procedure mes (i: integer);
  477.             begin
  478.                 topnew := topnew + cdx[i] * maxstack;
  479.                 if topnew > topmax then
  480.                     topmax := topnew
  481.             end;
  482.  
  483.             procedure putic;
  484.             begin
  485.                 if ic mod 10 = 0 then
  486.                     writeln(prr, 'i', ic : 5)
  487.             end;
  488.  
  489.             procedure gen0 (fop: oprange);
  490.             begin
  491.                 if prcode then
  492.                     begin
  493.                         putic;
  494.                         writeln(prr, mn[fop] : 4)
  495.                     end;
  496.                 ic := ic + 1;
  497.                 mes(fop)
  498.             end; (*gen0*)
  499.  
  500.             procedure gen1 (fop: oprange; fp2: integer);
  501.                 var
  502.                     k: integer;
  503.             begin
  504.                 if prcode then
  505.                     begin
  506.                         putic;
  507.                         write(prr, mn[fop] : 4);
  508.                         if fop = 30 then
  509.                             begin
  510.                                 writeln(prr, sna[fp2] : 12);
  511.                                 topnew := topnew + pdx[fp2] * maxstack;
  512.                                 if topnew > topmax then
  513.                                     topmax := topnew
  514.                             end
  515.                         else
  516.                             begin
  517.                                 if fop = 38 then
  518.                                     begin
  519.                                         write(prr, '''');
  520.                                         with cstptr[fp2]^ do
  521.                                             begin
  522.                                                 for k := 1 to slgth do
  523.                                                     write(prr, sval[k] : 1);
  524.                                                 for k := slgth + 1 to strglgth do
  525.                                                     write(prr, ' ');
  526.                                             end;
  527.                                         writeln(prr, '''')
  528.                                     end
  529.                                 else if fop = 42 then
  530.                                     writeln(prr, chr(fp2))
  531.                                 else
  532.                                     writeln(prr, fp2 : 12);
  533.                                 mes(fop)
  534.                             end
  535.                     end;
  536.                 ic := ic + 1
  537.             end; (*gen1*)
  538.  
  539.             procedure gen2 (fop: oprange; fp1, fp2: integer);
  540.                 var
  541.                     k: integer;
  542.             begin
  543.                 if prcode then
  544.                     begin
  545.                         putic;
  546.                         write(prr, mn[fop] : 4);
  547.                         case fop of
  548.                             45, 50, 54, 56: 
  549.                                 writeln(prr, ' ', fp1 : 3, fp2 : 8);
  550.                             47, 48, 49, 52, 53, 55: 
  551.                                 begin
  552.                                     write(prr, chr(fp1));
  553.                                     if chr(fp1) = 'm' then
  554.                                         write(prr, fp2 : 11);
  555.                                     writeln(prr)
  556.                                 end;
  557.                             51: 
  558.                                 case fp1 of
  559.                                     1: 
  560.                                         writeln(prr, 'i ', fp2);
  561.                                     2: 
  562.                                         begin
  563.                                             write(prr, 'r ');
  564.                                             with cstptr[fp2]^ do
  565.                                                 for k := 1 to strglgth do
  566.                                                     write(prr, rval[k]);
  567.                                             writeln(prr)
  568.                                         end;
  569.                                     3: 
  570.                                         writeln(prr, 'b ', fp2);
  571.                                     4: 
  572.                                         writeln(prr, 'n');
  573.                                     6: 
  574.                                         writeln(prr, 'c ''' : 3, chr(fp2), '''');
  575.                                     5: 
  576.                                         begin
  577.                                             write(prr, '(');
  578.                                             with cstptr[fp2]^ do
  579.                                                 for k := setlow to sethigh do
  580.                                                     if k in pval then
  581.                                                         write(prr, k : 3);
  582.                                             writeln(prr, ')')
  583.                                         end
  584.                                 end
  585.                         end;
  586.                     end;
  587.                 ic := ic + 1;
  588.                 mes(fop)
  589.             end; (*gen2*)
  590.  
  591.             procedure gentypindicator (fsp: stp);
  592.             begin
  593.                 if fsp <> nil then
  594.                     with fsp^ do
  595.                         case form of
  596.                             scalar: 
  597.                                 if fsp = intptr then
  598.                                     write(prr, 'i')
  599.                                 else if fsp = boolptr then
  600.                                     write(prr, 'b')
  601.                                 else if fsp = charptr then
  602.                                     write(prr, 'c')
  603.                                 else if scalkind = declared then
  604.                                     write(prr, 'i')
  605.                                 else
  606.                                     write(prr, 'r');
  607.                             subrange: 
  608.                                 gentypindicator(rangetype);
  609.                             pointer: 
  610.                                 write(prr, 'a');
  611.                             power: 
  612.                                 write(prr, 's');
  613.                             records, arrays: 
  614.                                 write(prr, 'm');
  615.                             files, tagfld, variant: 
  616.                                 error(500)
  617.                         end
  618.             end; (*typindicator*)
  619.  
  620.             procedure gen0t (fop: oprange; fsp: stp);
  621.             begin
  622.                 if prcode then
  623.                     begin
  624.                         putic;
  625.                         write(prr, mn[fop] : 4);
  626.                         gentypindicator(fsp);
  627.                         writeln(prr);
  628.                     end;
  629.                 ic := ic + 1;
  630.                 mes(fop)
  631.             end; (*gen0t*)
  632.  
  633.             procedure gen1t (fop: oprange; fp2: integer; fsp: stp);
  634.             begin
  635.                 if prcode then
  636.                     begin
  637.                         putic;
  638.                         write(prr, mn[fop] : 4);
  639.                         gentypindicator(fsp);
  640.                         writeln(prr, fp2 : 11)
  641.                     end;
  642.                 ic := ic + 1;
  643.                 mes(fop)
  644.             end; (*gen1t*)
  645.  
  646.             procedure gen2t (fop: oprange; fp1, fp2: integer; fsp: stp);
  647.             begin
  648.                 if prcode then
  649.                     begin
  650.                         putic;
  651.                         write(prr, mn[fop] : 4);
  652.                         gentypindicator(fsp);
  653.                         writeln(prr, fp1 : 3 + 5 * ord(abs(fp1) > 99), fp2 : 8);
  654.                     end;
  655.                 ic := ic + 1;
  656.                 mes(fop)
  657.             end; (*gen2t*)
  658.  
  659.             procedure load;
  660.             begin
  661.                 with gattr do
  662.                     if typtr <> nil then
  663.                         begin
  664.                             case kind of
  665.                                 cst: 
  666.                                     if (typtr^.form = scalar) and (typtr <> realptr) then
  667.                                         if typtr = boolptr then
  668.                                             gen2(51, 3, cval.ival)(*ldc*)
  669.                                         else if typtr = charptr then
  670.                                             gen2(51, 6, cval.ival)(*ldc*)
  671.                                         else
  672.                                             gen2(51, 1, cval.ival)(*ldc*)
  673.                                     else if typtr = nilptr then
  674.                                         gen2(51, 4, 0)(*ldc*)
  675.                                     else if cstptrix >= cstoccmax then
  676.                                         error(254)
  677.                                     else
  678.                                         begin
  679.                                             cstptrix := cstptrix + 1;
  680.                                             cstptr[cstptrix] := cval.valp;
  681.                                             if typtr = realptr then
  682.                                                 gen2(51, 2, cstptrix)(*ldc*)
  683.                                             else
  684.                                                 gen2(51, 5, cstptrix)(*ldc*)
  685.                                         end;
  686.                                 varbl: 
  687.                                     case access of
  688.                                         drct: 
  689.                                             if vlevel <= 1 then
  690.                                                 gen1t(39, dplmt, typtr)(*ldo*)
  691.                                             else
  692.                                                 gen2t(54, level - vlevel, dplmt, typtr);(*lod*)
  693.                                         indrct: 
  694.                                             gen1t(35, idplmt, typtr);(*ind*)
  695.                                         inxd: 
  696.                                             error(400)
  697.                                     end;
  698.                                 expr: 
  699.                             end;
  700.                             kind := expr
  701.                         end
  702.             end; (*load*)
  703.  
  704.             procedure store (var fattr: attr);
  705.             begin
  706.                 with fattr do
  707.                     if typtr <> nil then
  708.                         case access of
  709.                             drct: 
  710.                                 if vlevel <= 1 then
  711.                                     gen1t(43, dplmt, typtr)(*sro*)
  712.                                 else
  713.                                     gen2t(56, level - vlevel, dplmt, typtr);(*str*)
  714.                             indrct: 
  715.                                 if idplmt <> 0 then
  716.                                     error(400)
  717.                                 else
  718.                                     gen0t(26, typtr);(*sto*)
  719.                             inxd: 
  720.                                 error(400)
  721.                         end
  722.             end; (*store*)
  723.  
  724.             procedure loadaddress;
  725.             begin
  726.                 with gattr do
  727.                     if typtr <> nil then
  728.                         begin
  729.                             case kind of
  730.                                 cst: 
  731.                                     if isString(typtr) then
  732.                                         if cstptrix >= cstoccmax then
  733.                                             error(254)
  734.                                         else
  735.                                             begin
  736.                                                 cstptrix := cstptrix + 1;
  737.                                                 cstptr[cstptrix] := cval.valp;
  738.                                                 gen1(38, cstptrix)(*lca*)
  739.                                             end
  740.                                     else
  741.                                         error(400);
  742.                                 varbl: 
  743.                                     case access of
  744.                                         drct: 
  745.                                             if vlevel <= 1 then
  746.                                                 gen1(37, dplmt)(*lao*)
  747.                                             else
  748.                                                 gen2(50, level - vlevel, dplmt);(*lda*)
  749.                                         indrct: 
  750.                                             if idplmt <> 0 then
  751.                                                 gen1t(34, idplmt, nilptr);(*inc*)
  752.                                         inxd: 
  753.                                             error(400)
  754.                                     end;
  755.                                 expr: 
  756.                                     error(400)
  757.                             end;
  758.                             kind := varbl;
  759.                             access := indrct;
  760.                             idplmt := 0
  761.                         end
  762.             end; (*loadaddress*)
  763.  
  764.  
  765.             procedure genfjp (faddr: integer);
  766.             begin
  767.                 load;
  768.                 if gattr.typtr <> nil then
  769.                     if gattr.typtr <> boolptr then
  770.                         error(144);
  771.                 if prcode then
  772.                     begin
  773.                         putic;
  774.                         writeln(prr, mn[33] : 4, ' l' : 8, faddr : 4)
  775.                     end;
  776.                 ic := ic + 1;
  777.                 mes(33)
  778.             end; (*genfjp*)
  779.  
  780.             procedure genujpxjp (fop: oprange; fp2: integer);
  781.             begin
  782.                 if prcode then
  783.                     begin
  784.                         putic;
  785.                         writeln(prr, mn[fop] : 4, ' l' : 8, fp2 : 4)
  786.                     end;
  787.                 ic := ic + 1;
  788.                 mes(fop)
  789.             end; (*genujpxjp*)
  790.  
  791.  
  792.             procedure gencupent (fop: oprange; fp1, fp2: integer);
  793.             begin
  794.                 if prcode then
  795.                     begin
  796.                         putic;
  797.                         writeln(prr, mn[fop] : 4, fp1 : 4, 'l' : 4, fp2 : 4)
  798.                     end;
  799.                 ic := ic + 1;
  800.                 mes(fop)
  801.             end;
  802.  
  803.  
  804.             procedure checkbnds (fsp: stp);
  805.                 var
  806.                     lmin, lmax: integer;
  807.             begin
  808.                 if fsp <> nil then
  809.                     if fsp <> intptr then
  810.                         if fsp <> realptr then
  811.                             if fsp^.form <= subrange then
  812.                                 begin
  813.                                     getbounds(fsp, lmin, lmax);
  814.                                     gen2t(45, lmin, lmax, fsp)(*chk*)
  815.                                 end
  816.             end; (*checkbnds*)
  817.  
  818.  
  819.             procedure putlabel (labname: integer);
  820.             begin
  821.                 if prcode then
  822.                     writeln(prr, 'l', labname : 4)
  823.             end; (*putlabel*)
  824.  
  825.             procedure statement (fsys: setofsys);
  826.                 label
  827.                     1;
  828.                 var
  829.                     lcp: ctp;
  830.                     llp: lbp;
  831.  
  832.                 procedure expression (fsys: setofsys);
  833.                 forward;
  834.  
  835.                 procedure selector (fsys: setofsys; fcp: ctp);
  836.                     var
  837.                         lattr: attr;
  838.                         lcp: ctp;
  839.                         lsize: addrrange;
  840.                         lmin, lmax: integer;
  841.                 begin
  842.                     with fcp^, gattr do
  843.                         begin
  844.                             typtr := idtype;
  845.                             kind := varbl;
  846.                             case klass of
  847.                                 vars: 
  848.                                     if vkind = actual then
  849.                                         begin
  850.                                             access := drct;
  851.                                             vlevel := vlev;
  852.                                             dplmt := vaddr
  853.                                         end
  854.                                     else
  855.                                         begin
  856.                                             gen2t(54, level - vlev, vaddr, nilptr);(*lod*)
  857.                                             access := indrct;
  858.                                             idplmt := 0
  859.                                         end;
  860.                                 field: 
  861.                                     with display[disx] do
  862.                                         if occur = crec then
  863.                                             begin
  864.                                                 access := drct;
  865.                                                 vlevel := clev;
  866.                                                 dplmt := cdspl + fldaddr
  867.                                             end
  868.                                         else
  869.                                             begin
  870.                                                 if level = 1 then
  871.                                                     gen1t(39, vdspl, nilptr)(*ldo*)
  872.                                                 else
  873.                                                     gen2t(54, 0, vdspl, nilptr);(*lod*)
  874.                                                 access := indrct;
  875.                                                 idplmt := fldaddr
  876.                                             end;
  877.                                 func: 
  878.                                     if pfdeckind = standard then
  879.                                         begin
  880.                                             error(150);
  881.                                             typtr := nil
  882.                                         end
  883.                                     else
  884.                                         begin
  885.                                             if pfkind = formal then
  886.                                                 error(151)
  887.                                             else if (pflev + 1 <> level) or (fprocp <> fcp) then
  888.                                                 error(177);
  889.                                             begin
  890.                                                 access := drct;
  891.                                                 vlevel := pflev + 1;
  892.                                                 dplmt := 0   (*impl. relat. addr. of fct. result*)
  893.                                             end
  894.                                         end
  895.                             end (*case*)
  896.                         end; (*with*)
  897.                     if not (sy in selectsys + fsys) then
  898.                         begin
  899.                             error(59);
  900.                             skip(selectsys + fsys)
  901.                         end;
  902.                     while sy in selectsys do
  903.                         begin
  904.     (*[*)
  905.                             if sy = lbrack then
  906.                                 begin
  907.                                     repeat
  908.                                         lattr := gattr;
  909.                                         with lattr do
  910.                                             if typtr <> nil then
  911.                                                 if typtr^.form <> arrays then
  912.                                                     begin
  913.                                                         error(138);
  914.                                                         typtr := nil
  915.                                                     end;
  916.                                         loadaddress;
  917.                                         insymbol;
  918.                                         expression(fsys + [comma, rbrack]);
  919.                                         load;
  920.                                         if gattr.typtr <> nil then
  921.                                             if gattr.typtr^.form <> scalar then
  922.                                                 error(113)
  923.                                             else if not comptypes(gattr.typtr, intptr) then
  924.                                                 gen0t(58, gattr.typtr);(*ord*)
  925.                                         if lattr.typtr <> nil then
  926.                                             with lattr.typtr^ do
  927.                                                 begin
  928.                                                     if comptypes(inxtype, gattr.typtr) then
  929.                                                         begin
  930.                                                             if inxtype <> nil then
  931.                                                                 begin
  932.                                                                     getbounds(inxtype, lmin, lmax);
  933.                                                                     if debug then
  934.                                                                         gen2t(45, lmin, lmax, intptr);(*chk*)
  935.                                                                     if lmin > 0 then
  936.                                                                         gen1t(31, lmin, intptr)(*dec*)
  937.                                                                     else if lmin < 0 then
  938.                                                                         gen1t(34, -lmin, intptr);(*inc*)
  939.                   (*or simply gen1(31,lmin)*)
  940.                                                                 end
  941.                                                         end
  942.                                                     else
  943.                                                         error(139);
  944.                                                     with gattr do
  945.                                                         begin
  946.                                                             typtr := aeltype;
  947.                                                             kind := varbl;
  948.                                                             access := indrct;
  949.                                                             idplmt := 0
  950.                                                         end;
  951.                                                     if gattr.typtr <> nil then
  952.                                                         begin
  953.                                                             lsize := gattr.typtr^.size;
  954.                                                             align(gattr.typtr, lsize);
  955.                                                             gen1(36, lsize)(*ixa*)
  956.                                                         end
  957.                                                 end
  958.                                     until sy <> comma;
  959.                                     if sy = rbrack then
  960.                                         insymbol
  961.                                     else
  962.                                         error(12)
  963.                                 end (*if sy = lbrack*)
  964.                             else
  965.     (*.*)
  966.                                 if sy = period then
  967.                                     begin
  968.                                         with gattr do
  969.                                             begin
  970.                                                 if typtr <> nil then
  971.                                                     if typtr^.form <> records then
  972.                                                         begin
  973.                                                             error(140);
  974.                                                             typtr := nil
  975.                                                         end;
  976.                                                 insymbol;
  977.                                                 if sy = ident then
  978.                                                     begin
  979.                                                         if typtr <> nil then
  980.                                                             begin
  981.                                                                 searchsection(typtr^.fstfld, lcp);
  982.                                                                 if lcp = nil then
  983.                                                                     begin
  984.                                                                         error(152);
  985.                                                                         typtr := nil
  986.                                                                     end
  987.                                                                 else
  988.                                                                     with lcp^ do
  989.                                                                         begin
  990.                                                                             typtr := idtype;
  991.                                                                             case access of
  992.                                                                                 drct: 
  993.                                                                                     dplmt := dplmt + fldaddr;
  994.                                                                                 indrct: 
  995.                                                                                     idplmt := idplmt + fldaddr;
  996.                                                                                 inxd: 
  997.                                                                                     error(400)
  998.                                                                             end
  999.                                                                         end
  1000.                                                             end;
  1001.                                                         insymbol
  1002.                                                     end (*sy = ident*)
  1003.                                                 else
  1004.                                                     error(2)
  1005.                                             end (*with gattr*)
  1006.                                     end (*if sy = period*)
  1007.                                 else
  1008.     (*^*)
  1009.                                     begin
  1010.                                         if gattr.typtr <> nil then
  1011.                                             with gattr, typtr^ do
  1012.                                                 if form = pointer then
  1013.                                                     begin
  1014.                                                         load;
  1015.                                                         typtr := eltype;
  1016.                                                         if debug then
  1017.                                                             gen2t(45, 1, maxaddr, nilptr);(*chk*)
  1018.                                                         with gattr do
  1019.                                                             begin
  1020.                                                                 kind := varbl;
  1021.                                                                 access := indrct;
  1022.                                                                 idplmt := 0
  1023.                                                             end
  1024.                                                     end
  1025.                                                 else if form = files then
  1026.                                                     typtr := filtype
  1027.                                                 else
  1028.                                                     error(141);
  1029.                                         insymbol
  1030.                                     end;
  1031.                             if not (sy in fsys + selectsys) then
  1032.                                 begin
  1033.                                     error(6);
  1034.                                     skip(fsys + selectsys)
  1035.                                 end
  1036.                         end (*while*)
  1037.                 end; (*selector*)
  1038.  
  1039.                 procedure call (fsys: setofsys; fcp: ctp);
  1040.                     var
  1041.                         lkey: 1..15;
  1042.  
  1043.                     procedure variable (fsys: setofsys);
  1044.                         var
  1045.                             lcp: ctp;
  1046.                     begin
  1047.                         if sy = ident then
  1048.                             begin
  1049.                                 searchid([vars, field], lcp);
  1050.                                 insymbol
  1051.                             end
  1052.                         else
  1053.                             begin
  1054.                                 error(2);
  1055.                                 lcp := uvarptr
  1056.                             end;
  1057.                         selector(fsys, lcp)
  1058.                     end; (*variable*)
  1059.  
  1060.                     procedure getputresetrewrite;
  1061.                     begin
  1062.                         variable(fsys + [rparent]);
  1063.                         loadaddress;
  1064.                         if gattr.typtr <> nil then
  1065.                             if gattr.typtr^.form <> files then
  1066.                                 error(116);
  1067.                         if lkey <= 2 then
  1068.                             gen1(30, lkey)(*csp*)
  1069. (*get,put*)
  1070.                         else
  1071.                             error(399)
  1072.                     end; (*getputresetrewrite*)
  1073.  
  1074.                     procedure read;
  1075.                         var
  1076.                             llev: levrange;
  1077.                             laddr: addrrange;
  1078.                             lsp: stp;
  1079.                     begin
  1080.                         llev := 1;
  1081.                         laddr := lcaftermarkstack;
  1082.                         if sy = lparent then
  1083.                             begin
  1084.                                 insymbol;
  1085.                                 variable(fsys + [comma, rparent]);
  1086.                                 lsp := gattr.typtr;
  1087.                                 test := false;
  1088.                                 if lsp <> nil then
  1089.                                     if lsp^.form = files then
  1090.                                         with gattr, lsp^ do
  1091.                                             begin
  1092.                                                 if filtype = charptr then
  1093.                                                     begin
  1094.                                                         llev := vlevel;
  1095.                                                         laddr := dplmt
  1096.                                                     end
  1097.                                                 else
  1098.                                                     error(399);
  1099.                                                 if sy = rparent then
  1100.                                                     begin
  1101.                                                         if lkey = 5 then
  1102.                                                             error(116);
  1103.                                                         test := true
  1104.                                                     end
  1105.                                                 else if sy <> comma then
  1106.                                                     begin
  1107.                                                         error(116);
  1108.                                                         skip(fsys + [comma, rparent])
  1109.                                                     end;
  1110.                                                 if sy = comma then
  1111.                                                     begin
  1112.                                                         insymbol;
  1113.                                                         variable(fsys + [comma, rparent])
  1114.                                                     end
  1115.                                                 else
  1116.                                                     test := true
  1117.                                             end;
  1118.                                 if not test then
  1119.                                     repeat
  1120.                                         loadaddress;
  1121.                                         gen2(50, level - llev, laddr);(*lda*)
  1122.                                         if gattr.typtr <> nil then
  1123.                                             if gattr.typtr^.form <= subrange then
  1124.                                                 if comptypes(intptr, gattr.typtr) then
  1125.                                                     gen1(30, 3)(*csp*)
  1126. (*rdi*)
  1127.                                                 else if comptypes(realptr, gattr.typtr) then
  1128.                                                     gen1(30, 4)(*csp*)
  1129. (*rdr*)
  1130.                                                 else if comptypes(charptr, gattr.typtr) then
  1131.                                                     gen1(30, 5)(*csp*)
  1132. (*rdc*)
  1133.                                                 else
  1134.                                                     error(399)
  1135.                                             else
  1136.                                                 error(116);
  1137.                                         test := sy <> comma;
  1138.                                         if not test then
  1139.                                             begin
  1140.                                                 insymbol;
  1141.                                                 variable(fsys + [comma, rparent])
  1142.                                             end
  1143.                                     until test;
  1144.                                 if sy = rparent then
  1145.                                     insymbol
  1146.                                 else
  1147.                                     error(4)
  1148.                             end
  1149.                         else if lkey = 5 then
  1150.                             error(116);
  1151.                         if lkey = 11 then
  1152.                             begin
  1153.                                 gen2(50, level - llev, laddr);(*lda*)
  1154.                                 gen1(30, 21)(*csp*)
  1155. (*rln*)
  1156.                             end
  1157.                     end; (*read*)
  1158.  
  1159.                     procedure write;
  1160.                         var
  1161.                             lsp: stp;
  1162.                             default: boolean;
  1163.                             llkey: 1..15;
  1164.                             llev: levrange;
  1165.                             laddr, len: addrrange;
  1166.                     begin
  1167.                         llkey := lkey;
  1168.                         llev := 1;
  1169.                         laddr := lcaftermarkstack + charmax;
  1170.                         if sy = lparent then
  1171.                             begin
  1172.                                 insymbol;
  1173.                                 expression(fsys + [comma, colon, rparent]);
  1174.                                 lsp := gattr.typtr;
  1175.                                 test := false;
  1176.                                 if lsp <> nil then
  1177.                                     if lsp^.form = files then
  1178.                                         with gattr, lsp^ do
  1179.                                             begin
  1180.                                                 if filtype = charptr then
  1181.                                                     begin
  1182.                                                         llev := vlevel;
  1183.                                                         laddr := dplmt
  1184.                                                     end
  1185.                                                 else
  1186.                                                     error(399);
  1187.                                                 if sy = rparent then
  1188.                                                     begin
  1189.                                                         if llkey = 6 then
  1190.                                                             error(116);
  1191.                                                         test := true
  1192.                                                     end
  1193.                                                 else if sy <> comma then
  1194.                                                     begin
  1195.                                                         error(116);
  1196.                                                         skip(fsys + [comma, rparent])
  1197.                                                     end;
  1198.                                                 if sy = comma then
  1199.                                                     begin
  1200.                                                         insymbol;
  1201.                                                         expression(fsys + [comma, colon, rparent])
  1202.                                                     end
  1203.                                                 else
  1204.                                                     test := true
  1205.                                             end;
  1206.                                 if not test then
  1207.                                     repeat
  1208.                                         lsp := gattr.typtr;
  1209.                                         if lsp <> nil then
  1210.                                             if lsp^.form <= subrange then
  1211.                                                 load
  1212.                                             else
  1213.                                                 loadaddress;
  1214.                                         if sy = colon then
  1215.                                             begin
  1216.                                                 insymbol;
  1217.                                                 expression(fsys + [comma, colon, rparent]);
  1218.                                                 if gattr.typtr <> nil then
  1219.                                                     if gattr.typtr <> intptr then
  1220.                                                         error(116);
  1221.                                                 load;
  1222.                                                 default := false
  1223.                                             end
  1224.                                         else
  1225.                                             default := true;
  1226.                                         if sy = colon then
  1227.                                             begin
  1228.                                                 insymbol;
  1229.                                                 expression(fsys + [comma, rparent]);
  1230.                                                 if gattr.typtr <> nil then
  1231.                                                     if gattr.typtr <> intptr then
  1232.                                                         error(116);
  1233.                                                 if lsp <> realptr then
  1234.                                                     error(124);
  1235.                                                 load;
  1236.                                                 error(399);
  1237.                                             end
  1238.                                         else if lsp = intptr then
  1239.                                             begin
  1240.                                                 if default then
  1241.                                                     gen2(51, 1, 10);(*ldc*)
  1242.                                                 gen2(50, level - llev, laddr);(*lda*)
  1243.                                                 gen1(30, 6)(*csp*)
  1244. (*wri*)
  1245.                                             end
  1246.                                         else if lsp = realptr then
  1247.                                             begin
  1248.                                                 if default then
  1249.                                                     gen2(51, 1, 20);(*ldc*)
  1250.                                                 gen2(50, level - llev, laddr);(*lda*)
  1251.                                                 gen1(30, 8)(*csp*)
  1252. (*wrr*)
  1253.                                             end
  1254.                                         else if lsp = charptr then
  1255.                                             begin
  1256.                                                 if default then
  1257.                                                     gen2(51, 1, 1);(*ldc*)
  1258.                                                 gen2(50, level - llev, laddr);(*lda*)
  1259.                                                 gen1(30, 9)(*csp*)
  1260. (*wrc*)
  1261.                                             end
  1262.                                         else if lsp <> nil then
  1263.                                             begin
  1264.                                                 if lsp^.form = scalar then
  1265.                                                     error(399)
  1266.                                                 else if isString(lsp) then
  1267.                                                     begin
  1268.                                                         len := lsp^.size div charmax;
  1269.                                                         if default then
  1270.                                                             gen2(51, 1, len);(*ldc*)
  1271.                                                         gen2(51, 1, len);(*ldc*)
  1272.                                                         gen2(50, level - llev, laddr);(*lda*)
  1273.                                                         gen1(30, 10)(*csp*)
  1274. (*wrs*)
  1275.                                                     end
  1276.                                                 else
  1277.                                                     error(116)
  1278.                                             end;
  1279.                                         test := sy <> comma;
  1280.                                         if not test then
  1281.                                             begin
  1282.                                                 insymbol;
  1283.                                                 expression(fsys + [comma, colon, rparent])
  1284.                                             end
  1285.                                     until test;
  1286.                                 if sy = rparent then
  1287.                                     insymbol
  1288.                                 else
  1289.                                     error(4)
  1290.                             end
  1291.                         else if lkey = 6 then
  1292.                             error(116);
  1293.                         if llkey = 12 then (*writeln*)
  1294.                             begin
  1295.                                 gen2(50, level - llev, laddr);(*lda*)
  1296.                                 gen1(30, 22)(*csp*)
  1297. (*wln*)
  1298.                             end
  1299.                     end; (*write*)
  1300.  
  1301.                     procedure pack;
  1302.                         var
  1303.                             lsp, lsp1: stp;
  1304.                     begin
  1305.                         error(399);
  1306.                         variable(fsys + [comma, rparent]);
  1307.                         lsp := nil;
  1308.                         lsp1 := nil;
  1309.                         if gattr.typtr <> nil then
  1310.                             with gattr.typtr^ do
  1311.                                 if form = arrays then
  1312.                                     begin
  1313.                                         lsp := inxtype;
  1314.                                         lsp1 := aeltype
  1315.                                     end
  1316.                                 else
  1317.                                     error(116);
  1318.                         if sy = comma then
  1319.                             insymbol
  1320.                         else
  1321.                             error(20);
  1322.                         expression(fsys + [comma, rparent]);
  1323.                         if gattr.typtr <> nil then
  1324.                             if gattr.typtr^.form <> scalar then
  1325.                                 error(116)
  1326.                             else if not comptypes(lsp, gattr.typtr) then
  1327.                                 error(116);
  1328.                         if sy = comma then
  1329.                             insymbol
  1330.                         else
  1331.                             error(20);
  1332.                         variable(fsys + [rparent]);
  1333.                         if gattr.typtr <> nil then
  1334.                             with gattr.typtr^ do
  1335.                                 if form = arrays then
  1336.                                     begin
  1337.                                         if not comptypes(aeltype, lsp1) or not comptypes(inxtype, lsp) then
  1338.                                             error(116)
  1339.                                     end
  1340.                                 else
  1341.                                     error(116)
  1342.                     end; (*pack*)
  1343.  
  1344.                     procedure unpack;
  1345.                         var
  1346.                             lsp, lsp1: stp;
  1347.                     begin
  1348.                         error(399);
  1349.                         variable(fsys + [comma, rparent]);
  1350.                         lsp := nil;
  1351.                         lsp1 := nil;
  1352.                         if gattr.typtr <> nil then
  1353.                             with gattr.typtr^ do
  1354.                                 if form = arrays then
  1355.                                     begin
  1356.                                         lsp := inxtype;
  1357.                                         lsp1 := aeltype
  1358.                                     end
  1359.                                 else
  1360.                                     error(116);
  1361.                         if sy = comma then
  1362.                             insymbol
  1363.                         else
  1364.                             error(20);
  1365.                         variable(fsys + [comma, rparent]);
  1366.                         if gattr.typtr <> nil then
  1367.                             with gattr.typtr^ do
  1368.                                 if form = arrays then
  1369.                                     begin
  1370.                                         if not comptypes(aeltype, lsp1) or not comptypes(inxtype, lsp) then
  1371.                                             error(116)
  1372.                                     end
  1373.                                 else
  1374.                                     error(116);
  1375.                         if sy = comma then
  1376.                             insymbol
  1377.                         else
  1378.                             error(20);
  1379.                         expression(fsys + [rparent]);
  1380.                         if gattr.typtr <> nil then
  1381.                             if gattr.typtr^.form <> scalar then
  1382.                                 error(116)
  1383.                             else if not comptypes(lsp, gattr.typtr) then
  1384.                                 error(116);
  1385.                     end; (*unpack*)
  1386.  
  1387.                     procedure new;
  1388.                         label
  1389.                             1;
  1390.                         var
  1391.                             lsp, lsp1: stp;
  1392.                             varts: integer;
  1393.                             lsize: addrrange;
  1394.                             lval: valu;
  1395.                     begin
  1396.                         variable(fsys + [comma, rparent]);
  1397.                         loadaddress;
  1398.                         lsp := nil;
  1399.                         varts := 0;
  1400.                         lsize := 0;
  1401.                         if gattr.typtr <> nil then
  1402.                             with gattr.typtr^ do
  1403.                                 if form = pointer then
  1404.                                     begin
  1405.                                         if eltype <> nil then
  1406.                                             begin
  1407.                                                 lsize := eltype^.size;
  1408.                                                 if eltype^.form = records then
  1409.                                                     lsp := eltype^.recvar
  1410.                                             end
  1411.                                     end
  1412.                                 else
  1413.                                     error(116);
  1414.                         while sy = comma do
  1415.                             begin
  1416.                                 insymbol;
  1417.                                 Bconstant(fsys + [comma, rparent], lsp1, lval);
  1418.                                 varts := varts + 1;
  1419.         (*check to insert here: is constant in tagfieldtype range*)
  1420.                                 if lsp = nil then
  1421.                                     error(158)
  1422.                                 else if lsp^.form <> tagfld then
  1423.                                     error(162)
  1424.                                 else if lsp^.tagfieldp <> nil then
  1425.                                     if isString(lsp1) or (lsp1 = realptr) then
  1426.                                         error(159)
  1427.                                     else if comptypes(lsp^.tagfieldp^.idtype, lsp1) then
  1428.                                         begin
  1429.                                             lsp1 := lsp^.fstvar;
  1430.                                             while lsp1 <> nil do
  1431.                                                 with lsp1^ do
  1432.                                                     if varval.ival = lval.ival then
  1433.                                                         begin
  1434.                                                             lsize := size;
  1435.                                                             lsp := subvar;
  1436.                                                             goto 1
  1437.                                                         end
  1438.                                                     else
  1439.                                                         lsp1 := nxtvar;
  1440.                                             lsize := lsp^.size;
  1441.                                             lsp := nil;
  1442.                                         end
  1443.                                     else
  1444.                                         error(116);
  1445. 1:
  1446.                             end; (*while*)
  1447.                         gen2(51, 1, lsize);(*ldc*)
  1448.                         gen1(30, 12);(*csp*)
  1449. (*new*)
  1450.                     end; (*new*)
  1451.  
  1452.                     procedure mark;
  1453.                     begin
  1454.                         variable(fsys + [rparent]);
  1455.                         if gattr.typtr <> nil then
  1456.                             if gattr.typtr^.form = pointer then
  1457.                                 begin
  1458.                                     loadaddress;
  1459.                                     gen1(30, 23)(*csp*)
  1460. (*sav*)
  1461.                                 end
  1462.                             else
  1463.                                 error(116)
  1464.                     end;(*mark*)
  1465.  
  1466.                     procedure release;
  1467.                     begin
  1468.                         variable(fsys + [rparent]);
  1469.                         if gattr.typtr <> nil then
  1470.                             if gattr.typtr^.form = pointer then
  1471.                                 begin
  1472.                                     load;
  1473.                                     gen1(30, 13)(*csp*)
  1474. (*rst*)
  1475.                                 end
  1476.                             else
  1477.                                 error(116)
  1478.                     end; (*release*)
  1479.  
  1480.  
  1481.  
  1482.                     procedure abs;
  1483.                     begin
  1484.                         if gattr.typtr <> nil then
  1485.                             if gattr.typtr = intptr then
  1486.                                 gen0(0)(*abi*)
  1487.                             else if gattr.typtr = realptr then
  1488.                                 gen0(1)(*abr*)
  1489.                             else
  1490.                                 begin
  1491.                                     error(125);
  1492.                                     gattr.typtr := intptr
  1493.                                 end
  1494.                     end; (*abs*)
  1495.  
  1496.                     procedure sqr;
  1497.                     begin
  1498.                         if gattr.typtr <> nil then
  1499.                             if gattr.typtr = intptr then
  1500.                                 gen0(24)(*sqi*)
  1501.                             else if gattr.typtr = realptr then
  1502.                                 gen0(25)(*sqr*)
  1503.                             else
  1504.                                 begin
  1505.                                     error(125);
  1506.                                     gattr.typtr := intptr
  1507.                                 end
  1508.                     end; (*sqr*)
  1509.  
  1510.                     procedure trunc;
  1511.                     begin
  1512.                         if gattr.typtr <> nil then
  1513.                             if gattr.typtr <> realptr then
  1514.                                 error(125);
  1515.                         gen0(27);(*trc*)
  1516.                         gattr.typtr := intptr
  1517.                     end; (*trunc*)
  1518.  
  1519.                     procedure odd;
  1520.                     begin
  1521.                         if gattr.typtr <> nil then
  1522.                             if gattr.typtr <> intptr then
  1523.                                 error(125);
  1524.                         gen0(20);(*odd*)
  1525.                         gattr.typtr := boolptr
  1526.                     end; (*odd*)
  1527.  
  1528.                     procedure ord;
  1529.                     begin
  1530.                         if gattr.typtr <> nil then
  1531.                             if gattr.typtr^.form >= power then
  1532.                                 error(125);
  1533.                         gen0t(58, gattr.typtr);(*ord*)
  1534.                         gattr.typtr := intptr
  1535.                     end; (*ord*)
  1536.  
  1537.                     procedure chr;
  1538.                     begin
  1539.                         if gattr.typtr <> nil then
  1540.                             if gattr.typtr <> intptr then
  1541.                                 error(125);
  1542.                         gen0(59);(*chr*)
  1543.                         gattr.typtr := charptr
  1544.                     end; (*chr*)
  1545.  
  1546.                     procedure predsucc;
  1547.                     begin
  1548.                         if gattr.typtr <> nil then
  1549.                             if gattr.typtr^.form <> scalar then
  1550.                                 error(125);
  1551.                         if lkey = 7 then
  1552.                             gen1t(31, 1, gattr.typtr)(*dec*)
  1553.                         else
  1554.                             gen1t(34, 1, gattr.typtr)(*inc*)
  1555.                     end; (*predsucc*)
  1556.  
  1557.                     procedure eof;
  1558.                     begin
  1559.                         if sy = lparent then
  1560.                             begin
  1561.                                 insymbol;
  1562.                                 variable(fsys + [rparent]);
  1563.                                 if sy = rparent then
  1564.                                     insymbol
  1565.                                 else
  1566.                                     error(4)
  1567.                             end
  1568.                         else
  1569.                             with gattr do
  1570.                                 begin
  1571.                                     typtr := textptr;
  1572.                                     kind := varbl;
  1573.                                     access := drct;
  1574.                                     vlevel := 1;
  1575.                                     dplmt := lcaftermarkstack
  1576.                                 end;
  1577.                         loadaddress;
  1578.                         if gattr.typtr <> nil then
  1579.                             if gattr.typtr^.form <> files then
  1580.                                 error(125);
  1581.                         if lkey = 9 then
  1582.                             gen0(8)(*eof*)
  1583.                         else
  1584.                             gen1(30, 14);(*csp*)
  1585. (*eln*)
  1586.                         gattr.typtr := boolptr
  1587.                     end; (*eof*)
  1588.  
  1589.  
  1590.  
  1591.                     procedure callnonstandard;
  1592.                         var
  1593.                             nxt, lcp: ctp;
  1594.                             lsp: stp;
  1595.                             lkind: idkind;
  1596.                             lb: boolean;
  1597.                             locpar, llc: addrrange;
  1598.                     begin
  1599.                         locpar := 0;
  1600.                         with fcp^ do
  1601.                             begin
  1602.                                 nxt := next;
  1603.                                 lkind := pfkind;
  1604.                                 if not externl then
  1605.                                     gen1(41, level - pflev)(*mst*)
  1606.                             end;
  1607.                         if sy = lparent then
  1608.                             begin
  1609.                                 llc := lc;
  1610.                                 repeat
  1611.                                     lb := false; (*decide whether proc/func must be passed*)
  1612.                                     if lkind = actual then
  1613.                                         begin
  1614.                                             if nxt = nil then
  1615.                                                 error(126)
  1616.                                             else
  1617.                                                 lb := nxt^.klass in [proc, func]
  1618.                                         end
  1619.                                     else
  1620.                                         error(399);
  1621.           (*For formal proc/func, lb is false and expression}
  1622. {           will be called, which will always interpret a proc/func id}
  1623. {           at its beginning as a call rather than a parameter passing.}
  1624. {           In this implementation, parameter procedures/functions}
  1625. {           are therefore not allowed to have procedure/function}
  1626. {           parameters*)
  1627.                                     insymbol;
  1628.                                     if lb then   (*pass function or procedure*)
  1629.                                         begin
  1630.                                             error(399);
  1631.                                             if sy <> ident then
  1632.                                                 begin
  1633.                                                     error(2);
  1634.                                                     skip(fsys + [comma, rparent])
  1635.                                                 end
  1636.                                             else
  1637.                                                 begin
  1638.                                                     if nxt^.klass = proc then
  1639.                                                         searchid([proc], lcp)
  1640.                                                     else
  1641.                                                         begin
  1642.                                                             searchid([func], lcp);
  1643.                                                             if not comptypes(lcp^.idtype, nxt^.idtype) then
  1644.                                                                 error(128)
  1645.                                                         end;
  1646.                                                     insymbol;
  1647.                                                     if not (sy in fsys + [comma, rparent]) then
  1648.                                                         begin
  1649.                                                             error(6);
  1650.                                                             skip(fsys + [comma, rparent])
  1651.                                                         end
  1652.                                                 end
  1653.                                         end (*if lb*)
  1654.                                     else
  1655.                                         begin
  1656.                                             expression(fsys + [comma, rparent]);
  1657.                                             if gattr.typtr <> nil then
  1658.                                                 if lkind = actual then
  1659.                                                     begin
  1660.                                                         if nxt <> nil then
  1661.                                                             begin
  1662.                                                                 lsp := nxt^.idtype;
  1663.                                                                 if lsp <> nil then
  1664.                                                                     begin
  1665.                                                                         if (nxt^.vkind = actual) then
  1666.                                                                             if lsp^.form <= power then
  1667.                                                                                 begin
  1668.                                                                                     load;
  1669.                                                                                     if debug then
  1670.                                                                                         checkbnds(lsp);
  1671.                                                                                     if comptypes(realptr, lsp) and (gattr.typtr = intptr) then
  1672.                                                                                         begin
  1673.                                                                                             gen0(10);(*flt*)
  1674.                                                                                             gattr.typtr := realptr
  1675.                                                                                         end;
  1676.                                                                                     locpar := locpar + lsp^.size;
  1677.                                                                                     align(parmptr, locpar);
  1678.                                                                                 end
  1679.                                                                             else
  1680.                                                                                 begin
  1681.                                                                                     loadaddress;
  1682.                                                                                     locpar := locpar + ptrsize;
  1683.                                                                                     align(parmptr, locpar)
  1684.                                                                                 end
  1685.                                                                         else if gattr.kind = varbl then
  1686.                                                                             begin
  1687.                                                                                 loadaddress;
  1688.                                                                                 locpar := locpar + ptrsize;
  1689.                                                                                 align(parmptr, locpar);
  1690.                                                                             end
  1691.                                                                         else
  1692.                                                                             error(154);
  1693.                                                                         if not comptypes(lsp, gattr.typtr) then
  1694.                                                                             error(142)
  1695.                                                                     end
  1696.                                                             end
  1697.                                                     end
  1698.                                                 else (*lkind = formal*)
  1699.                                                     begin (*pass formal param*)
  1700.                                                     end
  1701.                                         end;
  1702.                                     if (lkind = actual) and (nxt <> nil) then
  1703.                                         nxt := nxt^.next
  1704.                                 until sy <> comma;
  1705.                                 lc := llc;
  1706.                                 if sy = rparent then
  1707.                                     insymbol
  1708.                                 else
  1709.                                     error(4)
  1710.                             end; (*if lparent*)
  1711.                         if lkind = actual then
  1712.                             begin
  1713.                                 if nxt <> nil then
  1714.                                     error(126);
  1715.                                 with fcp^ do
  1716.                                     begin
  1717.                                         if externl then
  1718.                                             gen1(30, pfname)(*csp*)
  1719.                                         else
  1720.                                             gencupent(46, locpar, pfname);(*cup*)
  1721.                                     end
  1722.                             end;
  1723.                         gattr.typtr := fcp^.idtype
  1724.                     end; (*callnonstandard*)
  1725.  
  1726.                 begin (*call*)
  1727.                     if fcp^.pfdeckind = standard then
  1728.                         begin
  1729.                             lkey := fcp^.key;
  1730.                             if fcp^.klass = proc then
  1731.                                 begin
  1732.                                     if not (lkey in [5, 6, 11, 12]) then
  1733.                                         if sy = lparent then
  1734.                                             insymbol
  1735.                                         else
  1736.                                             error(9);
  1737.                                     case lkey of
  1738.                                         1, 2, 3, 4: 
  1739.                                             getputresetrewrite;
  1740.                                         5, 11: 
  1741.                                             read;
  1742.                                         6, 12: 
  1743.                                             write;
  1744.                                         7: 
  1745.                                             pack;
  1746.                                         8: 
  1747.                                             unpack;
  1748.                                         9: 
  1749.                                             new;
  1750.                                         10: 
  1751.                                             release;
  1752.                                         13: 
  1753.                                             mark
  1754.                                     end;
  1755.                                     if not (lkey in [5, 6, 11, 12]) then
  1756.                                         if sy = rparent then
  1757.                                             insymbol
  1758.                                         else
  1759.                                             error(4)
  1760.                                 end
  1761.                             else
  1762.                                 begin
  1763.                                     if lkey <= 8 then
  1764.                                         begin
  1765.                                             if sy = lparent then
  1766.                                                 insymbol
  1767.                                             else
  1768.                                                 error(9);
  1769.                                             expression(fsys + [rparent]);
  1770.                                             load
  1771.                                         end;
  1772.                                     case lkey of
  1773.                                         1: 
  1774.                                             abs;
  1775.                                         2: 
  1776.                                             sqr;
  1777.                                         3: 
  1778.                                             trunc;
  1779.                                         4: 
  1780.                                             odd;
  1781.                                         5: 
  1782.                                             ord;
  1783.                                         6: 
  1784.                                             chr;
  1785.                                         7, 8: 
  1786.                                             predsucc;
  1787.                                         9, 10: 
  1788.                                             eof
  1789.                                     end;
  1790.                                     if lkey <= 8 then
  1791.                                         if sy = rparent then
  1792.                                             insymbol
  1793.                                         else
  1794.                                             error(4)
  1795.                                 end;
  1796.                         end (*standard procedures and functions*)
  1797.                     else
  1798.                         callnonstandard
  1799.                 end; (*call*)
  1800.  
  1801.                 procedure expression;
  1802.                     var
  1803.                         lattr: attr;
  1804.                         lop: operator;
  1805.                         typind: char;
  1806.                         lsize: addrrange;
  1807.  
  1808.                     procedure simpleexpression (fsys: setofsys);
  1809.                         var
  1810.                             lattr: attr;
  1811.                             lop: operator;
  1812.                             signed: boolean;
  1813.  
  1814.                         procedure term (fsys: setofsys);
  1815.                             var
  1816.                                 lattr: attr;
  1817.                                 lop: operator;
  1818.  
  1819.                             procedure factor (fsys: setofsys);
  1820.                                 var
  1821.                                     lcp: ctp;
  1822.                                     lvp: csp;
  1823.                                     varpart: boolean;
  1824.                                     cstpart: setty;
  1825.                                     lsp: stp;
  1826.                             begin
  1827.                                 if not (sy in facbegsys) then
  1828.                                     begin
  1829.                                         error(58);
  1830.                                         skip(fsys + facbegsys);
  1831.                                         gattr.typtr := nil
  1832.                                     end;
  1833.                                 while sy in facbegsys do
  1834.                                     begin
  1835.                                         case sy of
  1836.           (*id*)
  1837.                                             ident: 
  1838.                                                 begin
  1839.                                                     searchid([konst, vars, field, func], lcp);
  1840.                                                     insymbol;
  1841.                                                     if lcp^.klass = func then
  1842.                                                         begin
  1843.                                                             call(fsys, lcp);
  1844.                                                             with gattr do
  1845.                                                                 begin
  1846.                                                                     kind := expr;
  1847.                                                                     if typtr <> nil then
  1848.                                                                         if typtr^.form = subrange then
  1849.                                                                             typtr := typtr^.rangetype
  1850.                                                                 end
  1851.                                                         end
  1852.                                                     else if lcp^.klass = konst then
  1853.                                                         with gattr, lcp^ do
  1854.                                                             begin
  1855.                                                                 typtr := idtype;
  1856.                                                                 kind := cst;
  1857.                                                                 cval := values
  1858.                                                             end
  1859.                                                     else
  1860.                                                         begin
  1861.                                                             selector(fsys, lcp);
  1862.                                                             if gattr.typtr <> nil then(*elim.subr.types to*)
  1863.                                                                 with gattr, typtr^ do(*simplify later tests*)
  1864.                                                                     if form = subrange then
  1865.                                                                         typtr := rangetype
  1866.                                                         end
  1867.                                                 end;
  1868.           (*cst*)
  1869.                                             intconst: 
  1870.                                                 begin
  1871.                                                     with gattr do
  1872.                                                         begin
  1873.                                                             typtr := intptr;
  1874.                                                             kind := cst;
  1875.                                                             cval := val
  1876.                                                         end;
  1877.                                                     insymbol
  1878.                                                 end;
  1879.                                             realconst: 
  1880.                                                 begin
  1881.                                                     with gattr do
  1882.                                                         begin
  1883.                                                             typtr := realptr;
  1884.                                                             kind := cst;
  1885.                                                             cval := val
  1886.                                                         end;
  1887.                                                     insymbol
  1888.                                                 end;
  1889.                                             stringconst: 
  1890.                                                 begin
  1891.                                                     with gattr do
  1892.                                                         begin
  1893.                                                             if lgth = 1 then
  1894.                                                                 typtr := charptr
  1895.                                                             else
  1896.                                                                 begin
  1897.                                                                     new(lsp, arrays);
  1898.                                                                     with lsp^ do
  1899.                                                                         begin
  1900.                                                                             aeltype := charptr;
  1901.                                                                             form := arrays;
  1902.                                                                             inxtype := nil;
  1903.                                                                             size := lgth * charsize
  1904.                                                                         end;
  1905.                                                                     typtr := lsp
  1906.                                                                 end;
  1907.                                                             kind := cst;
  1908.                                                             cval := val
  1909.                                                         end;
  1910.                                                     insymbol
  1911.                                                 end;
  1912.           (* ( *)
  1913.                                             lparent: 
  1914.                                                 begin
  1915.                                                     insymbol;
  1916.                                                     expression(fsys + [rparent]);
  1917.                                                     if sy = rparent then
  1918.                                                         insymbol
  1919.                                                     else
  1920.                                                         error(4)
  1921.                                                 end;
  1922.           (*not*)
  1923.                                             notsy: 
  1924.                                                 begin
  1925.                                                     insymbol;
  1926.                                                     factor(fsys);
  1927.                                                     load;
  1928.                                                     gen0(19);(*not*)
  1929.                                                     if gattr.typtr <> nil then
  1930.                                                         if gattr.typtr <> boolptr then
  1931.                                                             begin
  1932.                                                                 error(135);
  1933.                                                                 gattr.typtr := nil
  1934.                                                             end;
  1935.                                                 end;
  1936.           (*[*)
  1937.                                             lbrack: 
  1938.                                                 begin
  1939.                                                     insymbol;
  1940.                                                     cstpart := [];
  1941.                                                     varpart := false;
  1942.                                                     new(lsp, power);
  1943.                                                     with lsp^ do
  1944.                                                         begin
  1945.                                                             elset := nil;
  1946.                                                             size := setsize;
  1947.                                                             form := power
  1948.                                                         end;
  1949.                                                     if sy = rbrack then
  1950.                                                         begin
  1951.                                                             with gattr do
  1952.                                                                 begin
  1953.                                                                     typtr := lsp;
  1954.                                                                     kind := cst
  1955.                                                                 end;
  1956.                                                             insymbol
  1957.                                                         end
  1958.                                                     else
  1959.                                                         begin
  1960.                                                             repeat
  1961.                                                                 expression(fsys + [comma, rbrack]);
  1962.                                                                 if gattr.typtr <> nil then
  1963.                                                                     if gattr.typtr^.form <> scalar then
  1964.                                                                         begin
  1965.                                                                             error(136);
  1966.                                                                             gattr.typtr := nil
  1967.                                                                         end
  1968.                                                                     else if comptypes(lsp^.elset, gattr.typtr) then
  1969.                                                                         begin
  1970.                                                                             if gattr.kind = cst then
  1971.                                                                                 if (gattr.cval.ival < setlow) or (gattr.cval.ival > sethigh) then
  1972.                                                                                     error(304)
  1973.                                                                                 else
  1974.                                                                                     cstpart := cstpart + [gattr.cval.ival]
  1975.                                                                             else
  1976.                                                                                 begin
  1977.                                                                                     load;
  1978.                                                                                     if not comptypes(gattr.typtr, intptr) then
  1979.                                                                                         gen0t(58, gattr.typtr);(*ord*)
  1980.                                                                                     gen0(23);(*sgs*)
  1981.                                                                                     if varpart then
  1982.                                                                                         gen0(28)(*uni*)
  1983.                                                                                     else
  1984.                                                                                         varpart := true
  1985.                                                                                 end;
  1986.                                                                             lsp^.elset := gattr.typtr;
  1987.                                                                             gattr.typtr := lsp
  1988.                                                                         end
  1989.                                                                     else
  1990.                                                                         error(137);
  1991.                                                                 test := sy <> comma;
  1992.                                                                 if not test then
  1993.                                                                     insymbol
  1994.                                                             until test;
  1995.                                                             if sy = rbrack then
  1996.                                                                 insymbol
  1997.                                                             else
  1998.                                                                 error(12)
  1999.                                                         end;
  2000.                                                     if varpart then
  2001.                                                         begin
  2002.                                                             if cstpart <> [] then
  2003.                                                                 begin
  2004.                                                                     new(lvp, pset);
  2005.                                                                     lvp^.pval := cstpart;
  2006.                                                                     lvp^.cclass := pset;
  2007.                                                                     if cstptrix = cstoccmax then
  2008.                                                                         error(254)
  2009.                                                                     else
  2010.                                                                         begin
  2011.                                                                             cstptrix := cstptrix + 1;
  2012.                                                                             cstptr[cstptrix] := lvp;
  2013.                                                                             gen2(51, 5, cstptrix);(*ldc*)
  2014.                                                                             gen0(28);(*uni*)
  2015.                                                                             gattr.kind := expr
  2016.                                                                         end
  2017.                                                                 end
  2018.                                                         end
  2019.                                                     else
  2020.                                                         begin
  2021.                                                             new(lvp, pset);
  2022.                                                             lvp^.pval := cstpart;
  2023.                                                             lvp^.cclass := pset;
  2024.                                                             gattr.cval.valp := lvp
  2025.                                                         end
  2026.                                                 end
  2027.                                         end; (*case*)
  2028.                                         if not (sy in fsys) then
  2029.                                             begin
  2030.                                                 error(6);
  2031.                                                 skip(fsys + facbegsys)
  2032.                                             end
  2033.                                     end (*while*)
  2034.                             end; (*factor*)
  2035.  
  2036.                         begin (*term*)
  2037.                             factor(fsys + [mulop]);
  2038.                             while sy = mulop do
  2039.                                 begin
  2040.                                     load;
  2041.                                     lattr := gattr;
  2042.                                     lop := op;
  2043.                                     insymbol;
  2044.                                     factor(fsys + [mulop]);
  2045.                                     load;
  2046.                                     if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
  2047.                                         case lop of
  2048.         (***)
  2049.                                             mul: 
  2050.                                                 if (lattr.typtr = intptr) and (gattr.typtr = intptr) then
  2051.                                                     gen0(15)(*mpi*)
  2052.                                                 else
  2053.                                                     begin
  2054.                                                         if lattr.typtr = intptr then
  2055.                                                             begin
  2056.                                                                 gen0(9);(*flo*)
  2057.                                                                 lattr.typtr := realptr
  2058.                                                             end
  2059.                                                         else if gattr.typtr = intptr then
  2060.                                                             begin
  2061.                                                                 gen0(10);(*flt*)
  2062.                                                                 gattr.typtr := realptr
  2063.                                                             end;
  2064.                                                         if (lattr.typtr = realptr) and (gattr.typtr = realptr) then
  2065.                                                             gen0(16)(*mpr*)
  2066.                                                         else if (lattr.typtr^.form = power) and comptypes(lattr.typtr, gattr.typtr) then
  2067.                                                             gen0(12)(*int*)
  2068.                                                         else
  2069.                                                             begin
  2070.                                                                 error(134);
  2071.                                                                 gattr.typtr := nil
  2072.                                                             end
  2073.                                                     end;
  2074.         (* / *)
  2075.                                             rdiv: 
  2076.                                                 begin
  2077.                                                     if gattr.typtr = intptr then
  2078.                                                         begin
  2079.                                                             gen0(10);(*flt*)
  2080.                                                             gattr.typtr := realptr
  2081.                                                         end;
  2082.                                                     if lattr.typtr = intptr then
  2083.                                                         begin
  2084.                                                             gen0(9);(*flo*)
  2085.                                                             lattr.typtr := realptr
  2086.                                                         end;
  2087.                                                     if (lattr.typtr = realptr) and (gattr.typtr = realptr) then
  2088.                                                         gen0(7)(*dvr*)
  2089.                                                     else
  2090.                                                         begin
  2091.                                                             error(134);
  2092.                                                             gattr.typtr := nil
  2093.                                                         end
  2094.                                                 end;
  2095.         (*div*)
  2096.                                             idiv: 
  2097.                                                 if (lattr.typtr = intptr) and (gattr.typtr = intptr) then
  2098.                                                     gen0(6)(*dvi*)
  2099.                                                 else
  2100.                                                     begin
  2101.                                                         error(134);
  2102.                                                         gattr.typtr := nil
  2103.                                                     end;
  2104.         (*mod*)
  2105.                                             imod: 
  2106.                                                 if (lattr.typtr = intptr) and (gattr.typtr = intptr) then
  2107.                                                     gen0(14)(*mod*)
  2108.                                                 else
  2109.                                                     begin
  2110.                                                         error(134);
  2111.                                                         gattr.typtr := nil
  2112.                                                     end;
  2113.         (*and*)
  2114.                                             andop: 
  2115.                                                 if (lattr.typtr = boolptr) and (gattr.typtr = boolptr) then
  2116.                                                     gen0(4)(*and*)
  2117.                                                 else
  2118.                                                     begin
  2119.                                                         error(134);
  2120.                                                         gattr.typtr := nil
  2121.                                                     end
  2122.                                         end (*case*)
  2123.                                     else
  2124.                                         gattr.typtr := nil
  2125.                                 end (*while*)
  2126.                         end; (*term*)
  2127.  
  2128.                     begin (*simpleexpression*)
  2129.                         signed := false;
  2130.                         if (sy = addop) and (op in [plus, minus]) then
  2131.                             begin
  2132.                                 signed := op = minus;
  2133.                                 insymbol
  2134.                             end;
  2135.                         term(fsys + [addop]);
  2136.                         if signed then
  2137.                             begin
  2138.                                 load;
  2139.                                 if gattr.typtr = intptr then
  2140.                                     gen0(17)(*ngi*)
  2141.                                 else if gattr.typtr = realptr then
  2142.                                     gen0(18)(*ngr*)
  2143.                                 else
  2144.                                     begin
  2145.                                         error(134);
  2146.                                         gattr.typtr := nil
  2147.                                     end
  2148.                             end;
  2149.                         while sy = addop do
  2150.                             begin
  2151.                                 load;
  2152.                                 lattr := gattr;
  2153.                                 lop := op;
  2154.                                 insymbol;
  2155.                                 term(fsys + [addop]);
  2156.                                 load;
  2157.                                 if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
  2158.                                     case lop of
  2159.       (*+*)
  2160.                                         plus: 
  2161.                                             if (lattr.typtr = intptr) and (gattr.typtr = intptr) then
  2162.                                                 gen0(2)(*adi*)
  2163.                                             else
  2164.                                                 begin
  2165.                                                     if lattr.typtr = intptr then
  2166.                                                         begin
  2167.                                                             gen0(9);(*flo*)
  2168.                                                             lattr.typtr := realptr
  2169.                                                         end
  2170.                                                     else if gattr.typtr = intptr then
  2171.                                                         begin
  2172.                                                             gen0(10);(*flt*)
  2173.                                                             gattr.typtr := realptr
  2174.                                                         end;
  2175.                                                     if (lattr.typtr = realptr) and (gattr.typtr = realptr) then
  2176.                                                         gen0(3)(*adr*)
  2177.                                                     else if (lattr.typtr^.form = power) and comptypes(lattr.typtr, gattr.typtr) then
  2178.                                                         gen0(28)(*uni*)
  2179.                                                     else
  2180.                                                         begin
  2181.                                                             error(134);
  2182.                                                             gattr.typtr := nil
  2183.                                                         end
  2184.                                                 end;
  2185.       (*-*)
  2186.                                         minus: 
  2187.                                             if (lattr.typtr = intptr) and (gattr.typtr = intptr) then
  2188.                                                 gen0(21)(*sbi*)
  2189.                                             else
  2190.                                                 begin
  2191.                                                     if lattr.typtr = intptr then
  2192.                                                         begin
  2193.                                                             gen0(9);(*flo*)
  2194.                                                             lattr.typtr := realptr
  2195.                                                         end
  2196.                                                     else if gattr.typtr = intptr then
  2197.                                                         begin
  2198.                                                             gen0(10);(*flt*)
  2199.                                                             gattr.typtr := realptr
  2200.                                                         end;
  2201.                                                     if (lattr.typtr = realptr) and (gattr.typtr = realptr) then
  2202.                                                         gen0(22)(*sbr*)
  2203.                                                     else if (lattr.typtr^.form = power) and comptypes(lattr.typtr, gattr.typtr) then
  2204.                                                         gen0(5)(*dif*)
  2205.                                                     else
  2206.                                                         begin
  2207.                                                             error(134);
  2208.                                                             gattr.typtr := nil
  2209.                                                         end
  2210.                                                 end;
  2211.       (*or*)
  2212.                                         orop: 
  2213.                                             if (lattr.typtr = boolptr) and (gattr.typtr = boolptr) then
  2214.                                                 gen0(13)(*ior*)
  2215.                                             else
  2216.                                                 begin
  2217.                                                     error(134);
  2218.                                                     gattr.typtr := nil
  2219.                                                 end
  2220.                                     end (*case*)
  2221.                                 else
  2222.                                     gattr.typtr := nil
  2223.                             end (*while*)
  2224.                     end; (*simpleexpression*)
  2225.  
  2226.                 begin (*expression*)
  2227.                     simpleexpression(fsys + [relop]);
  2228.                     if sy = relop then
  2229.                         begin
  2230.                             if gattr.typtr <> nil then
  2231.                                 if gattr.typtr^.form <= power then
  2232.                                     load
  2233.                                 else
  2234.                                     loadaddress;
  2235.                             lattr := gattr;
  2236.                             lop := op;
  2237.                             if lop = inop then
  2238.                                 if not comptypes(gattr.typtr, intptr) then
  2239.                                     gen0t(58, gattr.typtr);(*ord*)
  2240.                             insymbol;
  2241.                             simpleexpression(fsys);
  2242.                             if gattr.typtr <> nil then
  2243.                                 if gattr.typtr^.form <= power then
  2244.                                     load
  2245.                                 else
  2246.                                     loadaddress;
  2247.                             if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
  2248.                                 if lop = inop then
  2249.                                     if gattr.typtr^.form = power then
  2250.                                         if comptypes(lattr.typtr, gattr.typtr^.elset) then
  2251.                                             gen0(11)(*inn*)
  2252.                                         else
  2253.                                             begin
  2254.                                                 error(129);
  2255.                                                 gattr.typtr := nil
  2256.                                             end
  2257.                                     else
  2258.                                         begin
  2259.                                             error(130);
  2260.                                             gattr.typtr := nil
  2261.                                         end
  2262.                                 else
  2263.                                     begin
  2264.                                         if lattr.typtr <> gattr.typtr then
  2265.                                             if lattr.typtr = intptr then
  2266.                                                 begin
  2267.                                                     gen0(9);(*flo*)
  2268.                                                     lattr.typtr := realptr
  2269.                                                 end
  2270.                                             else if gattr.typtr = intptr then
  2271.                                                 begin
  2272.                                                     gen0(10);(*flt*)
  2273.                                                     gattr.typtr := realptr
  2274.                                                 end;
  2275.                                         if comptypes(lattr.typtr, gattr.typtr) then
  2276.                                             begin
  2277.                                                 lsize := lattr.typtr^.size;
  2278.                                                 case lattr.typtr^.form of
  2279.                                                     scalar: 
  2280.                                                         if lattr.typtr = realptr then
  2281.                                                             typind := 'r'
  2282.                                                         else if lattr.typtr = boolptr then
  2283.                                                             typind := 'b'
  2284.                                                         else if lattr.typtr = charptr then
  2285.                                                             typind := 'c'
  2286.                                                         else
  2287.                                                             typind := 'i';
  2288.                                                     pointer: 
  2289.                                                         begin
  2290.                                                             if lop in [ltop, leop, gtop, geop] then
  2291.                                                                 error(131);
  2292.                                                             typind := 'a'
  2293.                                                         end;
  2294.                                                     power: 
  2295.                                                         begin
  2296.                                                             if lop in [ltop, gtop] then
  2297.                                                                 error(132);
  2298.                                                             typind := 's'
  2299.                                                         end;
  2300.                                                     arrays: 
  2301.                                                         begin
  2302.                                                             if not isString(lattr.typtr) then
  2303.                                                                 error(134);
  2304.                                                             typind := 'm'
  2305.                                                         end;
  2306.                                                     records: 
  2307.                                                         begin
  2308.                                                             error(134);
  2309.                                                             typind := 'm'
  2310.                                                         end;
  2311.                                                     files: 
  2312.                                                         begin
  2313.                                                             error(133);
  2314.                                                             typind := 'f'
  2315.                                                         end
  2316.                                                 end;
  2317.                                                 case lop of
  2318.                                                     ltop: 
  2319.                                                         gen2(53, ord(typind), lsize);(*les*)
  2320.                                                     leop: 
  2321.                                                         gen2(52, ord(typind), lsize);(*leq*)
  2322.                                                     gtop: 
  2323.                                                         gen2(49, ord(typind), lsize);(*grt*)
  2324.                                                     geop: 
  2325.                                                         gen2(48, ord(typind), lsize);(*geq*)
  2326.                                                     neop: 
  2327.                                                         gen2(55, ord(typind), lsize);(*neq*)
  2328.                                                     eqop: 
  2329.                                                         gen2(47, ord(typind), lsize)(*equ*)
  2330.                                                 end
  2331.                                             end
  2332.                                         else
  2333.                                             error(129)
  2334.                                     end;
  2335.                             gattr.typtr := boolptr;
  2336.                             gattr.kind := expr
  2337.                         end (*sy = relop*)
  2338.                 end; (*expression*)
  2339.  
  2340.                 procedure assignment (fcp: ctp);
  2341.                     var
  2342.                         lattr: attr;
  2343.                 begin
  2344.                     selector(fsys + [becomes], fcp);
  2345.                     if sy = becomes then
  2346.                         begin
  2347.                             if gattr.typtr <> nil then
  2348.                                 if (gattr.access <> drct) or (gattr.typtr^.form > power) then
  2349.                                     loadaddress;
  2350.                             lattr := gattr;
  2351.                             insymbol;
  2352.                             expression(fsys);
  2353.                             if gattr.typtr <> nil then
  2354.                                 if gattr.typtr^.form <= power then
  2355.                                     load
  2356.                                 else
  2357.                                     loadaddress;
  2358.                             if (lattr.typtr <> nil) and (gattr.typtr <> nil) then
  2359.                                 begin
  2360.                                     if comptypes(realptr, lattr.typtr) and (gattr.typtr = intptr) then
  2361.                                         begin
  2362.                                             gen0(10);(*flt*)
  2363.                                             gattr.typtr := realptr
  2364.                                         end;
  2365.                                     if comptypes(lattr.typtr, gattr.typtr) then
  2366.                                         case lattr.typtr^.form of
  2367.                                             scalar, subrange: 
  2368.                                                 begin
  2369.                                                     if debug then
  2370.                                                         checkbnds(lattr.typtr);
  2371.                                                     store(lattr)
  2372.                                                 end;
  2373.                                             pointer: 
  2374.                                                 begin
  2375.                                                     if debug then
  2376.                                                         gen2t(45, 0, maxaddr, nilptr);(*chk*)
  2377.                                                     store(lattr)
  2378.                                                 end;
  2379.                                             power: 
  2380.                                                 store(lattr);
  2381.                                             arrays, records: 
  2382.                                                 gen1(40, lattr.typtr^.size);(*mov*)
  2383.                                             files: 
  2384.                                                 error(146)
  2385.                                         end
  2386.                                     else
  2387.                                         error(129)
  2388.                                 end
  2389.                         end (*sy = becomes*)
  2390.                     else
  2391.                         error(51)
  2392.                 end; (*assignment*)
  2393.  
  2394.                 procedure gotostatement;
  2395.                     var
  2396.                         llp: lbp;
  2397.                         found: boolean;
  2398.                         ttop, ttop1: disprange;
  2399.                 begin
  2400.                     if sy = intconst then
  2401.                         begin
  2402.                             found := false;
  2403.                             ttop := top;
  2404.                             while display[ttop].occur <> blck do
  2405.                                 ttop := ttop - 1;
  2406.                             ttop1 := ttop;
  2407.                             repeat
  2408.                                 llp := display[ttop].flabel;
  2409.                                 while (llp <> nil) and not found do
  2410.                                     with llp^ do
  2411.                                         if labval = val.ival then
  2412.                                             begin
  2413.                                                 found := true;
  2414.                                                 if ttop = ttop1 then
  2415.                                                     genujpxjp(57, labname)(*ujp*)
  2416.                                                 else (*goto leads out of procedure*)
  2417.                                                     error(399)
  2418.                                             end
  2419.                                         else
  2420.                                             llp := nextlab;
  2421.                                 ttop := ttop - 1
  2422.                             until found or (ttop = 0);
  2423.                             if not found then
  2424.                                 error(167);
  2425.                             insymbol
  2426.                         end
  2427.                     else
  2428.                         error(15)
  2429.                 end; (*gotostatement*)
  2430.  
  2431.                 procedure compoundstatement;
  2432.                 begin
  2433.                     repeat
  2434.                         repeat
  2435.                             statement(fsys + [semicolon, endsy])
  2436.                         until not (sy in statbegsys);
  2437.                         test := sy <> semicolon;
  2438.                         if not test then
  2439.                             insymbol
  2440.                     until test;
  2441.                     if sy = endsy then
  2442.                         insymbol
  2443.                     else
  2444.                         error(13)
  2445.                 end; (*compoundstatemenet*)
  2446.  
  2447.                 procedure ifstatement;
  2448.                     var
  2449.                         lcix1, lcix2: integer;
  2450.                 begin
  2451.                     expression(fsys + [thensy]);
  2452.                     genlabel(lcix1);
  2453.                     genfjp(lcix1);
  2454.                     if sy = thensy then
  2455.                         insymbol
  2456.                     else
  2457.                         error(52);
  2458.                     statement(fsys + [elsesy]);
  2459.                     if sy = elsesy then
  2460.                         begin
  2461.                             genlabel(lcix2);
  2462.                             genujpxjp(57, lcix2);(*ujp*)
  2463.                             putlabel(lcix1);
  2464.                             insymbol;
  2465.                             statement(fsys);
  2466.                             putlabel(lcix2)
  2467.                         end
  2468.                     else
  2469.                         putlabel(lcix1)
  2470.                 end; (*ifstatement*)
  2471.  
  2472.                 procedure casestatement;
  2473.                     label
  2474.                         1;
  2475.                     type
  2476.                         cip = ^caseinfo;
  2477.                         caseinfo = packed record
  2478.                                 next: cip;
  2479.                                 csstart: integer;
  2480.                                 cslab: integer
  2481.                             end;
  2482.                     var
  2483.                         lsp, lsp1: stp;
  2484.                         fstptr, lpt1, lpt2, lpt3: cip;
  2485.                         lval: valu;
  2486.                         laddr, lcix, lcix1, lmin, lmax: integer;
  2487.                 begin
  2488.                     expression(fsys + [ofsy, comma, colon]);
  2489.                     load;
  2490.                     genlabel(lcix);
  2491.                     lsp := gattr.typtr;
  2492.                     if lsp <> nil then
  2493.                         if (lsp^.form <> scalar) or (lsp = realptr) then
  2494.                             begin
  2495.                                 error(144);
  2496.                                 lsp := nil
  2497.                             end
  2498.                         else if not comptypes(lsp, intptr) then
  2499.                             gen0t(58, lsp);(*ord*)
  2500.                     genujpxjp(57, lcix);(*ujp*)
  2501.                     if sy = ofsy then
  2502.                         insymbol
  2503.                     else
  2504.                         error(8);
  2505.                     fstptr := nil;
  2506.                     genlabel(laddr);
  2507.                     repeat
  2508.                         lpt3 := nil;
  2509.                         genlabel(lcix1);
  2510.                         if not (sy in [semicolon, endsy]) then
  2511.                             begin
  2512.                                 repeat
  2513.                                     Bconstant(fsys + [comma, colon], lsp1, lval);
  2514.                                     if lsp <> nil then
  2515.                                         if comptypes(lsp, lsp1) then
  2516.                                             begin
  2517.                                                 lpt1 := fstptr;
  2518.                                                 lpt2 := nil;
  2519.                                                 while lpt1 <> nil do
  2520.                                                     with lpt1^ do
  2521.                                                         begin
  2522.                                                             if cslab <= lval.ival then
  2523.                                                                 begin
  2524.                                                                     if cslab = lval.ival then
  2525.                                                                         error(156);
  2526.                                                                     goto 1
  2527.                                                                 end;
  2528.                                                             lpt2 := lpt1;
  2529.                                                             lpt1 := next
  2530.                                                         end;
  2531. 1:
  2532.                                                 new(lpt3);
  2533.                                                 with lpt3^ do
  2534.                                                     begin
  2535.                                                         next := lpt1;
  2536.                                                         cslab := lval.ival;
  2537.                                                         csstart := lcix1
  2538.                                                     end;
  2539.                                                 if lpt2 = nil then
  2540.                                                     fstptr := lpt3
  2541.                                                 else
  2542.                                                     lpt2^.next := lpt3
  2543.                                             end
  2544.                                         else
  2545.                                             error(147);
  2546.                                     test := sy <> comma;
  2547.                                     if not test then
  2548.                                         insymbol
  2549.                                 until test;
  2550.                                 if sy = colon then
  2551.                                     insymbol
  2552.                                 else
  2553.                                     error(5);
  2554.                                 putlabel(lcix1);
  2555.                                 repeat
  2556.                                     statement(fsys + [semicolon])
  2557.                                 until not (sy in statbegsys);
  2558.                                 if lpt3 <> nil then
  2559.                                     genujpxjp(57, laddr);(*ujp*)
  2560.                             end;
  2561.                         test := sy <> semicolon;
  2562.                         if not test then
  2563.                             insymbol
  2564.                     until test;
  2565.                     putlabel(lcix);
  2566.                     if fstptr <> nil then
  2567.                         begin
  2568.                             lmax := fstptr^.cslab;
  2569.           (*reverse pointers*)
  2570.                             lpt1 := fstptr;
  2571.                             fstptr := nil;
  2572.                             repeat
  2573.                                 lpt2 := lpt1^.next;
  2574.                                 lpt1^.next := fstptr;
  2575.                                 fstptr := lpt1;
  2576.                                 lpt1 := lpt2
  2577.                             until lpt1 = nil;
  2578.                             lmin := fstptr^.cslab;
  2579.                             if lmax - lmin < cixmax then
  2580.                                 begin
  2581.                                     gen2t(45, lmin, lmax, intptr);(*chk*)
  2582.                                     gen2(51, 1, lmin);(*ldc*)
  2583.                                     gen0(21);(*sbi*)
  2584.                                     genlabel(lcix);
  2585.                                     genujpxjp(44, lcix);(*xjp*)
  2586.                                     putlabel(lcix);
  2587.                                     repeat
  2588.                                         with fstptr^ do
  2589.                                             begin
  2590.                                                 while cslab > lmin do
  2591.                                                     begin
  2592.                                                         gen0(60);(*ujc error*)
  2593.                                                         lmin := lmin + 1
  2594.                                                     end;
  2595.                                                 genujpxjp(57, csstart);(*ujp*)
  2596.                                                 fstptr := next;
  2597.                                                 lmin := lmin + 1
  2598.                                             end
  2599.                                     until fstptr = nil;
  2600.                                     putlabel(laddr)
  2601.                                 end
  2602.                             else
  2603.                                 error(157)
  2604.                         end;
  2605.                     if sy = endsy then
  2606.                         insymbol
  2607.                     else
  2608.                         error(13)
  2609.                 end; (*casestatement*)
  2610.  
  2611.                 procedure repeatstatement;
  2612.                     var
  2613.                         laddr: integer;
  2614.                 begin
  2615.                     genlabel(laddr);
  2616.                     putlabel(laddr);
  2617.                     repeat
  2618.                         statement(fsys + [semicolon, untilsy]);
  2619.                         if sy in statbegsys then
  2620.                             error(14)
  2621.                     until not (sy in statbegsys);
  2622.                     while sy = semicolon do
  2623.                         begin
  2624.                             insymbol;
  2625.                             repeat
  2626.                                 statement(fsys + [semicolon, untilsy]);
  2627.                                 if sy in statbegsys then
  2628.                                     error(14)
  2629.                             until not (sy in statbegsys);
  2630.                         end;
  2631.                     if sy = untilsy then
  2632.                         begin
  2633.                             insymbol;
  2634.                             expression(fsys);
  2635.                             genfjp(laddr)
  2636.                         end
  2637.                     else
  2638.                         error(53)
  2639.                 end; (*repeatstatement*)
  2640.  
  2641.                 procedure whilestatement;
  2642.                     var
  2643.                         laddr, lcix: integer;
  2644.                 begin
  2645.                     genlabel(laddr);
  2646.                     putlabel(laddr);
  2647.                     expression(fsys + [dosy]);
  2648.                     genlabel(lcix);
  2649.                     genfjp(lcix);
  2650.                     if sy = dosy then
  2651.                         insymbol
  2652.                     else
  2653.                         error(54);
  2654.                     statement(fsys);
  2655.                     genujpxjp(57, laddr);(*ujp*)
  2656.                     putlabel(lcix)
  2657.                 end; (*whilestatement*)
  2658.  
  2659.                 procedure forstatement;
  2660.                     var
  2661.                         lattr: attr;
  2662.                         lsy: symbol;
  2663.                         lcix, laddr: integer;
  2664.                         llc: addrrange;
  2665.                 begin
  2666.                     llc := lc;
  2667.                     with lattr do
  2668.                         begin
  2669.                             typtr := nil;
  2670.                             kind := varbl;
  2671.                             access := drct;
  2672.                             vlevel := level;
  2673.                             dplmt := 0
  2674.                         end;
  2675.                     if sy = ident then
  2676.                         begin
  2677.                             searchid([vars], lcp);
  2678.                             with lcp^, lattr do
  2679.                                 begin
  2680.                                     typtr := idtype;
  2681.                                     kind := varbl;
  2682.                                     if vkind = actual then
  2683.                                         begin
  2684.                                             access := drct;
  2685.                                             vlevel := vlev;
  2686.                                             dplmt := vaddr
  2687.                                         end
  2688.                                     else
  2689.                                         begin
  2690.                                             error(155);
  2691.                                             typtr := nil
  2692.                                         end
  2693.                                 end;
  2694.                             if lattr.typtr <> nil then
  2695.                                 if (lattr.typtr^.form > subrange) or comptypes(realptr, lattr.typtr) then
  2696.                                     begin
  2697.                                         error(143);
  2698.                                         lattr.typtr := nil
  2699.                                     end;
  2700.                             insymbol
  2701.                         end
  2702.                     else
  2703.                         begin
  2704.                             error(2);
  2705.                             skip(fsys + [becomes, tosy, downtosy, dosy])
  2706.                         end;
  2707.                     if sy = becomes then
  2708.                         begin
  2709.                             insymbol;
  2710.                             expression(fsys + [tosy, downtosy, dosy]);
  2711.                             if gattr.typtr <> nil then
  2712.                                 if gattr.typtr^.form <> scalar then
  2713.                                     error(144)
  2714.                                 else if comptypes(lattr.typtr, gattr.typtr) then
  2715.                                     begin
  2716.                                         load;
  2717.                                         store(lattr)
  2718.                                     end
  2719.                                 else
  2720.                                     error(145)
  2721.                         end
  2722.                     else
  2723.                         begin
  2724.                             error(51);
  2725.                             skip(fsys + [tosy, downtosy, dosy])
  2726.                         end;
  2727.                     if sy in [tosy, downtosy] then
  2728.                         begin
  2729.                             lsy := sy;
  2730.                             insymbol;
  2731.                             expression(fsys + [dosy]);
  2732.                             if gattr.typtr <> nil then
  2733.                                 if gattr.typtr^.form <> scalar then
  2734.                                     error(144)
  2735.                                 else if comptypes(lattr.typtr, gattr.typtr) then
  2736.                                     begin
  2737.                                         load;
  2738.                                         if not comptypes(lattr.typtr, intptr) then
  2739.                                             gen0t(58, gattr.typtr);(*ord*)
  2740.                                         align(intptr, lc);
  2741.                                         gen2t(56, 0, lc, intptr);(*str*)
  2742.                                         genlabel(laddr);
  2743.                                         putlabel(laddr);
  2744.                                         gattr := lattr;
  2745.                                         load;
  2746.                                         if not comptypes(gattr.typtr, intptr) then
  2747.                                             gen0t(58, gattr.typtr);(*ord*)
  2748.                                         gen2t(54, 0, lc, intptr);(*lod*)
  2749.                                         lc := lc + intsize;
  2750.                                         if lc > lcmax then
  2751.                                             lcmax := lc;
  2752.                                         if lsy = tosy then
  2753.                                             gen2(52, ord('i'), 1)(*leq*)
  2754.                                         else
  2755.                                             gen2(48, ord('i'), 1);(*geq*)
  2756.                                     end
  2757.                                 else
  2758.                                     error(145)
  2759.                         end
  2760.                     else
  2761.                         begin
  2762.                             error(55);
  2763.                             skip(fsys + [dosy])
  2764.                         end;
  2765.                     genlabel(lcix);
  2766.                     genujpxjp(33, lcix);(*fjp*)
  2767.                     if sy = dosy then
  2768.                         insymbol
  2769.                     else
  2770.                         error(54);
  2771.                     statement(fsys);
  2772.                     gattr := lattr;
  2773.                     load;
  2774.                     if lsy = tosy then
  2775.                         gen1t(34, 1, gattr.typtr)(*inc*)
  2776.                     else
  2777.                         gen1t(31, 1, gattr.typtr);(*dec*)
  2778.                     store(lattr);
  2779.                     genujpxjp(57, laddr);(*ujp*)
  2780.                     putlabel(lcix);
  2781.                     lc := llc;
  2782.                 end; (*forstatement*)
  2783.  
  2784.  
  2785.                 procedure withstatement;
  2786.                     var
  2787.                         lcp: ctp;
  2788.                         lcnt1: disprange;
  2789.                         llc: addrrange;
  2790.                 begin
  2791.                     lcnt1 := 0;
  2792.                     llc := lc;
  2793.                     repeat
  2794.                         if sy = ident then
  2795.                             begin
  2796.                                 searchid([vars, field], lcp);
  2797.                                 insymbol
  2798.                             end
  2799.                         else
  2800.                             begin
  2801.                                 error(2);
  2802.                                 lcp := uvarptr
  2803.                             end;
  2804.                         selector(fsys + [comma, dosy], lcp);
  2805.                         if gattr.typtr <> nil then
  2806.                             if gattr.typtr^.form = records then
  2807.                                 if top < displimit then
  2808.                                     begin
  2809.                                         top := top + 1;
  2810.                                         lcnt1 := lcnt1 + 1;
  2811.                                         with display[top] do
  2812.                                             begin
  2813.                                                 fname := gattr.typtr^.fstfld;
  2814.                                                 flabel := nil
  2815.                                             end;
  2816.                                         if gattr.access = drct then
  2817.                                             with display[top] do
  2818.                                                 begin
  2819.                                                     occur := crec;
  2820.                                                     clev := gattr.vlevel;
  2821.                                                     cdspl := gattr.dplmt
  2822.                                                 end
  2823.                                         else
  2824.                                             begin
  2825.                                                 loadaddress;
  2826.                                                 align(nilptr, lc);
  2827.                                                 gen2t(56, 0, lc, nilptr);(*str*)
  2828.                                                 with display[top] do
  2829.                                                     begin
  2830.                                                         occur := vrec;
  2831.                                                         vdspl := lc
  2832.                                                     end;
  2833.                                                 lc := lc + ptrsize;
  2834.                                                 if lc > lcmax then
  2835.                                                     lcmax := lc
  2836.                                             end
  2837.                                     end
  2838.                                 else
  2839.                                     error(250)
  2840.                             else
  2841.                                 error(140);
  2842.                         test := sy <> comma;
  2843.                         if not test then
  2844.                             insymbol
  2845.                     until test;
  2846.                     if sy = dosy then
  2847.                         insymbol
  2848.                     else
  2849.                         error(54);
  2850.                     statement(fsys);
  2851.                     top := top - lcnt1;
  2852.                     lc := llc;
  2853.                 end; (*withstatement*)
  2854.  
  2855.             begin (*statement*)
  2856.                 if sy = intconst then (*label*)
  2857.                     begin
  2858.                         llp := display[level].flabel;
  2859.                         while llp <> nil do
  2860.                             with llp^ do
  2861.                                 if labval = val.ival then
  2862.                                     begin
  2863.                                         if defined then
  2864.                                             error(165);
  2865.                                         putlabel(labname);
  2866.                                         defined := true;
  2867.                                         goto 1
  2868.                                     end
  2869.                                 else
  2870.                                     llp := nextlab;
  2871.                         error(167);
  2872. 1:
  2873.                         insymbol;
  2874.                         if sy = colon then
  2875.                             insymbol
  2876.                         else
  2877.                             error(5)
  2878.                     end;
  2879.                 if not (sy in fsys + [ident]) then
  2880.                     begin
  2881.                         error(6);
  2882.                         skip(fsys)
  2883.                     end;
  2884.                 if sy in statbegsys + [ident] then
  2885.                     begin
  2886.                         case sy of
  2887.                             ident: 
  2888.                                 begin
  2889.                                     searchid([vars, field, func, proc], lcp);
  2890.                                     insymbol;
  2891.                                     if lcp^.klass = proc then
  2892.                                         call(fsys, lcp)
  2893.                                     else
  2894.                                         assignment(lcp)
  2895.                                 end;
  2896.                             beginsy: 
  2897.                                 begin
  2898.                                     insymbol;
  2899.                                     compoundstatement
  2900.                                 end;
  2901.                             gotosy: 
  2902.                                 begin
  2903.                                     insymbol;
  2904.                                     gotostatement
  2905.                                 end;
  2906.                             ifsy: 
  2907.                                 begin
  2908.                                     insymbol;
  2909.                                     ifstatement
  2910.                                 end;
  2911.                             casesy: 
  2912.                                 begin
  2913.                                     insymbol;
  2914.                                     casestatement
  2915.                                 end;
  2916.                             whilesy: 
  2917.                                 begin
  2918.                                     insymbol;
  2919.                                     whilestatement
  2920.                                 end;
  2921.                             repeatsy: 
  2922.                                 begin
  2923.                                     insymbol;
  2924.                                     repeatstatement
  2925.                                 end;
  2926.                             forsy: 
  2927.                                 begin
  2928.                                     insymbol;
  2929.                                     forstatement
  2930.                                 end;
  2931.                             withsy: 
  2932.                                 begin
  2933.                                     insymbol;
  2934.                                     withstatement
  2935.                                 end
  2936.                         end;
  2937.                         if not (sy in [semicolon, endsy, elsesy, untilsy]) then
  2938.                             begin
  2939.                                 error(6);
  2940.                                 skip(fsys)
  2941.                             end
  2942.                     end
  2943.             end; (*statement*)
  2944.  
  2945.         begin (*body*)
  2946.             if fprocp <> nil then
  2947.                 entname := fprocp^.pfname
  2948.             else
  2949.                 genlabel(entname);
  2950.             cstptrix := 0;
  2951.             topnew := lcaftermarkstack;
  2952.             topmax := lcaftermarkstack;
  2953.             putlabel(entname);
  2954.             genlabel(segsize);
  2955.             genlabel(stacktop);
  2956.             gencupent(32, 1, segsize);(*ent1*)
  2957.             gencupent(32, 2, stacktop);(*ent2*)
  2958.             if fprocp <> nil then (*copy multiple values into local cells*)
  2959.                 begin
  2960.                     llc1 := lcaftermarkstack;
  2961.                     lcp := fprocp^.next;
  2962.                     while lcp <> nil do
  2963.                         with lcp^ do
  2964.                             begin
  2965.                                 align(parmptr, llc1);
  2966.                                 if klass = vars then
  2967.                                     if idtype <> nil then
  2968.                                         if idtype^.form > power then
  2969.                                             begin
  2970.                                                 if vkind = actual then
  2971.                                                     begin
  2972.                                                         gen2(50, 0, vaddr);(*lda*)
  2973.                                                         gen2t(54, 0, llc1, nilptr);(*lod*)
  2974.                                                         gen1(40, idtype^.size);(*mov*)
  2975.                                                     end;
  2976.                                                 llc1 := llc1 + ptrsize
  2977.                                             end
  2978.                                         else
  2979.                                             llc1 := llc1 + idtype^.size;
  2980.                                 lcp := lcp^.next;
  2981.                             end;
  2982.                 end;
  2983.             lcmax := lc;
  2984.             repeat
  2985.                 repeat
  2986.                     statement(fsys + [semicolon, endsy])
  2987.                 until not (sy in statbegsys);
  2988.                 test := sy <> semicolon;
  2989.                 if not test then
  2990.                     insymbol
  2991.             until test;
  2992.             if sy = endsy then
  2993.                 insymbol
  2994.             else
  2995.                 error(13);
  2996.             llp := display[top].flabel; (*test for undefined labels*)
  2997.             while llp <> nil do
  2998.                 with llp^ do
  2999.                     begin
  3000.                         if not defined then
  3001.                             begin
  3002.                                 error(168);
  3003.                                 writeln(output);
  3004.                                 writeln(output, ' label ', labval);
  3005.                                 write(output, ' ' : chcnt + 16)
  3006.                             end;
  3007.                         llp := nextlab
  3008.                     end;
  3009.             if fprocp <> nil then
  3010.                 begin
  3011.                     if fprocp^.idtype = nil then
  3012.                         gen1(42, ord('p'))(*ret*)
  3013.                     else
  3014.                         gen0t(42, fprocp^.idtype);(*ret*)
  3015.                     align(parmptr, lcmax);
  3016.                     if prcode then
  3017.                         begin
  3018.                             writeln(prr, 'l', segsize : 4, '=', lcmax);
  3019.                             writeln(prr, 'l', stacktop : 4, '=', topmax)
  3020.                         end
  3021.                 end
  3022.             else
  3023.                 begin
  3024.                     gen1(42, ord('p'));(*ret*)
  3025.                     align(parmptr, lcmax);
  3026.                     if prcode then
  3027.                         begin
  3028.                             writeln(prr, 'l', segsize : 4, '=', lcmax);
  3029.                             writeln(prr, 'l', stacktop : 4, '=', topmax);
  3030.                             writeln(prr, 'q')
  3031.                         end;
  3032.                     ic := 0;
  3033.       (*generate call of main program; note that this call must be loaded}
  3034. {        at absolute address zero*)
  3035.                     gen1(41, 0);(*mst*)
  3036.                     gencupent(46, 0, entname);(*cup*)
  3037.                     gen0(29);(*stp*)
  3038.                     if prcode then
  3039.                         writeln(prr, 'q');
  3040.                     saveid := id;
  3041.                     while fextfilep <> nil do
  3042.                         begin
  3043.                             with fextfilep^ do
  3044.                                 if not ((filename = 'input   ') or (filename = 'output  ') or (filename = 'prd     ') or (filename = 'prr     ')) then
  3045.                                     begin
  3046.                                         id := filename;
  3047.                                         searchid([vars], llcp);
  3048.                                         if llcp^.idtype <> nil then
  3049.                                             if llcp^.idtype^.form <> files then
  3050.                                                 begin
  3051.                                                     writeln(output);
  3052.                                                     writeln(output, ' ' : 8, 'undeclared ', 'external ', 'file', fextfilep^.filename : 8);
  3053.                                                     write(output, ' ' : chcnt + 16)
  3054.                                                 end
  3055.                                     end;
  3056.                             fextfilep := fextfilep^.nextfile
  3057.                         end;
  3058.                     id := saveid;
  3059.                     if prtables then
  3060.                         begin
  3061.                             writeln(output);
  3062.                             printtables(true)
  3063.                         end
  3064.                 end;
  3065.         end; (*body*)
  3066.  
  3067.     begin (*block*)
  3068.         dp := true;
  3069.         repeat
  3070.             if sy = labelsy then
  3071.                 begin
  3072.                     insymbol;
  3073.                     labeldeclaration(fsys) {FIX!!!}
  3074.                 end;
  3075.             if sy = constsy then
  3076.                 begin
  3077.                     insymbol;
  3078.                     constdeclaration(fsys) {FIX!!!}
  3079.                 end;
  3080.             if sy = typesy then
  3081.                 begin
  3082.                     insymbol;
  3083.                     typedeclaration(fsys) {FIX!!!}
  3084.                 end;
  3085.             if sy = varsy then
  3086.                 begin
  3087.                     insymbol;
  3088.                     vardeclaration(fsys) {FIX!!!}
  3089.                 end;
  3090.             while sy in [procsy, funcsy] do
  3091.                 begin
  3092.                     lsy := sy;
  3093.                     insymbol;
  3094.                     procdeclaration(lsy)
  3095.                 end;
  3096.             if sy <> beginsy then
  3097.                 begin
  3098.                     error(18);
  3099.                     skip(fsys)
  3100.                 end
  3101.         until (sy in statbegsys) or eof(input);
  3102.         dp := false;
  3103.         if sy = beginsy then
  3104.             insymbol
  3105.         else
  3106.             error(17);
  3107.         repeat
  3108.             body(fsys + [casesy]);
  3109.             if sy <> fsy then
  3110.                 begin
  3111.                     error(6);
  3112.                     skip(fsys)
  3113.                 end
  3114.         until ((sy = fsy) or (sy in blockbegsys)) or eof(input);
  3115.     end; (*block*)
  3116. end.