|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 13740 (0x35ac)
Types: TextFile
Names: »mytangle.diff«
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89
└─⟦this⟧ »./DVIware/lpr-viewers/crudetype/mytangle.diff«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z«
└─⟦ca79c7339⟧
└─⟦this⟧ »DVIware/lpr-viewers/crudetype/mytangle.diff«
*** mytangle.web Tue Mar 7 18:39:05 1989
--- tangle.web Fri Jan 6 15:21:59 1989
***************
*** 12,18 ****
% Version 2.7 fixed the definition of check_sum_prime (May, 1985).
% Version 2.8 fixed a bug in change_buffer movement (August, 1985).
% Version 2.9 allows nonnumeric macros before their definition (December, 1988).
- % RMD's attempts to improve error detection
% Here is TeX material that gets inserted after \input webmac
\def\hang{\hangindent 3em\indent\ignorespaces}
--- 12,17 ----
***************
*** 89,96 ****
Other parts, delimited by |stat| and $|tats|$, are optionally included if
statistics about \.{TANGLE}'s memory usage are desired.
! @d debug== {change this to `$\\{debug}\equiv\null$' when debugging}
! @d gubed== {change this to `$\\{gubed}\equiv\null$' when debugging}
@f debug==begin
@f gubed==end
@#
--- 88,95 ----
Other parts, delimited by |stat| and $|tats|$, are optionally included if
statistics about \.{TANGLE}'s memory usage are desired.
! @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
! @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
@f debug==begin
@f gubed==end
@#
***************
*** 472,485 ****
for i:=1 to @'37 do xchr[i]:=' ';
@ The following system-independent code makes the |xord| array contain a
! suitable inverse to the information in |xchr|. The procedure |init_xord| is
! intended to set all entries of |xord| to |invalid_code|, so that out-of-range
! characters in the input can be detected.
- @d invalid_code= @'177
-
@<Set init...@>=
- init_xord( xord) ;
for i:=first_text_char to last_text_char do xord[chr(i)]:=@'40;
for i:=1 to @'176 do xord[xchr[i]]:=i;
\f
@* Input and output.
--- 471,479 ----
for i:=1 to @'37 do xchr[i]:=' ';
@ The following system-independent code makes the |xord| array contain a
! suitable inverse to the information in |xchr|.
@<Set init...@>=
for i:=first_text_char to last_text_char do xord[chr(i)]:=@'40;
for i:=1 to @'176 do xord[xchr[i]]:=i;
\f
@* Input and output.
***************
*** 574,601 ****
or |carriage_return|.
@p function input_ln(var f:text_file):boolean;
! {inputs a line or returns |false|}
var final_limit:0..buf_size; {|limit| without trailing blanks}
- c : text_char ;
begin limit:=0; final_limit:=0;
! if eof(f) then input_ln:=false
! else begin while not eoln(f) do
! begin c := f^ ; get(f);
! if xord[c] = invalid_code then
! @<Complain about bad character, and discard it@>
! else begin
! buffer[limit] := xord[c] ;
! incr(limit);
! if buffer[limit-1]<>" " then final_limit:=limit;
! if limit=buf_size then
! begin while not eoln(f) do get(f);
! decr(limit); {keep |buffer[buf_size]| empty}
! print_nl('! Input line too long'); loc:=0; error;
! @.Input line too long@>
! end;
end;
end;
! read_ln(f); limit:=final_limit; input_ln:=true;
end;
end;
\f
@* Reporting errors to the user.
--- 568,589 ----
or |carriage_return|.
@p function input_ln(var f:text_file):boolean;
! {inputs a line or returns |false|}
var final_limit:0..buf_size; {|limit| without trailing blanks}
begin limit:=0; final_limit:=0;
! if eof(f) then input_ln:=false
! else begin while not eoln(f) do
! begin buffer[limit]:=xord[f^]; get(f);
! incr(limit);
! if buffer[limit-1]<>" " then final_limit:=limit;
! if limit=buf_size then
! begin while not eoln(f) do get(f);
! decr(limit); {keep |buffer[buf_size]| empty}
! print_nl('! Input line too long'); loc:=0; error;
! @.Input line too long@>
end;
end;
! read_ln(f); limit:=final_limit; input_ln:=true;
end;
end;
\f
@* Reporting errors to the user.
***************
*** 1106,1114 ****
@.Identifier conflict...@>
for k:=byte_start[q] to byte_start[q+ww]-1 do print(xchr[byte_mem[w,k]]);
error; q:=0; {only one conflict will be printed, since |equiv[0]=0|}
- print_nl( 'missing @@ ?' );
- @.Missing \AT! @>
- @<Show last checkpoint@>;
not_found:
end
--- 1094,1099 ----
***************
*** 1386,1401 ****
"@@": print('@@@@');
verbatim: print('@@=');
force_line: print('@@\');
- and_sign: print('&');
- not_sign: print(' not ');
- set_element_sign: print(' in ');
- left_arrow: print(' := ');
- not_equal: print(' <> ');
- less_or_equal: print(' <= ');
- greater_or_equal: print(' >= ');
- equivalence_sign: print(' == ');
- or_sign: print(' or ');
-
othercases print(xchr[a])
endcases
\f
@* Stacks for output.
--- 1371,1376 ----
***************
*** 2053,2061 ****
@!n:integer; {number being scanned}
begin while stack_ptr>0 do
begin cur_char:=get_output;
! reswitch:
! @<Semicolon-else test@>;
! case cur_char of
0: do_nothing; {this case might arise if output ends unexpectedly}
@t\4@>@<Cases related to identifiers@>@;
@t\4@>@<Cases related to constants, possibly leading to
--- 2028,2034 ----
@!n:integer; {number being scanned}
begin while stack_ptr>0 do
begin cur_char:=get_output;
! reswitch: case cur_char of
0: do_nothing; {this case might arise if output ends unexpectedly}
@t\4@>@<Cases related to identifiers@>@;
@t\4@>@<Cases related to constants, possibly leading to
***************
*** 2546,2558 ****
"<": control_code:=module_name; {beginning of a module name}
"=": control_code:=verbatim; {beginning of \PASCAL\ verbatim mode}
"\": control_code:=force_line; {force a new line in \PASCAL\ output}
! ",", ">", "!", "?", "|", "/", "#", "+", ";", "0","1","2":
! control_code:=ignore; {Codes used by \.{WEAVE} but ignored by .{TANGLE}}
! othercases
! begin err_print('! Unknown control code: ', '@@', xchr[c]);
! @.Unknown control code@>
! control_code:=ignore;
! end;
endcases;
end;
--- 2519,2525 ----
"<": control_code:=module_name; {beginning of a module name}
"=": control_code:=verbatim; {beginning of \PASCAL\ verbatim mode}
"\": control_code:=force_line; {force a new line in \PASCAL\ output}
! othercases control_code:=ignore {ignore all other cases}
endcases;
end;
***************
*** 2993,3001 ****
a:=a mod @'400;
end;
module_name: if t<>module_name then goto done
! else
! begin @<Was an `@@ ' missed here? @>;
! app_repl((cur_module div @'400)+@'250);
a:=cur_module mod @'400;
end;
verbatim: @<Copy verbatim string from the buffer to |tok_mem|@>;
--- 2960,2966 ----
a:=a mod @'400;
end;
module_name: if t<>module_name then goto done
! else begin app_repl((cur_module div @'400)+@'250);
a:=cur_module mod @'400;
end;
verbatim: @<Copy verbatim string from the buffer to |tok_mem|@>;
***************
*** 3004,3013 ****
@.\AT!p is ignored in Pascal text@>
@.\AT!d is ignored in Pascal text@>
@.\AT!f is ignored in Pascal text@>
! ' is ignored in Pascal text: maybe @@ missing?');
! @.Missing \AT! @>
! @<Show last checkpoint@>;
! goto continue;
end;
new_module: goto done;
--- 2969,2975 ----
@.\AT!p is ignored in Pascal text@>
@.\AT!d is ignored in Pascal text@>
@.\AT!f is ignored in Pascal text@>
! ' is ignored in Pascal text'); goto continue;
end;
new_module: goto done;
***************
*** 3296,3435 ****
error_message: print_nl('(Pardon me, but I think I spotted something wrong.)');
fatal_message: print_nl('(That was a fatal error, my friend.)');
end {there are no other cases}
- \f
@* Error detection.
- This section is an attempt to improve \.{TANGLE} by making it detect certain
- errors. Most of the additional code goes in here, so as not to disturb the
- module numbers of the rest of the program.
-
- First: two consecutive modules in a \.{WEB} program must be separated by the
- string `@@ ' . If this is omitted, this error usually damages the \PASCAL
- output. If \.{TANGLE} does not detect this error, then the user will probably
- try to compile the damaged output. The likeliest result is that the compiler
- becomes confused, and prints lots of error reports that bear no clear relation
- to the cause of the trouble.
-
- In order to try to detect this error, \.{TANGLE} now enforces an extra rule of
- syntax: if the replacement text of one module includes a call of a second
- module, then that call may not be immediately followed (on the same input
- line) by `=' or `+=' . This rule is not really valid for \.{WEB} programs: one
- might want to say:
-
- $$ \hbox{if \AT!<the variable we are interested in \AT!>= 0 then...} $$
-
- but this construction seems unlikely in \.{PASCAL}, and it can still be used
- if you put the equals sign on the next line.
-
- @ Here is the code that performs the test. We have just read a module name
- within the replacement text of a module. |loc| should be pointing to the next
- character after the `@@>' that ends the module name. Note that we must look
- ahead without actually moving forward in the input file.
-
- @<Was an `@@ ' missed here? @>=
- try_loc := loc;
- while (buffer[try_loc] = " " ) and (try_loc < limit) do incr(try_loc);
- if (buffer[try_loc] = "+" ) and (try_loc < limit) then incr(try_loc);
- while (buffer[try_loc] = " " ) and (try_loc < limit) do incr(try_loc);
- if (buffer[try_loc] = "=" ) then
- begin
- err_print('Nested named module definitions. Was an @@ missing?');
- @. Nested named module @>@.Missing \AT! @>
- @<Show last checkpoint@>;
- end;
-
- @ This module will be called when \.{TANGLE} thinks it has found a missing
- `@@ '. It tries to help the programmer by indicating where the missing `@@ '
- should have been. It is not possible to tell the exact position, so \.{TANGLE}
- will only indicate a range of line numbers. The formal error is an illegal
- construction within the \.{PASCAL} code of the current module, and \.{TANGLE}
- says where it thinks that module started.
-
- @<Show last checkpoint@>=
- print_nl (' Pascal part of current module began at line ' , last_line:1 );
- if was_changing then print(' in change file');
- print_ln ( ' ');
-
- @ The checkpoint is set at the start of the \.{PASCAL} code of each module,
- also at the beginning of the program.
-
- @<Scan the \(definition part...@>=
- last_line := line ;
- was_changing := changing;
-
- @ @<Set init...@>=
- last_line := 0; {place where current module started}
- was_changing := false;
-
- @ @<Glob...@>=
- last_line, try_loc: integer ;
- was_changing: boolean;
-
- @ Another error is that of writing a program containing the sequence
- `|; else|', which \.{PASCAL} does not allow. This is easy to do, especially
- if the semicolon and the |else| come from different modules. Although there is
- absolutely no reason why you cannot say `|; else|' in \.{WEB}, it is still
- desirable that \.{TANGLE} should detect this, as (on some machines) \.{TANGLE}
- runs much faster than the \.{PASCAL} compiler. To detect this error requires
- quite a bit of ``cookery''. The first step is to put an |else| into the
- |byte_mem|.
-
- @<Glob...@>=
- point_else: name_pointer;
- semi_last: boolean ; {the last output was a semicolon}
-
- @ @<Initialize the input system@>=
- buffer[0] := "e" ; buffer[1] := "l" ;
- buffer[2] := "s" ; buffer[3] := "e" ;
- id_first := 0;
- id_loc := 4 ;
- point_else := id_lookup( normal);
- buffer[0] := " " ;
- semi_last := false ;
-
- @ Then |send_the_output| tests for `|; else|' . This test is crude; it will
- not recognise `ELSE' or `Else' or the output from `el \@\& se'.
-
- @<Semicolon-else test@>=
- if (cur_char = begin_comment) or (cur_char = join )
- or (cur_char = module_number) or (cur_char = 0 )
- or (cur_char = force_line) or (brace_level > 0 )
- then do_nothing
- else if cur_char = ";" then semi_last := true
- else if semi_last and (cur_char = identifier) and (cur_val = point_else)
- then err_print ('! semicolon-ELSE found')
- @.semicolon-ELSE found@>
- else semi_last := false;
-
- @ The next change is designed to catch out-of-range characters appearing in
- the input. On some systems (including VMS), characters in the range 128..255
- can cause very peculiar effects. Note that when a bad character is detected,
- the error message must not print that character, in case it messes up the
- terminal.
-
- @<Complain about bad character...@>=
- begin
- if limit > 0 then loc := limit-1 ;
- err_print
- ('bad character in input, skipped, ordinal value is: ', ord(c): 1);
- @.bad character in input...@>
- end
-
- @ A related difficulty is that \.{TANGLE} initialises only part of the |xord|
- array, namely the elements with ordinal values in the range 0..127. If the
- operating system allows characters with ordinal values outside that range,
- then the corresponding elements of |xord| will be undefined. This procedure
- tries to prevent this happening by dynamically determining the bounds of the
- |text_char| type. If the local version of \PASCAL does not allow conformant
- array parameters, then the installer will need to find out the right values
- for |first| and |last| and write them into this procedure by hand.
- @.system dependencies@>@.Conformant arrays@>
-
- @<Error handling procedures@>=
- procedure init_xord( var xx: array[first..last:text_char] of ASCII_code );
- var c: text_char;
- begin
- for c := first to last do
- xx[c] := invalid_code ;
- end;
\f
@* System-dependent changes.
This module should be replaced, if necessary, by changes to the program
that are necessary to make \.{TANGLE} work at a particular installation.
--- 3258,3263 ----