mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 13:36:36 +01:00
read-print: 'read-with-comments' reads comments within gexps.
Fixes <https://issues.guix.gnu.org/62059>. Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>. * guix/read-print.scm (read-with-comments): Special-case #~, #$, and #+. * tests/read-print.scm: Add two tests.
This commit is contained in:
parent
8f219e658d
commit
83128f00e9
2 changed files with 36 additions and 0 deletions
|
@ -219,6 +219,27 @@ (define item
|
|||
(list 'quote (loop #f return)))
|
||||
((eq? chr #\`)
|
||||
(list 'quasiquote (loop #f return)))
|
||||
((eq? chr #\#)
|
||||
(match (read-char port)
|
||||
(#\~ (list 'gexp (loop #f return)))
|
||||
(#\$ (list (match (peek-char port)
|
||||
(#\@
|
||||
(read-char port) ;consume
|
||||
'ungexp-splicing)
|
||||
(_
|
||||
'ungexp))
|
||||
(loop #f return)))
|
||||
(#\+ (list (match (peek-char port)
|
||||
(#\@
|
||||
(read-char port) ;consume
|
||||
'ungexp-native-splicing)
|
||||
(_
|
||||
'ungexp-native))
|
||||
(loop #f return)))
|
||||
(chr
|
||||
(unread-char chr port)
|
||||
(unread-char #\# port)
|
||||
(read port))))
|
||||
((eq? chr #\,)
|
||||
(list (match (peek-char port)
|
||||
(#\@
|
||||
|
|
|
@ -231,6 +231,21 @@ (define-syntax-rule (test-pretty-print/sequence str args ...)
|
|||
;; Regular indentation for 'replace' here.
|
||||
(replace \"gmp\" gmp))")
|
||||
|
||||
(test-pretty-print "\
|
||||
#~(modify-phases phases
|
||||
(add-after 'whatever 'something-else
|
||||
(lambda _
|
||||
;; This comment appears inside a gexp.
|
||||
42)))")
|
||||
|
||||
(test-pretty-print "\
|
||||
#~(list #$@(list coreutils ;yup
|
||||
grep) ;margin comment
|
||||
#+sed
|
||||
|
||||
;; Line comment.
|
||||
#$grep)")
|
||||
|
||||
(test-pretty-print "\
|
||||
(package
|
||||
;; Here 'sha256', 'base32', and 'arguments' must be
|
||||
|
|
Loading…
Reference in a new issue