From 2ec8502b72574b244c1ed1e07383d8735aa90ac0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 28 May 2021 23:52:49 -0700 Subject: parser: remove some parser access functions. * parser.c (lisp_parse_impl): Access pi->eof directly instead of going through parser_eof. We are using pi->errors in the same expression! This is the only place pi->eof is needed. (read_file_common): Don't call parser_eof. Assume that if error_val emerges, and errors is zero, it must be eof. (read_eval_ret_last): Simplify: the code actually does nothing specia for eof versus errors, so we just bail if error_var emerges. (get_parser): Function removed. (parse_errors): This is the only caller of get_parser, which now just calls gethash to fetch the parser. (parser_eof): Function removed. (parse_init): sys:get-parser, sys:parser-errors and sys:parser-eof intrinsics removed. The C function parser_errors still exists; it is used in a few places. * parser.h (get_parser, parser_eof): Declarations removed. * share/txr/stdlib/compiler.tl (compile-file-conditionally): Use the new parse-errors function instead of the removed sys:parser-errors. Since that works on the stream, we don't have to call sys:get-parser. Because it returns nil if there are no errors, we drop the > test. --- share/txr/stdlib/compiler.tl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index e56dea66..e3d43658 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -2314,10 +2314,9 @@ (compile-form obj)) (dump-to-tlo out-stream out)) - (let ((parser (sys:get-parser in-stream))) - (when (> (sys:parser-errors parser) 0) - (error "~s: compilation of ~s failed" 'compile-file - (stream-get-prop in-stream :name))))) + (when (parse-errors in-stream) + (error "~s: compilation of ~s failed" 'compile-file + (stream-get-prop in-stream :name)))) (flush-stream out-stream) (set success t)))))) -- cgit v1.2.3