unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [bug nyacc] C99 parser crashes on #warning
@ 2024-06-08  7:27 Janneke Nieuwenhuizen
  2024-06-08 14:14 ` Matt Wette
  0 siblings, 1 reply; 3+ messages in thread
From: Janneke Nieuwenhuizen @ 2024-06-08  7:27 UTC (permalink / raw)
  To: Matthew Wette; +Cc: guile-user

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

-- 
Janneke Nieuwenhuizen <janneke@gnu.org>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug nyacc] C99 parser crashes on #warning
  2024-06-08  7:27 [bug nyacc] C99 parser crashes on #warning Janneke Nieuwenhuizen
@ 2024-06-08 14:14 ` Matt Wette
  2024-06-08 20:50   ` Janneke Nieuwenhuizen
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Wette @ 2024-06-08 14:14 UTC (permalink / raw)
  To: Janneke Nieuwenhuizen; +Cc: guile-user

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
>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug nyacc] C99 parser crashes on #warning
  2024-06-08 14:14 ` Matt Wette
@ 2024-06-08 20:50   ` Janneke Nieuwenhuizen
  0 siblings, 0 replies; 3+ messages in thread
From: Janneke Nieuwenhuizen @ 2024-06-08 20:50 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

Matt Wette writes:

> quick fix (bug #65849)

Thanks for the quick fix!

-- 
Janneke Nieuwenhuizen <janneke@gnu.org>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-08 20:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-08  7:27 [bug nyacc] C99 parser crashes on #warning Janneke Nieuwenhuizen
2024-06-08 14:14 ` Matt Wette
2024-06-08 20:50   ` Janneke Nieuwenhuizen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).