Old secrets of quick debugging: source code animation

Friday evening often turns out to be an evening of memories, and not only about the past week, but about much earlier events. This Friday, I remembered one interesting program for MS DOS (as well as for Mac OS, UNIX and VAX /VMS) - Pascal interpreter and IDE Dr. Pascal. Detailed information about the features and reviews can be found on the archive manufacturer site Visible Software (USA), and I will confine myself to the most memorable ideas for me, and these ideas, in my opinion, even today have not lost their relevance. First of all, remember the picture:
 3r33434. 3r33417.  3r33434. Old secrets of quick debugging: source code animation 3r33417.  3r33434. PascalS written in pascal. Compared to queens, this program, with a volume of about 2000 lines of source code, is much more complicated. She was in the original form beyond the powers of the doctor, so I cut it into two parts. 3r33417.  3r33434. 3r33417.  3r33434. 3r33333. 3r33333. The first part prepares data files: [/b]
3r33333. {% F- no reformatting}
{% O +}
program Pas1 (input, output, paskey, pasksy, spsfile, enterf, symsetf {, textf}); 3r33434. 3r33434. const
nkw = 27; (* no. of key words *)
alng = 10; (* no. of significant chars in identifiers *)
type
symbol = (intcon, realcon, charcon, string,
notsy, plus, minus, times, idiv, rdiv, imod, andsy, orsy,
eql, neq, gtr, geq, lss, leq,
lparent, rparent , lbrack, rbrack, comma, semicolon, period,
capon, becomes, constsy, typesy, varsy, functionsy,
, procedurey, arraysy, recordsy, programsy, ident,
,
(endsy, elsesy, untilsy, ​​ofsy, dosy, tosy, downtosy, thensy); 3r33434. alfa = packed array[1alng]of char; 3r33434. object = (constant, variable, type? prozedure, funktion); 3r33434. types = (notyp, ints, reals, bools, chars, arrays, records); 3r33434. keytype = array[1nkw]of alfa; 3r33434. ksytype = array[1nkw]of symbol; 3r33434. spstype = array[char]of symbol; 3r33434. symset = set of symbol; 3r33434. entertype = record
fx0: alfa; fx1: object; 3r33434. fx2: types; fx3: integer; 3r33434. end; 3r33434. 3r33434. var
key: keytype; 3r33434. ksy: ksytype; 3r33434. sps: spstype; (* special symbols *)
syset: symset; 3r33434. pasksy: file of ksytype; 3r33434. paskey: file of keytype; 3r33434. spsfile: file of spstype; 3r33434. enterf: file of entertype; 3r33434. symsetf: file of symset; 3r33434. {textf: text;}
3r33434. procedure enter (x0: alfa; x1: object;
x2: types; x3: integer); 3r33434. 3r33434. var
EnterRec: EnterType; 3r33434. 3r33434. begin
with EnterRec do
begin fx0: = x0; fx1: = x1; 3r33434. fx2: = x2; fx3: = x3
end; 3r33434. write (enterf, enterrec); 3r33434. end (* enter *); 3r33434. 3r33434. begin {main program}
key[1]: = 'and'; key[2]: = 'array'; 3r33434. key[3]: = 'begin'; key[4]: = 'case'; 3r33434. key[5]: = 'const'; key[6]: = 'div'; 3r33434. key[7]: = 'do'; key[8]: = 'downto'; 3r33434. key[9]: = 'else'; key[10]: = 'end'; 3r33434. key[11]: = 'for'; key[12]: = 'function'; 3r33434. key[13]: = 'if'; key[14]: = 'mod'; 3r33434. key[15]: = 'not'; key[16]: = 'of'; 3r33434. key[17]: = 'or'; key[18]: = 'procedure'; 3r33434. key[19]: = 'program'; key[20]: = 'record'; 3r33434. key[21]: = 'repeat'; key[22]: = 'then'; 3r33434. key[23]: = 'to'; key[24]: = 'type'; 3r33434. key[25]: = 'until'; key[26]: = 'var'; 3r33434. key[27]: = 'while'; 3r33434. ksy[1]: = andsy; ksy[2]: = arraysy; 3r33434. ksy[3]: = beginsy; ksy[4]: = casesy; 3r33434. ksy[5]: = constsy; ksy[6]: = idiv; 3r33434. ksy[7]: = dosy; ksy[8]: = downtosy; 3r33434. ksy[9]: = elsesy; ksy[10]: = endsy; 3r33434. ksy[11]: = forsy; ksy[12]: = functionsy; 3r33434. ksy[13]: = ifsy; ksy[14]: = imod; 3r33434. ksy[15]: = notsy; ksy[16]: = ofsy; 3r33434. ksy[17]: = orsy; ksy[18]: = proceduresy; 3r33434. ksy[19]: = programsy; ksy[20]: = recordsy; 3r33434. ksy[21]: = repeatsy; ksy[22]: = thensy; 3r33434. ksy[23]: = tosy; ksy[24]: = typesy; 3r33434. ksy[25]: = untilsy; ksy[26]: = varsy; 3r33434. ksy[27]: = whilesy; 3r33434. rewrite (paskey); 3r33434. write (paskey, key); 3r33434. 3r33434. ksy[1]: = andsy; ksy[2]: = arraysy; 3r33434. ksy[3]: = beginsy; ksy[4]: = casesy; 3r33434. ksy[5]: = constsy; ksy[6]: = idiv; 3r33434. ksy[7]: = dosy; ksy[8]: = downtosy; 3r33434. ksy[9]: = elsesy; ksy[10]: = endsy; 3r33434. ksy[11]: = forsy; ksy[12]: = functionsy; 3r33434. ksy[13]: = ifsy; ksy[14]: = imod; 3r33434. ksy[15]: = notsy; ksy[16]: = ofsy; 3r33434. ksy[17]: = orsy; ksy[18]: = proceduresy; 3r33434. ksy[19]: = programsy; ksy[20]: = recordsy; 3r33434. ksy[21]: = repeatsy; ksy[22]: = thensy; 3r33434. ksy[23]: = tosy; ksy[24]: = typesy; 3r33434. ksy[25]: = untilsy; ksy[26]: = varsy; 3r33434. ksy[27]: = whilesy; 3r33434. rewrite (pasksy); 3r33434. write (pasksy, ksy); 3r33434. 3r33434. sps['+']: = plus; sps['-']: = minus; 3r33434. sps['*']: = times; sps['/']: = rdiv; 3r33434. sps['(']: = lparent; sps[')']: = rparent; 3r33434. sps['=']: = eql; sps[',']: = comma; 3r33434. sps['[']: = lbrack; sps[']']: = rbrack; 3r33434. sps['#']: = neq; sps['&']: = andsy; 3r33434. sps[';']: = semicolon; 3r33434. rewrite (spsfile); 3r33434. write (spsfile, sps); 3r33434. 3r33434. rewrite (enterf); 3r33434. enter (", variable, notyp, 0); (* sentinel *)
enter ('false', konstant, bools, 0); 3r33434. enter ('true', konstant, bools, 1); 3r33434. enter ('real', type? reals, 1); 3r33434. enter ('char', type? chars, 1); 3r33434. enter ('boolean', type? bools, 1); 3r33434. enter ('integer', type? ints, 1); 3r33434. enter ('abs', funktion, reals, 0); 3r33434. enter ('sqr', funktion, reals, 2); 3r33434. enter ('odd', funktion, bools, 4); 3r33434. enter ('chr', funktion, chars, 5); 3r33434. enter ('ord', funktion, ints, 6); 3r33434. enter ('succ', funktion, chars, 7); 3r33434. enter ('pred', funktion, chars, 8); 3r33434. enter ('round', funktion, ints, 9); 3r33434. enter ('trunc', funktion, ints, 10); 3r33434. enter ('sin', funktion, reals, 11); 3r33434. enter ('cos', funktion, reals, 12); 3r33434. enter ('exp', funktion, reals, 13); 3r33434. enter ('ln', funktion, reals, 14); 3r33434. enter ('sqrt', funktion, reals, 15); 3r33434. enter ('arctan', funktion, reals, 16); 3r33434. enter ('eof', funktion, bools, 17); 3r33434. enter ('eoln', funktion, bools, 18); 3r33434. enter ('read', prozedure, notyp, 1); 3r33434. enter ('readln', prozedure, notyp, 2); 3r33434. enter ('write', prozedure, notyp, 3); 3r33434. enter ('writeln', prozedure, notyp, 4); 3r33434. enter (", prozedure, notyp, 0); 3r33434. 3r33434. rewrite (symsetf); 3r33434. syset: =[plus,minus,intcon,realcon,charcon,ident]; 3r33434. write (symsetf, syset); 3r33434. syset: =[ident,arraysy,recordsy]; 3r33434. write (symsetf, syset); 3r33434. syset: =[constsy,typesy,varsy,proceduresy,functionsy,beginsy]; 3r33434. write (symsetf, syset); 3r33434. syset: =[intcon,realcon,charcon,ident,lparent,notsy]; 3r33434. write (symsetf, syset); 3r33434. syset: =[beginsy,ifsy,whilesy,repeatsy,forsy,casesy]; 3r33434. write (symsetf, syset); 3r33434. 3r33434. end. 3r33434. 3r3403. 3r3404. 3r33417.  3r33434.
3r33417.  3r33434. Here it is necessary to clarify that the directives Dr. Pascal are enclosed in comment braces and begin with a “%” character. The directive {% O +} includes a simplified file name, in which, for example, an external file defined as
 3r33434. 3r33417.  3r33434. 3r33333. pasksy: file of ksytype; 3r3403. 3r3404. 3r33417.  3r33434. it will be called “pasksy”. Like any external file, it must be specified in the program header:
 3r33434. 3r33417.  3r33434. 3r33333. program Pas1 (input, output, paskey, 3r3403.
 3r33434. In the rest of the PascalS also specify the data files:
 3r33434. 3r33417.  3r33434. 3r33333. {% D +}
{% F- no reformatting}
{% O +}
program Pascals (input, output, paskey, pasksy, spsfile, enterf, symsetf); {???}
3r3403. 3r3404. 3r33417.  3r33434. The% D + directive allows you to programmatically stop the animation by calling the predefined Freeze procedure. 3r33417.  3r33434. 3r33417.  3r33434. The body of the PascalS program will look like this:
 3r33434. 3r33417.  3r33434. 3r33333. begin {main program}
assign (input, 'QUEENS.PAS'); 3r33434. reset (input); 3r33434. init; 3r33434. block (blockbegsys + statbegsys, false, 1); 3r33434. finish; 3r33434. 99: end. 3r33434. 3r3403. 3r3404. 3r33417.  3r33434. 3r33333. 3r33333. Where init and finish procedures are: [/b]
3r33333. procedure init; 3r33434. {% s-}
3r33434. var
i: integer; 3r33434. EnterRec: EnterType; 3r33434. 3r33434. begin
writeln; 3r33434. reset (paskey); read (paskey, key); 3r33434. reset (pasksy); read (pasksy, ksy); 3r33434. reset (spsfile); read (spsfile, sps); 3r33434. reset (symsetf); 3r33434. read (symsetf, constbegsys, typebegsys, blockbegsys, facbegsys, statbegsys); 3r33434. stantyps: =[notyp,ints,reals,bools,chars]; 3r33434. lc: = 0; ll: = 0; cc: = 0; ch: = ''; 3r33434. errpos: = 0; errs: =[]; insymbol; 3r33434. t: = -1; a: = 0; b: = 1; sx: = 0; c2: = 0; 3r33434. display[0]: = 1; 3r33434. iflag: = false; oflag: = false; 3r33434. if sy <> programsy then freeze{3} else
begin insymbol; 3r33434. if sy <> ident then freeze{2} else
begin progname: = id; insymbol; 3r33434. if sy <> lparent then freeze{9} else
repeat insymbol; 3r33434. if sy <> ident then freeze{2} else
begin if id = 'input' then iflag: = true else
if id = 'output' then oflag: = true else freeze {0}; 3r33434. insymbol; 3r33434. end
until sy <> comma;
if sy = rparent then insymbol else freeze {4}; 3r33434. if not oflag then freeze {20}; 3r33434. end
end; 3r33434. reset (enterf); 3r33434. while not eof (enterf) do
begin
read (enterf, enterrec); 3r33434. with EnterRec do
enter (fx? fx? fx? fx3); 3r33434. end; 3r33434. with btab[1]do
begin last: = t; lastpar: = 1; psize: = 0; vsize: = 0
end; 3r33434. end {init}; 3r33434. 3r33434. procedure finish; 3r33434. {% s-}
3r33434. begin
if sy <> period then freeze{22};
{emit (31)}; {halt}
if btab[2].vsize> stacksize then freeze {49}; 3r33434. end {finish}; 3r33434. 3r3403. 3r3404. 3r33417.  3r33434.
3r33417.  3r33434. The% s- directive disables the animation and display of variable values ​​inside the procedure in which it is specified. 3r33417.  3r33434. 3r33417.  3r33434. After making these changes, I downloaded and executed the first part (Pas1), and then the second. PascalS read the queens and began to broadcast them (see the picture at the beginning). It was difficult to follow the continuous animation of such a large code as PascalS, therefore it called freeze at key points and numbered the calls in the comments. Having understood the situation, continued the animation team Continue. I think that in modern IDE modern languages ​​such animators would be useful. 3r33417.  3r33434. 3r33417.  3r33434. The “games” described here have been doing for a long time at 3r33419. 286 CPU 3r33434. under 3r33421. MS DOS 3.2 r3r3428 , now just launched old files to make pictures. In conclusion, I remembered an interesting fact about the distribution of Dr. Pascal. The basic delivery consisted of a user manual - a book of about 200 pages on good thick paper and a floppy disk. It cost $ ???US and was positioned as low cost software. Licenses for dozens of jobs in universities were much cheaper in terms of 1 copy. But besides States and, for example., Australia, Dr. Pascal was popular in India. As far as I know, a local company was sold a license for distribution in India, and this company itself printed books (also in English 1: 1 with the original) and wrote floppy disks. The books were on newsprint with blind text, but the price was in terms of rupees about $ 4US. The same company replicated other products popular at the time, such as LOTUS 1-2-3 , 3r33434. dBase-4
, ChiWriter etc. for about the same price.
3r33434. 3r33434. 3r33434. 3r33334. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () ();
3r33434.
+ 0 -

Add comment