From: Jan Nieuwenhuizen <janneke@gnu.org>
To: Matt Wette <matt.wette@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: nyacc 0.73.0 released
Date: Sun, 01 Jan 2017 13:22:33 +0100 [thread overview]
Message-ID: <87k2afas1i.fsf@gnu.org> (raw)
In-Reply-To: <04AF8714-9C32-4EA1-A3BC-74FBFF2EB478@gmail.com> (Matt Wette's message of "Sat, 31 Dec 2016 08:08:27 -0800")
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
Matt Wette writes:
> On Dec 31, 2016, at 7:57 AM, Matt Wette <matt.wette@gmail.com> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nyacc-c99-always-expand-cpp-conditionals.patch --]
[-- Type: text/x-patch, Size: 1527 bytes --]
From c737ebb8fbaeff75e8914a695951be466cf3d695 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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
[-- Attachment #3: Type: text/plain, Size: 154 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
next prev parent reply other threads:[~2017-01-01 12:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-26 4:05 nyacc 0.73.0 released Matt Wette
2016-12-26 7:29 ` Jan Nieuwenhuizen
2016-12-26 14:53 ` Matt Wette
2016-12-31 14:15 ` Jan Nieuwenhuizen
2016-12-31 15:57 ` Matt Wette
2016-12-31 16:08 ` Matt Wette
2017-01-01 12:22 ` Jan Nieuwenhuizen [this message]
2017-01-01 0:04 ` Matt Wette
2017-01-01 12:32 ` Jan Nieuwenhuizen
2017-01-07 11:14 ` Jan Nieuwenhuizen
2017-01-07 14:19 ` Matt Wette
2017-01-07 20:02 ` Jan Nieuwenhuizen
2017-01-11 2:33 ` Chaos Eternal
2017-01-11 2:58 ` Matt Wette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k2afas1i.fsf@gnu.org \
--to=janneke@gnu.org \
--cc=guile-user@gnu.org \
--cc=matt.wette@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).