diff options
author | Andy Wingo <wingo@pobox.com> | 2021-03-04 13:20:13 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2021-03-04 21:42:22 +0100 |
commit | 2c3029e6608455d2a60fad90060db9ef49530a12 (patch) | |
tree | e5df56c524d2b6cd866b27511beaf6c1c7f2b74a /module/system/syntax.scm | |
parent | bd93eaf7cc45d82c7b4ed13d648fd539a31a47b9 (diff) | |
download | guile-2c3029e6608455d2a60fad90060db9ef49530a12.tar.gz |
Syntax objects print with source locations
* module/system/syntax.scm (print-syntax): Print source locations.
Diffstat (limited to 'module/system/syntax.scm')
-rw-r--r-- | module/system/syntax.scm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/module/system/syntax.scm b/module/system/syntax.scm index 34fadb39f..ee8521234 100644 --- a/module/system/syntax.scm +++ b/module/system/syntax.scm @@ -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))))) |