1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Syntax objects print with source locations

* module/system/syntax.scm (print-syntax): Print source locations.
This commit is contained in:
Andy Wingo 2021-03-04 13:20:13 +01:00
parent bd93eaf7cc
commit 2c3029e660

View file

@ -1,6 +1,6 @@
;;; Syntax utilities ;;; 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 ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -30,4 +30,13 @@
(define (print-syntax obj port) (define (print-syntax obj port)
;; FIXME: Use syntax->datum instad of syntax-expression, when ;; FIXME: Use syntax->datum instad of syntax-expression, when
;; syntax->datum can operate on new syntax objects. ;; 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)))))