quick fix (bug #65849)
--- a/module/nyacc/lang/c99/parser.scm
+++ b/module/nyacc/lang/c99/parser.scm
@@ -591,7 +591,7 @@
;; If decl mode, only defines and includes outside {}
;; @end itemize
(define (pass-cpp-stmt stmt)
- (if (eq? 'pragma (car stmt))
+ (if (and (pair? stmt) (eq? 'pragma (car stmt)))
(if (eq? mode 'file)
`(cpp-stmt ,stmt)
`($pragma . ,(cadr stmt)))
On 6/8/24 12:27 AM, Janneke Nieuwenhuizen wrote:
Hi!
Using the file warning.c:
--8<---------------cut here---------------start------------->8---
// warning.c
#warning warn me!
#warning oops
--8<---------------cut here---------------end--------------->8---
Nyacc's c99 parser crashes on (right after) the first #warning
--8<---------------cut here---------------start------------->8---
$ guile
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use (nyacc lang c99 parser)
scheme@(guile-user)> ,use (nyacc version)
scheme@(guile-user)> *nyacc-version*
$1 = "1.09.4"
scheme@(guile-user)> (with-input-from-file "warning.c" parse-c99)
warning: warn me!
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure car: Wrong type argument in position 1 (expecting pair):
#<unspecified>
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In ice-9/ports.scm:
433:17 9 (call-with-input-file _ _ #:binary _ #:encoding _
#:guess-encoding _)
472:4 8 (_ _)
In nyacc/lang/c99/parser.scm:
784:6 7 (parse-c99 _ #:cpp-defs _ #:inc-dirs _ #:inc-help _ #:mode _
#:xdef? _ # _ # _ …)
In ice-9/boot-9.scm:
1747:15 6 (with-exception-handler #<procedure 7fa866593180 at
ice-9/boot-9.scm:1831:7 (…> …)
1747:15 5 (with-exception-handler #<procedure 7fa866593150 at
ice-9/boot-9.scm:1831:7 (…> …)
In nyacc/lang/c99/parser.scm:
787:33 4 (_)
In nyacc/parse.scm:
169:37 3 (_ #<procedure 7fa8665a3ee0 at nyacc/lang/c99/parser.scm:376:8
()> #:debug _)
In nyacc/lang/c99/parser.scm:
697:27 2 (_)
594:29 1 (read-token)
In ice-9/boot-9.scm:
1685:16 0 (raise-exception _ #:continuable? _)
scheme@(guile-user) [1]>
--8<---------------cut here---------------end--------------->8---
Greetings,
Janneke