Repair error wrt interpreter lines in pexpr text
This commit is contained in:
parent
23ba2e5a59
commit
a33786e469
|
@ -117,6 +117,7 @@
|
||||||
(match (peek-char in-port)
|
(match (peek-char in-port)
|
||||||
[(or (? eof-object?) #\] #\> #\} #\)) *TRAILER-ANCHOR*]
|
[(or (? eof-object?) #\] #\> #\} #\)) *TRAILER-ANCHOR*]
|
||||||
[_ (next)])))
|
[_ (next)])))
|
||||||
|
#:interpreter-annotation (lambda (line) (record 'r (list 'interpreter line)))
|
||||||
#:on-hash (lambda (in-port source next parse-error* default)
|
#:on-hash (lambda (in-port source next parse-error* default)
|
||||||
(match-lambda
|
(match-lambda
|
||||||
[#\{ (read-sequence 's in-port source next #\})]
|
[#\{ (read-sequence 's in-port source next #\})]
|
||||||
|
|
|
@ -70,9 +70,10 @@
|
||||||
[(_ re pat) (app (lambda (v) (regexp-try-match re v)) pat)]))
|
[(_ re pat) (app (lambda (v) (regexp-try-match re v)) pat)]))
|
||||||
|
|
||||||
(define ((make-preserve-text-reader #:reader-name reader-name
|
(define ((make-preserve-text-reader #:reader-name reader-name
|
||||||
|
#:interpreter-annotation interpreter-annotation
|
||||||
|
#:read-annotated-value read-annotated-value0
|
||||||
#:on-char on-char0
|
#:on-char on-char0
|
||||||
#:on-hash on-hash0
|
#:on-hash on-hash0)
|
||||||
#:read-annotated-value read-annotated-value0)
|
|
||||||
in-port source read-syntax? decode-embedded0)
|
in-port source read-syntax? decode-embedded0)
|
||||||
(define read-annotations? read-syntax?)
|
(define read-annotations? read-syntax?)
|
||||||
(define decode-embedded (or decode-embedded0
|
(define decode-embedded (or decode-embedded0
|
||||||
|
@ -106,7 +107,7 @@
|
||||||
[#\# (match (next-char*)
|
[#\# (match (next-char*)
|
||||||
[(or #\space #\tab) (annotate-next-with (read-comment-line))]
|
[(or #\space #\tab) (annotate-next-with (read-comment-line))]
|
||||||
[(or #\newline #\return) (annotate-next-with "")]
|
[(or #\newline #\return) (annotate-next-with "")]
|
||||||
[#\! (annotate-next-with `#s(interpreter ,(read-comment-line)))]
|
[#\! (annotate-next-with (interpreter-annotation (read-comment-line)))]
|
||||||
[#\f (unless (delimiter-follows?) (parse-error* "Delimiter must follow #f")) #f]
|
[#\f (unless (delimiter-follows?) (parse-error* "Delimiter must follow #f")) #f]
|
||||||
[#\t (unless (delimiter-follows?) (parse-error* "Delimiter must follow #t")) #t]
|
[#\t (unless (delimiter-follows?) (parse-error* "Delimiter must follow #t")) #t]
|
||||||
[#\" (read-literal-binary)]
|
[#\" (read-literal-binary)]
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
(make-preserve-text-reader
|
(make-preserve-text-reader
|
||||||
#:reader-name *reader-name*
|
#:reader-name *reader-name*
|
||||||
#:read-annotated-value (lambda (in-port source next parse-error*) next)
|
#:read-annotated-value (lambda (in-port source next parse-error*) next)
|
||||||
|
#:interpreter-annotation (lambda (line) `#s(interpreter ,line))
|
||||||
#:on-hash (lambda (in-port source next parse-error* default)
|
#:on-hash (lambda (in-port source next parse-error* default)
|
||||||
(match-lambda
|
(match-lambda
|
||||||
[#\{ (sequence-fold in-port
|
[#\{ (sequence-fold in-port
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"In each test, let stripped = strip(annotatedValue),"
|
"In each test, let stripped = strip(annotatedValue),"
|
||||||
" encodeBinary(·) produce canonical ordering and no annotations,"
|
" encodeBinary(·) produce canonical ordering and no annotations,"
|
||||||
" looseEncodeBinary(·) produce any ordering, but with annotations,"
|
" looseEncodeBinary(·) produce any ordering, but with annotations,"
|
||||||
" annotatedBinary(·) produce canonical ordering, but with annotations,"
|
" annotatedBinary(·) produce “canonical ordering”, but with annotations,"
|
||||||
" decodeBinary(·) include annotations,"
|
" decodeBinary(·) include annotations,"
|
||||||
" encodeText(·) include annotations,"
|
" encodeText(·) include annotations,"
|
||||||
" decodeText(·) include annotations,"
|
" decodeText(·) include annotations,"
|
||||||
|
@ -39,6 +39,10 @@
|
||||||
}>
|
}>
|
||||||
"Implementations may vary in their treatment of the difference between expectations"
|
"Implementations may vary in their treatment of the difference between expectations"
|
||||||
"21/22 and 31/32, depending on how they wish to treat end-of-stream conditions."
|
"21/22 and 31/32, depending on how they wish to treat end-of-stream conditions."
|
||||||
|
|
||||||
|
"The idea of canonical-ordering-with-annotations is to encode, say, sets with their elements"
|
||||||
|
"in sorted order of their canonical annotationless binary encoding, but then actually"
|
||||||
|
"*serialized* with the annotations present."
|
||||||
]>
|
]>
|
||||||
<TestCases {
|
<TestCases {
|
||||||
annotation1: <Test #x"85 B103616263 B00109" @"abc" 9>
|
annotation1: <Test #x"85 B103616263 B00109" @"abc" 9>
|
||||||
|
|
|
@ -138,6 +138,16 @@ PrecType = "PREC" / "PREC_LEFT" / "PREC_RIGHT" / "PREC_DYNAMIC";
|
||||||
ENDDOC
|
ENDDOC
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define U #<<ENDDOC
|
||||||
|
#!/example/of/a/shebang
|
||||||
|
{
|
||||||
|
key: value
|
||||||
|
# example of a comment at the end of a dictionary
|
||||||
|
}
|
||||||
|
# example of a comment at the end of the input file
|
||||||
|
ENDDOC
|
||||||
|
)
|
||||||
|
|
||||||
(parameterize ((pretty-print-columns 80)) (write-pexprs (string->pexprs P #:read-syntax? #t)) (newline))
|
(parameterize ((pretty-print-columns 80)) (write-pexprs (string->pexprs P #:read-syntax? #t)) (newline))
|
||||||
(parameterize ((pretty-print-columns 10)) (write-pexprs (string->pexprs P #:read-syntax? #t)) (newline))
|
(parameterize ((pretty-print-columns 10)) (write-pexprs (string->pexprs P #:read-syntax? #t)) (newline))
|
||||||
|
|
||||||
|
@ -149,3 +159,5 @@ ENDDOC
|
||||||
(parameterize ((pretty-print-columns 40)) (write-pexprs (string->pexprs S #:read-syntax? #t)) (newline))
|
(parameterize ((pretty-print-columns 40)) (write-pexprs (string->pexprs S #:read-syntax? #t)) (newline))
|
||||||
|
|
||||||
(parameterize ((pretty-print-columns 40)) (write-pexprs (string->pexprs T #:read-syntax? #t)) (newline))
|
(parameterize ((pretty-print-columns 40)) (write-pexprs (string->pexprs T #:read-syntax? #t)) (newline))
|
||||||
|
|
||||||
|
(parameterize ((pretty-print-columns 80)) (write-pexprs (string->pexprs U #:read-syntax? #t)) (newline))
|
||||||
|
|
|
@ -3,7 +3,7 @@ title: "P-expressions"
|
||||||
---
|
---
|
||||||
|
|
||||||
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
February 2024. Version 0.3.1.
|
May 2024. Version 0.3.2.
|
||||||
|
|
||||||
[text syntax]: preserves-text.html
|
[text syntax]: preserves-text.html
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ text-syntax encodings.
|
||||||
# example of a comment at the end of a dictionary
|
# example of a comment at the end of a dictionary
|
||||||
}
|
}
|
||||||
# example of a comment at the end of the input file⌝
|
# example of a comment at the end of the input file⌝
|
||||||
= @<interpreter "/example/of/a/shebang">
|
= @<r interpreter "/example/of/a/shebang">
|
||||||
[ <b
|
[ <b
|
||||||
key <p |:|> value
|
key <p |:|> value
|
||||||
@"example of a comment at the end of a dictionary" <a>
|
@"example of a comment at the end of a dictionary" <a>
|
||||||
|
|
Loading…
Reference in New Issue