diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-05-30 21:41:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-05-30 21:41:03 -0700 |
commit | 6846740ce44659a1f31e01054b0f1bcc8dc04c7a (patch) | |
tree | 14912dd2d0ecd0702ca9d67d0fdd965d24a75478 /parser.c | |
parent | d87f9b4b380df188a17b6c1b04c4d24d7d79f98e (diff) | |
download | txr-6846740ce44659a1f31e01054b0f1bcc8dc04c7a.tar.gz txr-6846740ce44659a1f31e01054b0f1bcc8dc04c7a.tar.bz2 txr-6846740ce44659a1f31e01054b0f1bcc8dc04c7a.zip |
command line: -e takes multiple forms.
* parser.[ch] (read_objects_from_string): New function.
* txr.c (help): Update description of -e, and don't
describe -p as being like -e.
(txr_main): Implement -e using read_objects_from_string,
with progn consed to the front. Don't evaluate if it
returns the error value colon_k.
* txr.1: Documentation updated.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -891,6 +891,31 @@ val read_compiled_file(val self, val stream, val error_stream) return read_file_common(self, stream, error_stream, t); } +val read_objects_from_string(val string, val error_stream, + val error_return_val, val name_in) +{ + val self = lit("read-objects-from-string"); + val stream = make_string_byte_input_stream(string); + val name = default_arg(name_in, lit("string")); + val parser = ensure_parser(stream, name); + list_collect_decl (out, ptail); + + for (;;) { + val form = lisp_parse_impl(self, prime_lisp, t, stream, + error_stream, unique_s, name, colon_k); + + if (form == unique_s) { + if (parser_errors(parser) != zero) + return error_return_val; + break; + } + + ptail = list_collect(ptail, form); + } + + return out; +} + val txr_parse(val source_in, val error_stream, val error_return_val, val name_in) { |