1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Fix order of evaluation in elisp lexer

* module/language/elisp/lexer.scm (lex): Use let*, to ensure that the
  port position is read before reading the next char.
This commit is contained in:
Andy Wingo 2013-11-01 18:23:51 +01:00
parent b681671ede
commit 14b9aa95e6

View file

@ -1,6 +1,6 @@
;;; Guile Emacs Lisp ;;; Guile Emacs Lisp
;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. ;;; Copyright (C) 2009, 2010, 2013 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
@ -261,20 +261,20 @@
(and=> (regexp-exec lexical-binding-regexp string) (and=> (regexp-exec lexical-binding-regexp string)
(lambda (match) (lambda (match)
(not (member (match:substring match 2) '("nil" "()")))))) (not (member (match:substring match 2) '("nil" "()"))))))
(let ((return (let ((file (if (file-port? port) (let* ((return (let ((file (if (file-port? port)
(port-filename port) (port-filename port)
#f)) #f))
(line (1+ (port-line port))) (line (1+ (port-line port)))
(column (1+ (port-column port)))) (column (1+ (port-column port))))
(lambda (token value) (lambda (token value)
(let ((obj (cons token value))) (let ((obj (cons token value)))
(set-source-property! obj 'filename file) (set-source-property! obj 'filename file)
(set-source-property! obj 'line line) (set-source-property! obj 'line line)
(set-source-property! obj 'column column) (set-source-property! obj 'column column)
obj)))) obj))))
;; Read afterwards so the source-properties are correct above ;; Read afterwards so the source-properties are correct above
;; and actually point to the very character to be read. ;; and actually point to the very character to be read.
(c (read-char port))) (c (read-char port)))
(cond (cond
;; End of input must be specially marked to the parser. ;; End of input must be specially marked to the parser.
((eof-object? c) (return 'eof c)) ((eof-object? c) (return 'eof c))