home *** CD-ROM | disk | FTP | other *** search
-
- (*
- * TPTC - Turbo Pascal to C translator
- *
- * (C) 1988 Samuel H. Smith (rev. 13-Feb-88)
- *
- *)
-
-
- (********************************************************************)
- procedure error (message: anystring);
- {place an error message into the object file and on the screen}
-
- procedure report(var fd: text);
- begin
- writeln(fd);
- writeln(fd,'/* TPTC: ', message,
- ', token="', tok,
- '", source line ',srclines[level],' */');
- end;
-
- begin
- write(con,srcfiles[level],'(',srclines[level],') ');
- report(con);
- report(ofd[level]);
- end;
-
-
- (********************************************************************)
- procedure syntax (message: anystring);
- {report a syntax error and skip to the next ';'}
- begin
- error(message);
-
- while ltok <> ';' do
- gettok;
-
- gettok;
- end;
-
-
- (********************************************************************)
- procedure abortcheck;
- {check for the abort(escape) key}
- var
- c: char;
-
- begin
- flush(output);
-
- if keypressed then
- begin
- c := readkey;
-
- if c = #27 then
- begin
- error('Aborted by <escape> key');
- close(ofd[level]);
- halt;
- end;
- end;
- end;
-
-
- (********************************************************************)
- procedure puttok;
- {output the current token and a space to the output}
- begin
- write(ofd[level],ltok,' ');
- end;
-
-
- (********************************************************************)
- procedure newline;
- {start a new line in the output file; indent to the same level
- as the current line}
- begin
- writeln(ofd[level]);
- write(ofd[level],spaces);
- end;
-
-
- (********************************************************************)
- procedure endfile;
- {report that unexpected end-of-file has been seen}
- begin
- error('No main block');
- close(ofd[level]);
- halt;
- end;
-
-