GNU bug report logs - #74454
Bug fix: Emacs Lisp parser

Previous Next

Package: guile;

Reported by: Ramin Honary <ramin.honary <at> gmail.com>

Date: Thu, 21 Nov 2024 07:55:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ramin Honary <ramin.honary <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: Bug fix: Emacs Lisp parser
Date: Thu, 21 Nov 2024 07:34:41 +0000
[Message part 1 (text/plain, inline)]
Hello Guile developers:

I originally sent this to the guile-devel list but someone kindly
explained that I should send it here.

I have made a small bug fix for the Emacs Lisp parser in the (language
elisp) module.

  - I fixed a simple bug in the lexer that decodes the carat encoding
for control characters (for example "^@" translates to #\null),

  - and I implemented octal digit decoding in the lexer.

I have tested these changes against Emacs Lisp code from the GNU Emacs
source code. I can confirm that files like "subr.el" can be fully
parsed to list data structures in Scheme now. Here is a simple test
program that parses "subr.el" from GNU Emacs:

(use-modules ((language elisp parser) #:select (read-elisp)))

(define (file-read-all-forms filepath)
  (call-with-port (open-input-file filepath)
    (lambda (port)
      (let loop ((forms-list '()))
        (let ((form (read-elisp port)))
          (cond
           ((eof-object? form) (reverse forms-list))
           (else (loop (cons form forms-list)))
           ))))))

(define path-to-test-el "/home/ramin/src/emacs-29.4/li
sp/subr.el")

(define (main)
  (for-each
   (lambda (form) (display form) (newline))
   (file-read-all-forms path-to-test-el)))

Before applying my patch, the above test program fails with:

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure integer->char: Argument 1 out of range: 67108955

After applying my patch, the whole file parses successfully.

Regards,

-- Ramin Honary


(ActivityPub: @ramin_hal9001 <at> fe.disroot.org)
[2024-11-20_ramin-honary_improve-elisp-parser.patch (text/x-patch, attachment)]

This bug report was last modified 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.