helpnyacc parser generator - Support: sr #110749, nyacc hangs if #ifndef is...


sr #110749: nyacc hangs if #ifndef is unterminated by #endif

Submitter:  Danny Milosavljevic <dannym>
Submitted:  Thu 27 Oct 2022 10:38:41 PM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Sat 31 Dec 2022 03:55:38 PM UTC, comment #1: 

this is fixed (in 1.07.?).

Matt Wette <mwette>
Project Administrator
Thu 27 Oct 2022 10:38:41 PM UTC, original submission:  

Currently, nyacc hangs on the following file (note: #endif is missing on purpose!):

#ifndef EXAMPLE
#define EXAMPLE
#ifndef EXAMPLE

int main() {
  return 0;

Workaround is:

--- /tmp/parser.scm 2022-10-28 00:12:33.440942173 +0200
+++ module/nyacc/lang/c99/parser.scm 2022-10-28 00:37:18.569782550 +0200
@@ -358,6 +358,7 @@
  (assc-$ (lambda (pair)
     (cons (assq-ref symtab (car pair)) (cdr pair))))
+ (t-$end (assq-ref symtab '$end))
  (t-ident (assq-ref symtab '$ident))
  (t-typename (assq-ref symtab 'typename)))

@@ -675,7 +676,10 @@
    (let loop ((pair (read-token)))
      (case (car ppxs)
        ((keep) pair)
-       ((skip-done skip-look skip) (loop (read-token)))
+       ((skip-done skip-look skip)
+        (if (equal? t-$end (car pair))
+            pair
+            (loop (read-token))))
        (else (throw 'c99-error "parser.scm: coding error")))))))


Danny Milosavljevic <dannym>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mwette (Posted a comment)
  • -email is unavailable- added by dannym (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-31 mwette Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.10