r7rs-small-texinfo

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/r7rs-small-texinfo
Log | Files | Refs

commit 1bc725972505daef11cd942680bf6c602c926f74
parent 5a5b69a07bffa48695c92b170f32b6e8128749a3
Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz>
Date:   Tue,  6 Feb 2024 14:46:59 -0500

Formal syntax: Dike out remaining syntax for now; Texify rest.

I want to figure out how we're going to display the grammar before
doing any more work. The pasted grammar text was a mess, anyway.

Diffstat:
Mdoc/r7rs-small/formal-syntax.texinfo | 201++++++-------------------------------------------------------------------------
1 file changed, 15 insertions(+), 186 deletions(-)

diff --git a/doc/r7rs-small/formal-syntax.texinfo b/doc/r7rs-small/formal-syntax.texinfo @@ -248,209 +248,38 @@ The definitions in this and the following subsections assume that all the syntax defined in this report have been properly imported from their libraries, and that none of them have been redefined or shadowed. -@svar{expression} ⟶@svar{identifier} -∣@svar{literal} -∣@svar{procedure call} -∣@svar{lambda expression} -∣@svar{conditional} -∣@svar{assignment} -∣@svar{derived expression} -∣@svar{macro use} -∣@svar{macro block} -∣@svar{includer} -@svar{literal} ⟶@svar{quotation} ∣@svar{self-evaluating} -@svar{self-evaluating} ⟶@svar{boolean} ∣@svar{number} ∣@svar{vector} -∣@svar{character} ∣@svar{string} ∣@svar{bytevector} -@svar{quotation} ⟶'@svar{datum} ∣(quote @svar{datum}) -@svar{procedure call} ⟶(@svar{operator} @svar{operand}*) -@svar{operator} ⟶@svar{expression} -@svar{operand} ⟶@svar{expression} -@svar{lambda expression} ⟶(lambda @svar{formals} @svar{body}) -@svar{formals} ⟶(@svar{identifier}*) ∣@svar{identifier} -∣(@svar{identifier}+ . @svar{identifier}) -@svar{body} ⟶@svar{definition}* @svar{sequence} -@svar{sequence} ⟶@svar{command}* @svar{expression} -@svar{command} ⟶@svar{expression} -@svar{conditional} ⟶(if @svar{test} @svar{consequent} @svar{alternate}) -@svar{test} ⟶@svar{expression} -@svar{consequent} ⟶@svar{expression} -@svar{alternate} ⟶@svar{expression} ∣@svar{empty} -@svar{assignment} ⟶(set! @svar{identifier} @svar{expression}) -@svar{derived expression} ⟶ (cond @svar{cond clause}+) -∣(cond @svar{cond clause}* (else @svar{sequence})) -∣(case @svar{expression} - @svar{case clause}+) -∣(case @svar{expression} - @svar{case clause}* - (else @svar{sequence})) -∣(case @svar{expression} - @svar{case clause}* - (else => @svar{recipient})) -∣(and @svar{test}*) -∣(or @svar{test}*) -∣(when @svar{test} @svar{sequence}) -∣(unless @svar{test} @svar{sequence}) -∣(let (@svar{binding spec}*) @svar{body}) -∣(let @svar{identifier} (@svar{binding spec}*) @svar{body}) -∣(let* (@svar{binding spec}*) @svar{body}) -∣(letrec (@svar{binding spec}*) @svar{body}) -∣(letrec* (@svar{binding spec}*) @svar{body}) -∣(let-values (@svar{mv binding spec}*) @svar{body}) -∣(let*-values (@svar{mv binding spec}*) @svar{body}) -∣(begin @svar{sequence}) -∣(do (@svar{iteration spec}*) - (@svar{test} @svar{do result}) - @svar{command}*) -∣(delay @svar{expression}) -∣(delay-force @svar{expression}) -∣(parameterize ((@svar{expression} @svar{expression})*) - @svar{body}) -∣(guard (@svar{identifier} @svar{cond clause}*) @svar{body}) -∣@svar{quasiquotation} -∣(case-lambda @svar{case-lambda clause}*) -@svar{cond clause} ⟶(@svar{test} @svar{sequence}) -∣(@svar{test}) -∣(@svar{test} => @svar{recipient}) -@svar{recipient} ⟶@svar{expression} -@svar{case clause} ⟶((@svar{datum}*) @svar{sequence}) -∣((@svar{datum}*) => @svar{recipient}) -@svar{binding spec} ⟶(@svar{identifier} @svar{expression}) -@svar{mv binding spec} ⟶(@svar{formals} @svar{expression}) -@svar{iteration spec} ⟶(@svar{identifier} @svar{init} @svar{step}) -∣(@svar{identifier} @svar{init}) -@svar{case-lambda clause} ⟶(@svar{formals} @svar{body}) -@svar{init} ⟶@svar{expression} -@svar{step} ⟶@svar{expression} -@svar{do result} ⟶@svar{sequence} ∣@svar{empty} -@svar{macro use} ⟶(@svar{keyword} @svar{datum}*) -@svar{keyword} ⟶@svar{identifier} -@svar{macro block} ⟶ (let-syntax (@svar{syntax spec}*) @svar{body}) -∣(letrec-syntax (@svar{syntax spec}*) @svar{body}) -@svar{syntax spec} ⟶(@svar{keyword} @svar{transformer spec}) -@svar{includer} ⟶ ∣(include @svar{string}+) -∣(include-ci @svar{string}+) +[grammar] @node Quasiquotations @subsection Quasiquotations The following grammar for quasiquote expressions is not context-free. It is presented as a recipe for generating an infinite number of production rules. Imagine a copy of the -following rules for D = 1, 2, 3, @dots{}, where D is the nesting depth. - -@svar{quasiquotation} ⟶@svar{quasiquotation 1} -@svar{qq template 0} ⟶@svar{expression} -@svar{quasiquotation D} ⟶`@svar{qq template D} -∣(quasiquote @svar{qq template D}) -@svar{qq template D} ⟶@svar{simple datum} -∣@svar{list qq template D} -∣@svar{vector qq template D} -∣@svar{unquotation D} -@svar{list qq template D} ⟶(@svar{qq template or splice D}*) -∣(@svar{qq template or splice D}+ . @svar{qq template D}) -∣'@svar{qq template D} -∣@svar{quasiquotation D + 1} -@svar{vector qq template D} ⟶#(@svar{qq template or splice D}*) -@svar{unquotation D} ⟶,@svar{qq template D−1} -∣(unquote @svar{qq template D−1}) -@svar{qq template or splice D} ⟶@svar{qq template D} -∣@svar{splicing unquotation D} -@svar{splicing unquotation D} ⟶,@@@svar{qq template D−1} -∣(unquote-splicing @svar{qq template D−1}) In @svar{quasiquotation}s, a @svar{list qq template D} can -sometimes be confused with either an @svar{unquotation D} or a @svar{splicing unquotation D}. -The interpretation as an @svar{unquotation} or @svar{splicing unquotation D} takes precedence. +following rules for @var{D} = 1, 2, 3, @dots{}, where @var{D} is the nesting depth. + +[grammar] + +In @svar{quasiquotation}s, a @svar{list qq template @var{D}} can +sometimes be confused with either an @svar{unquotation @var{D}} or a +@svar{splicing unquotation @var{D}}. + +The interpretation as an @svar{unquotation} or +@svar{splicing unquotation @var{D}} takes precedence. @node Transformers @subsection Transformers -Note: Though this grammar does not say so, a top-level syntax-rules pattern must be +Note: Though this grammar does not say so, a top-level @code{syntax-rules} pattern must be a list pattern, not a vector pattern or an identifier pattern. -@svar{transformer spec} ⟶ (syntax-rules (@svar{identifier}*) @svar{syntax rule}*) -∣(syntax-rules @svar{identifier} (@svar{identifier}*) - @svar{syntax rule}*) -@svar{syntax rule} ⟶(@svar{pattern} @svar{template}) -@svar{pattern} ⟶@svar{pattern identifier} -∣@svar{underscore} -∣(@svar{pattern}*) -∣(@svar{pattern}+ . @svar{pattern}) -∣(@svar{pattern}* @svar{pattern} @svar{ellipsis} @svar{pattern}*) -∣(@svar{pattern}* @svar{pattern} @svar{ellipsis} @svar{pattern}* - . @svar{pattern}) -∣#(@svar{pattern}*) -∣#(@svar{pattern}* @svar{pattern} @svar{ellipsis} @svar{pattern}*) -∣@svar{pattern datum} -@svar{pattern datum} ⟶@svar{string} -∣@svar{character} -∣@svar{boolean} -∣@svar{number} -∣@svar{bytevector} -@svar{template} ⟶@svar{pattern identifier} -∣(@svar{template element}*) -∣(@svar{template element}+ . @svar{template}) -∣#(@svar{template element}*) -∣@svar{template datum} -@svar{template element} ⟶@svar{template} -∣@svar{template} @svar{ellipsis} -@svar{template datum} ⟶@svar{pattern datum} -@svar{pattern identifier} ⟶@svar{any identifier except ...} -@svar{ellipsis} ⟶@svar{an identifier defaulting to ...} -@svar{underscore} ⟶@svar{the identifier _} +[grammar] @node Programs and definitions @subsection Programs and definitions -@svar{program} ⟶ @svar{import declaration}+ -@svar{command or definition}+ -@svar{command or definition} ⟶@svar{command} -∣@svar{definition} -∣(begin @svar{command or definition}+) -@svar{definition} ⟶(define @svar{identifier} @svar{expression}) -∣(define (@svar{identifier} @svar{def formals}) @svar{body}) -∣@svar{syntax definition} -∣(define-values @svar{formals} @svar{body}) -∣(define-record-type @svar{identifier} - @svar{constructor} @svar{identifier} @svar{field spec}*) -∣(begin @svar{definition}*) -@svar{def formals} ⟶@svar{identifier}* -∣@svar{identifier}* . @svar{identifier} -@svar{constructor} ⟶(@svar{identifier} @svar{field name}*) -@svar{field spec} ⟶(@svar{field name} @svar{accessor}) -∣(@svar{field name} @svar{accessor} @svar{mutator}) -@svar{field name} ⟶@svar{identifier} -@svar{accessor} ⟶@svar{identifier} -@svar{mutator} ⟶@svar{identifier} -@svar{syntax definition} ⟶ (define-syntax @svar{keyword} @svar{transformer spec}) +[grammar] @node Libraries formal @subsection Libraries -@display -@svar{library} @expansion{} - (d\=efine-library @svar{library name} - \arbno{@svar{library declaration}}) -@svar{library name} \: (\atleastone{@svar{library name part}}) -@svar{library name part} \: @svar{identifier} | @svar{uinteger 10} -@svar{library declaration} \: (export \arbno{@svar{export spec}}) - | @svar{import declaration} - | (begin \arbno{@svar{command or definition}}) - | @svar{includer} - | (include-library-declarations \atleastone{@svar{string}}) - | (cond-expand \atleastone{@svar{cond-expand clause}}) - | (cond-expand \atleastone{@svar{cond-expand clause}} - (else \arbno{@svar{library declaration}})) -@svar{import declaration} \: (import \atleastone{@svar{import set}}) -@svar{export spec} \: @svar{identifier} - | (rename @svar{identifier} @svar{identifier}) -@svar{import set} \: @svar{library name} - | (only @svar{import set} \atleastone{@svar{identifier}}) - | (except @svar{import set} \atleastone{@svar{identifier}}) - | (prefix @svar{import set} @svar{identifier}) - | (rename @svar{import set} \atleastone{(@svar{identifier} @svar{identifier})}) -@svar{cond-expand clause} \: - (@svar{feature requirement} \arbno{@svar{library declaration}}) -@svar{feature requirement} \: @svar{identifier} - | @svar{library name} - | (and \arbno{@svar{feature requirement}}) - | (or \arbno{@svar{feature requirement}}) - | (not @svar{feature requirement}) -@end display +[grammar]