From f9c0def5b6049bc600051b928910f724e14af4f5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 10 Aug 2015 22:31:01 -0700 Subject: Dot with no whitespace generates qref syntax. a.b.(expr ...).c -> (qref a b (expr ...) c) Consing dot requires whitespace. * eval.c (qref_s): New symbol global variable. (eval_init): Initialize qref_s. * eval.h (qref_s): Declared. * parser.l (REQWS): New pattern definition, required whitespace. (grammar): New rules to scan CONSDOT (space required on both sides) and LAMBDOT (space required after). * parser.y (CONSDOT, LAMBDOT): New token types. (list): (. n_expr) rule replaced with LAMBDOT and CONSDOT. (r_exprs): r_exprs . n_expr consing dot rule replaced with CONSDOT. (n_expr): New n_expr . n_expr rule introduced here for producing qref expressions. (yybadtoken): Handle CONSDOT and LAMBDOT. * txr.1: Documented qref dot. --- txr.1 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index a2c1ee32..2954fc4b 100644 --- a/txr.1 +++ b/txr.1 @@ -9181,6 +9181,47 @@ or an atom as .codn "(. sym)" . +.NP* Referencing Dot + +A dot token which is flanked by expressions on both sides, without any +intervening whitespace, is the referencing dot, and not the consing dot. +The referencing dot is a syntactic sugar which translated to the +.code qref +syntax ("quoted ref"), which currently has no assigned meaning and is reserved +for a future language extension. The referencing dot obeys these +correspondences: + +.cblk + ;; a.b may be almost any expressions + a.b <--> (qref a b) + a.b.c <--> (qref a b c) + a.(qref b c) <--> (qref a b c) + (qref a b).c <--> (qref (qref a b) c) +.cble + +That is to say, this dot operator constructs a +.code qref +expression out of its left and right arguments. If the right argument +of the dot is already a qref expression (whether produced by another instance +of the dot operator, or expressed directly) it is merged. And the qref dot +operator is right-to-left associative, so that +.code a.b.c +first produces +.code (qref b c) +via the right dot, and then +.code a +is adjoined into the syntax via the right dot. + +Integer tokens cannot be involved in this syntax, because they +form floating-point constants when juxtaposed with a dot. +Such ambiguous uses of floating-point tokens are diagnosed as syntax errors: + +.cblk + (a.4) ;; error: cramped floating-point literal + (a .4) ;; good: a followed by 0.4 +.cble + + .NP* Quote and Quasiquote .meIP >> ' expr -- cgit v1.2.3