diff --git a/pkgs/racket-doc/scribblings/inside/params.scrbl b/pkgs/racket-doc/scribblings/inside/params.scrbl index c0659feede..9602b8edb0 100644 --- a/pkgs/racket-doc/scribblings/inside/params.scrbl +++ b/pkgs/racket-doc/scribblings/inside/params.scrbl @@ -45,6 +45,13 @@ through the following indices: @item{@cppdef{MZCONFIG_CAN_READ_COMPILED} --- @racket[read-accept-compiled]} @item{@cppdef{MZCONFIG_CAN_READ_BOX} --- @racket[read-accept-box]} @item{@cppdef{MZCONFIG_CAN_READ_PIPE_QUOTE} --- @racket[read-accept-bar-quote]} +@item{@cppdef{MZCONFIG_CAN_READ_DOT} --- @racket[read-accept-dot]} +@item{@cppdef{MZCONFIG_CAN_READ_INFIX_DOT} --- @racket[read-accept-infix-dot]} +@item{@cppdef{MZCONFIG_CAN_READ_QUASI} --- @racket[read-accept-quasiquote]} +@item{@cppdef{MZCONFIG_CAN_READ_READER} --- @racket[read-accept-reader]} +@item{@cppdef{MZCONFIG_CAN_READ_LANG} --- @racket[read-accept-lang]} +@item{@cppdef{MZCONFIG_READ_DECIMAL_INEXACT} --- @racket[read-decimal-as-inexact]} +@item{@cppdef{MZCONFIG_READ_CDOT} --- @racket[read-cdot]} @item{@cppdef{MZCONFIG_PRINT_GRAPH} --- @racket[print-graph]} @item{@cppdef{MZCONFIG_PRINT_STRUCT} --- @racket[print-struct]} @@ -53,6 +60,8 @@ through the following indices: @item{@cppdef{MZCONFIG_CASE_SENS} --- @racket[read-case-sensitive]} @item{@cppdef{MZCONFIG_SQUARE_BRACKETS_ARE_PARENS} --- @racket[read-square-brackets-as-parens]} @item{@cppdef{MZCONFIG_CURLY_BRACES_ARE_PARENS} --- @racket[read-curly-braces-as-parens]} +@item{@cppdef{MZCONFIG_SQUARE_BRACKETS_ARE_TAGGED} --- @racket[read-square-brackets-with-tag]} +@item{@cppdef{MZCONFIG_CURLY_BRACES_ARE_TAGGED} --- @racket[read-curly-braces-with-tag]} @item{@cppdef{MZCONFIG_ERROR_PRINT_WIDTH} --- @racket[error-print-width]} diff --git a/pkgs/racket-doc/scribblings/reference/read.scrbl b/pkgs/racket-doc/scribblings/reference/read.scrbl index 635187e1aa..2b64d6b242 100644 --- a/pkgs/racket-doc/scribblings/reference/read.scrbl +++ b/pkgs/racket-doc/scribblings/reference/read.scrbl @@ -217,6 +217,23 @@ A @tech{parameter} that controls whether @litchar["{"] and @litchar["}"] are treated as parentheses. See @secref["parse-pair"] for more information.} +@defboolparam[read-square-bracket-with-tag on?]{ + +A @tech{parameter} that controls whether @litchar{[} and @litchar{]} +are treated as parentheses, but the resulting list tagged with +@racket[#%brackets]. See @secref["parse-pair"] for more information. + +@history[#:added "6.2.900.18"]} + +@defboolparam[read-curly-brace-with-tag on?]{ + +A @tech{parameter} that controls whether @litchar["{"] and +@litchar["}"] are treated as parentheses, but the resulting list +tagged with @racket[#%braces]. See @secref["parse-pair"] for more +information. + +@history[#:added "6.2.900.18"]} + @defboolparam[read-accept-box on?]{ A @tech{parameter} that controls parsing @litchar{#&} input. See @@ -256,6 +273,14 @@ information.} A @tech{parameter} that controls parsing input with two dots to trigger infix conversion. See @secref["parse-pair"] for more information.} +@defboolparam[read-cdot on?]{ + +A @tech{parameter} that controls parsing input with a dot, in a C +structure accessor style. See @secref["parse-cdot"] for more +information. + +@history[#:added "6.2.900.18"]} + @defboolparam[read-accept-quasiquote on?]{ A @tech{parameter} that controls parsing input with @litchar{`} or diff --git a/pkgs/racket-doc/scribblings/reference/reader.scrbl b/pkgs/racket-doc/scribblings/reference/reader.scrbl index 84ff9248cb..9da6e68301 100644 --- a/pkgs/racket-doc/scribblings/reference/reader.scrbl +++ b/pkgs/racket-doc/scribblings/reference/reader.scrbl @@ -388,13 +388,21 @@ elements are themselves in @racket[read-syntax] mode, so that the result is a list or pair of syntax objects that is itself wrapped as a syntax object. If the reader constructs nested pairs because the input included a single delimited @litchar{.}, then only the innermost pair -and outermost pair are wrapped as syntax objects. Whether wrapping a -pair or list, if the pair or list was formed with @litchar{[} and -@litchar{]}, then a @indexed-racket['paren-shape] property is attached -to the result with the value @racket[#\[]; if the list or pair was -formed with @litchar["{"] and @litchar["}"], then a -@racket['paren-shape] property is attached to the result with the -value @racket[#\{]. +and outermost pair are wrapped as syntax objects. + +Whether wrapping a pair or list, if the pair or list was formed with +@litchar{[} and @litchar{]}, then a @indexed-racket['paren-shape] +property is attached to the result with the value @racket[#\[]. If the +@racket[read-square-bracket-with-tag] @tech{parameter} is set to +@racket[#t], then the resulting pair or list is wrapped by the +equivalent of @racket[(cons '#%brackets _pair-or-list)]. + +Similarly, if the list or pair was formed with @litchar["{"] and +@litchar["}"], then a @racket['paren-shape] property is attached to +the result with the value @racket[#\{]. If the +@racket[read-curly-brace-with-tag] @tech{parameter} is set to +@racket[#t], then the resulting pair or list is wrapped by the +equivalent of @racket[(cons '#%braces _pair-or-list)]. If a delimited @litchar{.} appears in any other configuration, then the @exnraise[exn:fail:read]. Similarly, if the reader encounters a @@ -412,12 +420,14 @@ being parsed, then the @exnraise[exn:fail:read]. "(1 . 2 . 3)" ] -If the @racket[read-square-bracket-as-paren] @tech{parameter} is set to +If the @racket[read-square-bracket-as-paren] and +@racket[read-square-bracket-with-tag] @tech{parameter}s are set to @racket[#f], then when the reader encounters @litchar{[} and @litchar{]}, the @exnraise{exn:fail:read}. Similarly, if the -@racket[read-curly-brace-as-paren] @tech{parameter} is set to @racket[#f], -then when the reader encounters @litchar["{"] and @litchar["}"], the -@exnraise{exn:fail:read}. +@racket[read-curly-brace-as-paren] and +@racket[read-curly-brace-with-tag] @tech{parameter}s are set to +@racket[#f], then when the reader encounters @litchar["{"] and +@litchar["}"], the @exnraise{exn:fail:read}. If the @racket[read-accept-dot] @tech{parameter} is set to @racket[#f], then a delimited @litchar{.} triggers an @@ -931,6 +941,30 @@ If the @racket[read-accept-reader] or @racket[read-accept-lang] @tech{parameter} is set to @racket[#f], then if the reader encounters @litchar{#lang} or equivalent @litchar{#!}, the @exnraise[exn:fail:read]. +@section[#:tag "parse-cdot"]{Reading with C-style infix dot notation} + +When the @racket[read-cdot] @tech{parameter} is set to @racket[#t], +then a variety of changes occur in the reader. + +First, symbols can no longer include the character @litchar{.}, unless +the entire symbol is quoted with @litchar{|}. + +Second, numbers can no longer include the character @litchar{.}, +unless the number is prefixed with @litchar{#e} or @litchar{#i}, or an +equivalent prefix as discussed in @secref["parse-number"]. If these +numbers are followed by a @litchar{.} intended to be read as a C-style +infix dot, then there must be separating whitespace. + +Finally, after reading any value, @racket[_x], the reader will seek +over whitespace until it reaches a non-whitespace character. If the +character is not @litchar{.}, then the value, @racket[_x], is returned +as usual. If the character is @litchar{.}, then another value, +@racket[_y], is read and the result @racket[(list '#%dot _x _y)] is +returned. In @racket[read-syntax] mode, the @racket['#%dot] symbol has +the source location information of the @litchar{.} character and the +entire list has the source location information spanning from the +start of @racket[_x] to the end of @racket[_y]. + @subsection{S-Expression Reader Language} @defmodulelang[s-exp]