From f2a2306a8bd6fb86b4819875f752e3a836f1533d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 10 Aug 2015 06:43:37 -0700 Subject: Diagnose bad consing dot syntax like (a . b . c). * parser.y (r_exprs): Use unique object in the terminating cons to indicate the empty spot where the dotted cdr item will go. Check for misplaced consing dot. (misplaced_consing_dot_check): New static function. Checks for the terminator atom spot being taken already. Thus, the spot may be taken only by the very last reduction, such that the next reduction is r_exprs -> n_exprs where the terminating atom is processed. * parser.c (unique_s): New global variable. (parse_init): Initialize unique_s. * parser.h (unique_s): Declared. * share/txr/stdlib/place.tl (sys:placelet-1): We have a misplaced consing dot here! It was working correctly by "terminating atom propagation" behavior, which allowed (a . b c d) to produce (a c d . b). If a single terminating atom occurred in the middle of a list, it was promoted to the end. --- parser.h | 1 + 1 file changed, 1 insertion(+) (limited to 'parser.h') diff --git a/parser.h b/parser.h index fdd45e44..9b336d70 100644 --- a/parser.h +++ b/parser.h @@ -46,6 +46,7 @@ typedef struct { extern const wchar_t *spec_file; extern val form_to_ln_hash; extern val parser_s; +extern val unique_s; void yyerror(scanner_t *scanner, parser_t *, const char *s); void yyerr(scanner_t *scanner, const char *s); void yyerrorf(scanner_t *scanner, val s, ...); -- cgit v1.2.3