         Edinburgh IMP77 Compiler - Version 8.4

    1  ! Testing comment removal
    2  %begin
    3  
    4  %constintegerarray fred(0:2) = ;! A comment here???!
    5+           1,2,
    6+           ! comment?
    7+           3
    8  
    9  %routine jim(%integer p,
   10+              %integer q)
   11  %end
?Q unused
?P unused
   12  
   13  
   14  ! Imp77 allows multiple blank lines following a continuation (%c or ',' or '=')
   15  
   16  %constc
   17+ 
   18+ 
   19+ %integerarray sheila(0:2) =
   20+ 
   21+ 
   22+           1,2,
   23+ 
   24+           3
   25  
   26  
   27  %switch lab(1:4)
   28  %integer i
   29  %constinteger one=1, two=2, three=3
   30  
   31  i = sheila(2)
   32  
   33  lab(':'+one+two-':'):  !    i=9
   34                                          ;! %commc
   35                                           ! %ment { here
   36  print string("test 0"); newline
   37  print string("If there is output mentioning test 0 above, test 0 passed"); newline
   38  
   39  %comment %c {}
   40  print string("test 1"); newline   ;! The {} after the %c nullifies the continuation.
   41  print string("If there is output mentioning test 1 above, test 1 passed"); newline
   42  
   43  %comment %c
   44+ print string("test 2a failed - this is part of the comment above") %and newline; print string("test 2b failed - semicolons should not be honoured in %comments"); newline
   45  print string("If there is no output mentioning test 2 above, test2 passed"); newline
   46  ! Trailing space below:
   47  %comment %c 
   48  print string("test 3"); newline
   49  print string("If there is output mentioning test 3 above, test 3 passed"); newline
   50  
   51  ! Trailing tab below:
   52  %comment %c      
   53  print string("test 4"); newline
   54  print string("If there is output mentioning test 4 above, test 4 passed"); newline
   55  
   56  
   57  lab(':'+two+two*':'-':'*3): %comment %c
   58+ error?
   59  
   60                                          %comment ' { again
   61                                          %comment   { 'again
   62                                          %comment   { again } '
   63  
   64  %comment %c
   65+ 
   66+ This this part of the comment in Imp77!
   67  
   68  ! %c
   69  print string("Note that %c is not honoured within a '!' comment..."); newline
   70  
   71  !  a comment with an unbalanced ' is a problem
   72  print string("test 5 passed"); newline
   73  
   74  {  a comment with an unbalanced ' is a problem
   75  print string("test 6 passed"); newline
   76  
   77  {  a comment with an unbalanced ' is a problem }
   78  print string("test 7 passed"); newline
   79  
   80  %comment  a comment with an unbalanced ' is a problem
   81  print string("test 8 passed"); newline
   82  
   83  lab(*):
   84  !}
   85  
   86  ! The conclusion from these tests is that "!" or "{" after a label don't need special handling
   87  ! but that we should pass "%comment" through untouched
   88  
   89  ! And that whitespace characters after "%c" are significant.
   90  
   91  %end{}%of%pro %gram
?THREE unused
?JIM unused
?FRED unused

   38 Statements compiled
