mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-06 20:20:20 +02:00
* libguile/syntax.c (HAS_SOURCE_WORD_FLAG): Remove; all syntax objects now have a source word. (sourcev_to_props, props_to_sourcev): Remove. (scm_make_syntax): Require source to be a vector or #f. (scm_syntax_source): Just return source object. (scm_syntax_sourcev): Remove. * libguile/syntax.h: Remove scm_syntax_sourcev. * module/srfi/srfi-64.scm (syntax->source-properties): * module/system/base/types.scm (cell->object): * module/ice-9/boot-9.scm (case, current-source-location, current-filename) (define-module, load): Adapt for syntax-source returning a vector. * module/ice-9/psyntax-pp.scm: Regen. * module/ice-9/psyntax.scm: Rename uses of syntax-sourcev to syntax-source. * module/system/syntax.scm (syntax-sourcev): Add deprecated shim. (print-syntax): Use sourcev. * module/system/vm/assembler.scm (intern-constant): (link-data): Always write source word. * test-suite/tests/reader.test ("read-syntax"): Update expectation.
48 lines
1.8 KiB
Scheme
48 lines
1.8 KiB
Scheme
;;; Syntax utilities
|
|
|
|
;;; Copyright (C) 2017, 2021, 2025 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
|
|
;;;; License as published by the Free Software Foundation; either
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
|
;;;;
|
|
;;;; This library is distributed in the hope that it will be useful,
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;;;; Lesser General Public License for more details.
|
|
;;;;
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
;;;; License along with this library; if not, write to the Free Software
|
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
;;; Code:
|
|
|
|
(define-module (system syntax)
|
|
#:use-module (system syntax internal)
|
|
#:re-export (syntax?
|
|
syntax-local-binding
|
|
(%syntax-module . syntax-module)
|
|
syntax-locally-bound-identifiers
|
|
syntax-session-id))
|
|
|
|
(begin-deprecated
|
|
(define-public (syntax-sourcev x)
|
|
(issue-deprecation-warning
|
|
"syntax-sourcev is deprecated. Use syntax-source instead.")
|
|
(syntax-source x)))
|
|
|
|
;; Used by syntax.c.
|
|
(define (print-syntax obj port)
|
|
;; FIXME: Use syntax->datum instad of syntax-expression, when
|
|
;; syntax->datum can operate on new syntax objects.
|
|
(let ((src (syntax-source 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)))))
|