modernc.org/knuth@v0.0.4/tangle/tangle.ch (about)

     1  @x tangle.web:83:
     2  @d banner=='This is TANGLE, Version 4.6'
     3  @y
     4  @d banner=='This is TANGLE, Version 4.6 (gotangle v0.0-prereleaase)'
     5  @z
     6  
     7  @x tangle.web:83:
     8  @p @t\4@>@<Compiler directives@>@/
     9  program TANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool);
    10  label end_of_TANGLE; {go here to finish}
    11  const @<Constants in the outer block@>@/
    12  type @<Types in the outer block@>@/
    13  var @<Globals in the outer block@>@/
    14  @<Error handling procedures@>@/
    15  procedure initialize;
    16    var @<Local variables for initialization@>@/
    17    begin @<Set initial values@>@/
    18    end;
    19  @y
    20  @p @t\4@>@<Compiler directives@>@/
    21  program TANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool);
    22  const @<Constants in the outer block@>@/
    23  type @<Types in the outer block@>@/
    24  var @<Globals in the outer block@>@/
    25  @<Error handling procedures@>@/
    26  procedure initialize;
    27    var @<Local variables for initialization@>@/
    28    begin @<Set initial values@>@/
    29    end;
    30  @z
    31  
    32  @x tangle.web:174:
    33  @d othercases == others: {default for cases not listed explicitly}
    34  @y
    35  @d othercases == else {default for cases not listed explicitly}
    36  @z
    37  
    38  @x tangle.web:196:
    39  @!max_id_length=12; {long identifiers are chopped to this length, which must
    40    not exceed |line_length|}
    41  @!unambig_length=7; {identifiers must be unique if chopped to this length}
    42    {note that 7 is more strict than \PASCAL's 8, but this can be varied}
    43  @y
    44  @!max_id_length=32; {long identifiers are chopped to this length, which must
    45    not exceed |line_length|}
    46  @!unambig_length=32; {identifiers must be unique if chopped to this length}
    47  @z
    48  
    49  @x tangle.web:509:
    50  @d print(#)==write(term_out,#) {`|print|' means write on the terminal}
    51  @d print_ln(#)==write_ln(term_out,#) {`|print|' and then start new line}
    52  @d new_line==write_ln(term_out) {start new line}
    53  @d print_nl(#)==  {print information starting on a new line}
    54    begin new_line; print(#);
    55    end
    56  @y
    57  @d print(#)==write(#) {`|print|' means write on the terminal}
    58  @d print_ln(#)==write_ln(#) {`|print|' and then start new line}
    59  @d new_line==write_ln() {start new line}
    60  @d print_nl(#)==  {print information starting on a new line}
    61    begin new_line; print(#);
    62    end
    63  @d write_ln(#)==writeln(#)
    64  @d read_ln(#)==readln(#)
    65  @z
    66  
    67  @x tangle.web:525:
    68  rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
    69  
    70  @ The |update_terminal| procedure is called when we want
    71  to make sure that everything we have output to the terminal so far has
    72  actually left the computer's internal buffers and been sent.
    73  @^system dependencies@>
    74  
    75  @d update_terminal == break(term_out) {empty the terminal output buffer}
    76  @y
    77  @ The |update_terminal| procedure is called when we want
    78  to make sure that everything we have output to the terminal so far has
    79  actually left the computer's internal buffers and been sent.
    80  @^system dependencies@>
    81  
    82  @d update_terminal == {empty the terminal output buffer}
    83  @z
    84  
    85  @x tangle.web:691:
    86  @d fatal_error(#)==begin new_line; print(#); error; mark_fatal; jump_out;
    87    end
    88  
    89  @<Error handling...@>=
    90  procedure jump_out;
    91  begin goto end_of_TANGLE;
    92  end;
    93  @y
    94  @d fatal_error(#)==begin write_ln(stderr,#); error; mark_fatal; jump_out;
    95    end
    96  
    97  @<Error handling...@>=
    98  procedure jump_out;
    99  begin panic(end_of_TANGLE);
   100  end;
   101  @z
   102  
   103  @x tangle.web:3246:
   104  @p begin initialize;
   105  @<Initialize the input system@>;
   106  print_ln(banner); {print a ``banner line''}
   107  @<Phase I: Read all the user's text and compress it into |tok_mem|@>;
   108  stat for ii:=0 to zz-1 do max_tok_ptr[ii]:=tok_ptr[ii];@+tats@;@/
   109  @<Phase II:...@>;
   110  end_of_TANGLE:
   111  if string_ptr>256 then @<Finish off the string pool file@>;
   112  stat @<Print statistics about memory usage@>;@+tats@;@/
   113  @t\4\4@>{here files should be closed if the operating system requires it}
   114  @<Print the job |history|@>;
   115  end.
   116  @y
   117  @p begin initialize;
   118  @<Initialize the input system@>;
   119  print_ln(banner); {print a ``banner line''}
   120  @<Phase I: Read all the user's text and compress it into |tok_mem|@>;
   121  stat for ii:=0 to zz-1 do max_tok_ptr[ii]:=tok_ptr[ii];@+tats@;@/
   122  @<Phase II:...@>;
   123  if string_ptr>256 then @<Finish off the string pool file@>;
   124  stat @<Print statistics about memory usage@>;@+tats@;@/
   125  @t\4\4@>{here files should be closed if the operating system requires it}
   126  @<Print the job |history|@>;
   127  end.
   128  @z
   129  
   130  
   131  @x tangle.web:3300:
   132  case history of
   133  spotless: print_nl('(No errors were found.)');
   134  harmless_message: print_nl('(Did you see the warning message above?)');
   135  error_message: print_nl('(Pardon me, but I think I spotted something wrong.)');
   136  fatal_message: print_nl('(That was a fatal error, my friend.)');
   137  end {there are no other cases}
   138  @y
   139  case history of
   140  spotless: print_nl('(No errors were found.)');
   141  harmless_message: print_nl('(Did you see the warning message above?)');
   142  error_message: print_nl('(Pardon me, but I think I spotted something wrong.)');
   143  fatal_message: print_nl('(That was a fatal error, my friend.)');
   144  end {there are no other cases}
   145  ;write_ln(output)
   146  @z