guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nyacc 0.73.0 released


From: Jan Nieuwenhuizen
Subject: Re: nyacc 0.73.0 released
Date: Sun, 01 Jan 2017 13:22:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Matt Wette writes:

>     On Dec 31, 2016, at 7:57 AM, Matt Wette <address@hidden> wrote:
>
>       I think this may accomplish what you want:
>    
>     (define (my-xdef? name mode) (if (equal? name “__GNUC__”) #f (env? mode 
> ‘code))
>    
>     (parse-c99 #:xdef? my-xdef? …)
>
> The idea here is that there are two “modes” for parsing.  "file" mode will 
> pass the
> CPP statements to the AST and “code” mode will not.  There is a procedure 
> keyword
> argument #mode to control these.

Ah, I get the idea, but not the suggested code.  I don't have the procedure
`env?'

I'm now using

    (define (gnuc-xdef? name mode)
      (cond ((equal? name "__GNUC__") #t)
            ((equal? name "asm") #f)))

    (define (mescc)
      (parse-c99 #:inc-dirs (string-split (getenv "C_INCLUDE_PATH") #\:)
                 #:cpp-defs '(("__GNUC__" . "0"))
                 #:xdef? gnuc-xdef?))

together with the attached patch (I'm sure is not right).  Something
like this seems necessary for (if,elif,endif) to be expanded.  Setting
eval-flow? always to #t does not work.

It's very handy that #if now works, making a lot of round trips
between gcc and mescc to bootstrap the compiler.

Greetings,
Jan

>From c737ebb8fbaeff75e8914a695951be466cf3d695 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sat, 31 Dec 2016 20:35:50 +0100
Subject: [PATCH] nyacc: c99: always expand cpp conditionals.

* module/nyacc/lang/c99/body.scm (gen-c-lexer): Always expand conditionals.
---
 module/nyacc/lang/c99/body.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/module/nyacc/lang/c99/body.scm b/module/nyacc/lang/c99/body.scm
index b3e7843..a881849 100644
--- a/module/nyacc/lang/c99/body.scm
+++ b/module/nyacc/lang/c99/body.scm
@@ -319,7 +319,7 @@
                 (rem-define (cadr stmt)))
                ((if) ;; and ifdef, ifndef
                 (cpi-push)
-                (if (eval-flow?)
+                (if #t ;;(eval-flow?)
                     (let* ((defs (cpi-defs info))
                            (rhs (cpp-expand-text (cadr stmt) defs))
                            ;; rhs = "defined(1)" :(
@@ -333,7 +333,7 @@
                        (else
                         (set! skip (cons* 'skip-one (car skip) skip)))))))
                ((elif)
-                (if (eval-flow?)
+                (if #t ;;(eval-flow?)
                     (let* ((defs (cpi-defs info))
                            (rhs (cpp-expand-text (cadr stmt) defs))
                            (exp (parse-cpp-expr rhs))
@@ -353,7 +353,7 @@
                         (set! skip (cons* 'skip-one 'skip (cdr skip))))))
                     (cpi-shift)))
                ((else)
-                (if (eval-flow?)
+                (if #t ;; (eval-flow?)
                     (cond
                      ((eq? 'skip-look (car skip))
                       (cpi-shift)
@@ -363,7 +363,7 @@
                     (cpi-shift)))
                ((endif)
                 (cpi-pop)
-                (if (eval-flow?)
+                (if #t ;; (eval-flow?)
                     (set! skip (cons 'skip-one (cdr skip)))))
                ((error)
                 stmt)
-- 
2.10.2

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]