From ba9a6aade4adf32b4361aa8db8b156fdb40e2cd5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 10 Jan 2014 20:11:38 -0800 Subject: * eval.c (eval_init): Renaming lisp-parse to read; lisp-parse is retained as an obsolescent synonym. All arguments become optional. * parser.l (lisp_parse): Handle nil source. * txr.1: Updated. --- ChangeLog | 9 +++++++++ eval.c | 3 ++- parser.l | 6 ++++-- txr.1 | 16 +++++++++------- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5cf8026..4b9259ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-01-10 Kaz Kylheku + + * eval.c (eval_init): Renaming lisp-parse to read; lisp-parse + is retained as an obsolescent synonym. All arguments become optional. + + * parser.l (lisp_parse): Handle nil source. + + * txr.1: Updated. + 014-01-10 Kaz Kylheku * match.c (do_txeval): Lift an annoying restriction in the pattern diff --git a/eval.c b/eval.c index 25a6c0be..b8e2155c 100644 --- a/eval.c +++ b/eval.c @@ -2411,7 +2411,8 @@ void eval_init(void) reg_fun(intern(lit("hash-isec"), user_package), func_n2(hash_isec)); reg_fun(intern(lit("eval"), user_package), func_n2o(eval_intrinsic, 1)); - reg_fun(intern(lit("lisp-parse"), user_package), func_n2o(lisp_parse, 1)); + reg_fun(intern(lit("lisp-parse"), user_package), func_n2o(lisp_parse, 0)); + reg_fun(intern(lit("read"), user_package), func_n2o(lisp_parse, 0)); reg_fun(intern(lit("chain"), user_package), func_n0v(chainv)); reg_fun(intern(lit("andf"), user_package), func_n0v(andv)); diff --git a/parser.l b/parser.l index 6ffc4db8..449fb236 100644 --- a/parser.l +++ b/parser.l @@ -850,11 +850,13 @@ val regex_parse(val string, val error_stream) val lisp_parse(val source, val error_stream) { uses_or2; - val input_stream = if3(stringp(source), make_string_byte_input_stream(source), source); + val input_stream = if3(stringp(source), + make_string_byte_input_stream(source), + or2(source, std_input)); val secret_token_stream = make_string_byte_input_stream(lit("@\x01" "E")); val name = if3(stringp(source), format(nil, lit("expr: ~s"), source, nao), - stream_get_prop(source, name_k)); + stream_get_prop(input_stream, name_k)); val save_stream = std_error; yyin_stream = make_catenated_stream(list(secret_token_stream, input_stream, nao)); errors = 0; diff --git a/txr.1 b/txr.1 index 587e67e0..c52c4161 100644 --- a/txr.1 +++ b/txr.1 @@ -4972,7 +4972,7 @@ Restrictions: The notation must be enclosed in a list. For instance a..b is not an expression, but (a..b) is. This is important if Lisp data is being parsed from -a string or stream using the lisp-parse function. If the data "a..b" is +a string or stream using the read function. If the data "a..b" is parsed, the symbol "a" will be extracted, leaving "..a", which, if parsed, produces a syntax error since it consists of a "dotdot" token followed by a symbol, which is not valid syntax, akin to something like ")a" or ".a". @@ -10530,22 +10530,24 @@ the stream-real-time-p function above), and also for setting the priority at which messages are reported to syslog by the *stdlog* stream (see *stdlog* in the UNIX SYSLOG section). -.SS Function lisp-parse +.SS Function read .TP Syntax: - (lisp-parse : ) + (read : ) + (lisp-parse : ) ;; obsolescent synonym for read .TP Description: -The lisp-parse function converts text denoting TXR Lisp structure, into the +The read function converts text denoting TXR Lisp structure, into the corresponding data structure. The argument may be either a character -string, or a stream. The source must provide the syntax of one complete Lisp -object. +string, or a stream. If it is omitted, then *stdin* is used as the stream. -Multiple calls to lisp-parse on the same stream will extract successive objects +The source must provide the text representation of one complete TXR Lisp object. + +Multiple calls to read on the same stream will extract successive objects from the stream. To parse successive objects from a string, it is necessary to convert it to a string stream. -- cgit v1.2.3