mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
Syntax objects print with source locations
* module/system/syntax.scm (print-syntax): Print source locations.
This commit is contained in:
parent
bd93eaf7cc
commit
2c3029e660
1 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
;;; Syntax utilities
|
||||
|
||||
;;; Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
;;; Copyright (C) 2017, 2021 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -30,4 +30,13 @@
|
|||
(define (print-syntax obj port)
|
||||
;; FIXME: Use syntax->datum instad of syntax-expression, when
|
||||
;; syntax->datum can operate on new syntax objects.
|
||||
(format port "#<syntax ~s>" (syntax-expression obj)))
|
||||
(let ((src (syntax-sourcev obj)))
|
||||
(if src
|
||||
(format port "#<syntax:~a:~a:~a ~s>"
|
||||
(cond
|
||||
((vector-ref src 0) => basename)
|
||||
(else "unknown file"))
|
||||
(1+ (vector-ref src 1))
|
||||
(vector-ref src 2)
|
||||
(syntax-expression obj))
|
||||
(format port "#<syntax ~s>" (syntax-expression obj)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue