         Edinburgh IMP77 Compiler - Version 8.4

    1  ! File of externals followed by a main program.
    2  
    3  %recordformat rf ( %integer i, %real r, %record (rf) %name next)  ;! Are record format vars in a sub-scope?  Or is it just that formats are in a different name space?
    4  
    5  ! owns and externals are simpler declarations
    6  %externalinteger xi1
    7  %externalintegername xin1
    8  %externalreal xr1
    9  %externalinteger xi2,xi3
   10  %externalreal xcr1 = 3.1415
   11  %externalrealarray xra1(0:9)
   12  %externalrealarrayname xran1
   13  %externallongreal xclr1 = 3.1415
   14  %externallongrealarray xlra1(0:9)
   15  %externallongrealarrayname xlran1
   16  %externalintegernamearray xina1(0:9)
   17  %externalintegernamearrayname xinan1
   18  %externalstring(82) xs1
   19  %externalstring(82)%name xsn1
   20  %externalstring(82)%array xsa1(4:7)
   21  %externalstring(82)%arrayname xsan1
   22  %externalstring(82)%namearray xsna1(4:7)
   23  %externalstring(82)%namearrayname xsnan1
   24  %externalrecord (rf) xrec1
   25  %externalrecord (rf) %name xrecn1
   26  %externalrecord (rf) %array xreca1(2:3)
   27  %externalrecord (rf) %array %name xrecan1
   28  %externalrecord (rf) %name %array xrecna1(2:3)
   29  %externalrecord (rf) %name %array %name xrecnan1
   30  
   31  %externalintegerfn ifn1
   32    %result = xi1
   33  %end
   34  
   35  %externalintegermap imap1
   36    %result == xi1
   37  %end
   38  
   39  %externalroutine rt1
   40    %integer i1
   41    %routine rt1
   42    %end
   43  %end
?RT1 unused
?I1 unused
   44  
   45  %externalpredicate test1
   46    %true
   47  %end
   48  
   49  %externalroutine xrt1(%integer p1)
   50    %real r1
   51  %end
?R1 unused
?P1 unused
   52  
   53  %externalroutine xr2(%integer p1, p2, p3, p4)
   54    %real r1
   55  %end
?R1 unused
?P4 unused
?P3 unused
?P2 unused
?P1 unused
   56  
   57  %externalroutine xr3(%integer p1, p2, %real r1, r2)
   58    %real r3
   59  %end
?R3 unused
?R2 unused
?R1 unused
?P2 unused
?P1 unused
   60  
   61  %begin
   62  
   63    %integerfn use pointer(%integername n)
   64      %result = n
   65    %end
   66    
   67    %integerfn use scalar(%integer n)
   68      %result = n
   69    %end
   70    
   71    %integermap map scalar(%integer n)
   72      %owninteger local
   73      local = n;
   74      %result == local
   75    %end
   76  
   77    %routine increment(%integername var)
   78      var = var + 1
   79    %end
   80  
   81    %begin
   82    %integername ptr
   83  
   84    %integer i
   85  
   86    i = ptr
   87  
   88    i = ptr+ptr
   89  
   90    i = use scalar(ptr)
   91  
   92    i = use scalar(ptr+ptr)
   93  
   94    i = use scalar(ptr)+use scalar(ptr)
   95  
   96    ptr = i
   97  
   98    ptr = i+ptr
   99  
  100    ptr = use scalar(i)
  101  
  102    ptr = use scalar(ptr)
  103  
  104    ptr = use scalar(ptr+ptr)
  105  
  106    ptr = -ptr
  107    
  108    i = use pointer(ptr)
  109  
  110    i = use pointer(ptr)+use pointer(ptr)
  111  
  112    ptr = use pointer(i)
  113  
  114    ptr = use pointer(ptr)
  115  
  116    ->done %if ptr < ptr*ptr
  117  
  118    ->done %if ptr < i
  119  
  120    ->done %if ptr < use scalar(i)
  121  
  122    ->done %if ptr < use scalar(ptr)
  123  
  124    ->done %if ptr < use pointer(ptr)
  125  
  126    ->done %if i + ptr < i + use scalar(i)
  127  
  128    ->done %if i + ptr < i + use scalar(ptr)
  129  
  130    ->done %if i + ptr < i + use pointer(ptr)
  131  
  132    ->done %if use scalar(i) < use scalar(i)
  133  
  134    ->done %if use scalar(i) < use pointer(i)
  135  
  136    ->done %if use pointer(i) < use pointer(i)
  137  
  138    ->done %if i + use scalar(i) < use scalar(i)
  139  
  140    ->done %if i + use scalar(i) < use pointer(i)
  141  
  142    ->done %if i + use pointer(i) < use pointer(i)
  143  
  144    ->done %if ptr + use scalar(i) < use scalar(i)
  145  
  146    ->done %if ptr + use scalar(i) < use pointer(i)
  147  
  148    ->done %if ptr + use pointer(i) < use pointer(i)
  149  
  150    ->done %if i + ptr < i + map scalar(i)
  151  
  152    ->done %if i + ptr < i + map scalar(ptr)
  153  
  154    map scalar(4) = i
  155  
  156    map scalar(i) = i
  157  
  158    map scalar(ptr) = i
  159  
  160    map scalar(i + ptr) = i
  161  
  162    increment(i)
  163  
  164    increment(ptr)
  165  
  166    increment(map scalar(0))
  167    
  168    increment(map scalar(i))
  169    
  170    increment(map scalar(ptr))
  171    
  172    increment(map scalar(map scalar(0)))
  173    done:
  174    %end
  175    
  176    %integermapspec imap1
  177    %integer i1
  178    %integername in1
  179    %shortinteger si1
  180    %shortintegername sin1
  181    %byteinteger bi1
  182    %byteintegername bin1
  183    %real r1
  184    %realslong
  185    %real qr1
  186    %realsnormal
  187    %constreal cr1 = 3.1415
  188    %longreal lr1
  189    %constlongreal clr1 = 3.1415
  190    %integerfn ifn1
  191      %result = i1
  192    %end
  193    %integermap imap1
  194      %result == i1
  195    %end
  196    %routine rt1
  197      %integer i1
  198      %integer local1
  199      %routine rt1
  200        %integer local1
  201        local1 = 1
  202        i1 = 1
  203      %end
  204      local1 = 2
  205      i1 = 2
  206    %end
?RT1 unused
  207    
  208    %predicate test1
  209      %false
  210    %end
  211    
  212    %realarray ra1, ra1b(0:9), ra2, ra2b(10:19)
  213    %realarrayname ran1, ran2
  214    %longrealarray lra1, lra1b(0:9), lra2, lra2b(10:19)
  215    %longrealarrayname lran1, lran2
  216    %integernamearray ina1, ina1b(0:9), ina2, ina2b(10:19)
  217    %integernamearrayname inan1, inan2
  218    %string(82) s1, s2
  219    %string(82)%name sn1, sn2
  220    %string(82)%array sa1, sa1b(4:7), sa2, sa2b(9:10), sa3(1:100)
  221    %string(82)%arrayname san1, san2, san3
  222    %string(82)%namearray sna1, sna2(4:7), sna3(1:2)
  223    %string(82)%namearrayname snan1, snan2
  224    %record (rf) rec1, rec2
  225    %record (rf) %name recn1, recn2
  226    %record (rf) %array reca1,reca2(2:3),reca3(4:5)
  227    %record (rf) %array %name recan1,recan2
  228    %record (rf) %name %array recna1,recna2(2:3),recna3(1:2)
  229    %record (rf) %name %array %name recnan1,recnan2
  230  
  231    ! owns and externals are simpler declarations
  232    %owninteger oi1
  233    %ownintegername oin1
  234    %ownreal or1
  235    %ownlongreal olr1
  236    %owninteger oi2,oi3
  237    %ownreal ocr1 = 3.1415
  238    %ownlongreal oclr1 = 3.1415
  239    %ownrealarray ora1(0:9)
  240    %ownrealarrayname oran1
  241    %ownlongrealarray olra1(0:9)
  242    %ownlongrealarrayname olran1
  243    %ownintegernamearray oina1(0:9)
  244    %ownintegernamearrayname oinan1
  245    %ownstring(82) os1
  246    %ownstring(82)%name osn1
  247    %ownstring(82)%array osa1(4:7)
  248    %ownstring(82)%arrayname osan1
  249    %ownstring(82)%namearray osna1(4:7)
  250    %ownstring(82)%namearrayname osnan1
  251    %ownrecord (rf) orec1
  252    %ownrecord (rf) %name orecn1
  253    %ownrecord (rf) %array oreca1(2:3)
  254    %ownrecord (rf) %array %name orecan1
  255    %ownrecord (rf) %name %array orecna1(2:3)
  256    %ownrecord (rf) %name %array %name orecnan1
  257  
  258    %switch sw1(0:255), sw2('a':'z')
  259  
  260    %integer %array ia3, ia4(1:10), ia5(2:11,0:1,0:2)
  261  
  262    %integernamearray in3a1(2:11,0:1,0:2)
  263  
  264    i1 = 1
  265  
  266    !!!!!!!!!!!!!!!!!!!
  267  
  268    xi1 = 1
  269    xin1 == xi1
  270    xin1 = 1
  271    xr1 = 3.1
  272    xi2 = xi3
  273    xcr1 = 3.1415
  274    xra1(5) = xcr1
  275    xran1 == xra1
  276    xclr1 = 3.1415
  277    xlra1(2) = 3.1
  278    xlran1 == xlra1
  279    xlran1(2) = 3.2
  280    xina1(9) == xi1
  281    xinan1 == xina1
  282  
  283    %integer i
  284    %real r
  285    %name fred
  286    fred == i
  287    fred == r
  288  
  289  
  290    %begin
  291  
  292      %integer i
  293      %recordformat rf(%record (rf) %name next, %integer i)
  294  
  295      %record (rf) rec
  296      %record (rf) %name recn
  297      %record (rf) %array ra(0:10)
  298      %record (rf) %name %array rna(0:10)
  299      %record (rf) %name %array %name rnan
  300      %record (rf) %map rm(%integer i);  %result == rec;  %end
?I unused
  301      %integer x
  302      x = rec_i
  303      x = rec_next_i
  304      x = rec_next_next_i
  305      recn == ra(i)
  306      recn == ra(i)_next
  307      recn == ra(i)_next_next
  308      ra(i) = rec
  309      ra(i)_i = i
  310      ra(i)_next = rec
  311      ra(i)_next = recn
  312      ra(i)_next_i = i
  313      ra(i)_next_next = rec
  314      ra(i)_next_next = recn
  315      ra(i)_next_next_i = i
  316      x = ra(i)_i
  317      x = ra(i)_next_i
  318      x = ra(i)_next_next_i
  319      recn == rec
  320      x = recn_i
  321      x = recn_next_i
  322      x = recn_next_next_i
  323      recn = rec
  324      recn_i = i
  325      recn_next = rec
  326      recn_next_i = i
  327      recn_next_next = rec
  328      recn_next_next = recn
  329      recn_next_next_i = i
  330      recn == rna(i)
  331      recn == rna(i)_next
  332      recn == rna(i)_next_next
  333      rec = rna(i)
  334      rec = rna(i)_next
  335      rec = rna(i)_next_next
  336      x = rna(i)_i
  337      x = rna(i)_next_i
  338      x = rna(i)_next_next_i
  339      rnan == rna
  340      recn == rnan(i)
  341      recn == rnan(i)_next
  342      recn == rnan(i)_next
  343      rec  = rnan(i)
  344      rec  = rnan(i)_next
  345      rec  = rnan(i)_next
  346      x = rnan(i)_i
  347      x = rnan(i)_next_i
  348      x = rnan(i)_next_next_i
  349      rnan(i)_i = x
  350      rnan(i)_next = rec
  351      rnan(i)_next == recn
  352      rnan(i)_next_i = x
  353      rnan(i)_next_next = rec
  354      rnan(i)_next_next == recn
  355      rnan(i)_next_next_i = x
  356      recn == rm(i)
  357      recn == rm(i)_next
  358      recn == rm(i)_next_next
  359      recn_i = rm(i)_i
  360      recn_i = rm(i)_next_i
  361      recn_i = rm(i)_next_next_i
  362      rm(i) = rec
  363      rm(i)_next = rec
  364      rm(i)_next_i = x
  365      rm(i)_next == recn
  366      rm(i)_next_next = rec
  367      rm(i)_next_next_i = x
  368      rm(i)_next_next == recn
  369      x = rm(i)_i
  370      x = rm(i)_next_i
  371      x = rm(i)_next_next_i
  372      rm(i)_i = x
  373      rm(i)_next = rec
  374      rm(i)_next = recn
  375      rm(i)_next_i = x
  376      rm(i)_next_next = rec
  377      rm(i)_next_next = recn
  378      rm(i)_next_next_i = x
  379  
  380    %end
  381  
  382  done:
  383  
  384    %begin
  385    
  386    %recordformat fm (%byteintegerarray ra(-10:3), %integer x)
  387    %record (fm) jim
  388    %integer fred
  389    fred = jim_ra(3)
  390    jim_x = 123
  391  
  392    %end
  393  
  394  %endofprogram
?DONE unused
?IN3A1 unused
?IA5 unused
?IA4 unused
?IA3 unused
?SW2 unused
?SW1 unused
?ORECNAN1 unused
?ORECNA1 unused
?ORECAN1 unused
?ORECA1 unused
?ORECN1 unused
?OREC1 unused
?OSNAN1 unused
?OSNA1 unused
?OSAN1 unused
?OSA1 unused
?OSN1 unused
?OS1 unused
?OINAN1 unused
?OINA1 unused
?OLRAN1 unused
?OLRA1 unused
?ORAN1 unused
?ORA1 unused
?OCLR1 unused
?OCR1 unused
?OI3 unused
?OI2 unused
?OLR1 unused
?OR1 unused
?OIN1 unused
?OI1 unused
?RECNAN2 unused
?RECNAN1 unused
?RECNA3 unused
?RECNA2 unused
?RECNA1 unused
?RECAN2 unused
?RECAN1 unused
?RECA3 unused
?RECA2 unused
?RECA1 unused
?RECN2 unused
?RECN1 unused
?REC2 unused
?REC1 unused
?SNAN2 unused
?SNAN1 unused
?SNA3 unused
?SNA2 unused
?SNA1 unused
?SAN3 unused
?SAN2 unused
?SAN1 unused
?SA3 unused
?SA2B unused
?SA2 unused
?SA1B unused
?SA1 unused
?SN2 unused
?SN1 unused
?S2 unused
?S1 unused
?INAN2 unused
?INAN1 unused
?INA2B unused
?INA2 unused
?INA1B unused
?INA1 unused
?LRAN2 unused
?LRAN1 unused
?LRA2B unused
?LRA2 unused
?LRA1B unused
?LRA1 unused
?RAN2 unused
?RAN1 unused
?RA2B unused
?RA2 unused
?RA1B unused
?RA1 unused
?TEST1 unused
?RT1 unused
?IFN1 unused
?CLR1 unused
?LR1 unused
?CR1 unused
?QR1 unused
?R1 unused
?BIN1 unused
?BI1 unused
?SIN1 unused
?SI1 unused
?IN1 unused
?IMAP1 unused

  309 Statements compiled
