nyacc: fixed more CPP issues

This commit is contained in:
Matt Wette 2017-02-22 17:12:32 -08:00 committed by Jan Nieuwenhuizen
parent f7fb6ac395
commit 8580e706f8
8 changed files with 17 additions and 10 deletions

View file

@ -1,5 +1,7 @@
2017-02-22 Matt Wette <mwette@alumni.caltech.edu>
* lang/c99/cpp.scm (rtokl->string): added handler for 'string
* lang/c99/body.scm: added 'skip state so that if skipping #if
then no CPP if or elif arguments are evaluated

View file

@ -1,4 +1,4 @@
This is a version 0.76.1 of NYACC (Not Yet Another Compiler Compiler!).
This is a version 0.76.1+c99dev of NYACC (Not Yet Another Compiler Compiler!).
Copyright (C) 2015-2017 Matthew R. Wette

View file

@ -50,7 +50,7 @@
#:use-module (nyacc util)
)
(define *nyacc-version* "0.76.1")
(define *nyacc-version* "0.76.1+c99dev")
;; @deffn proxy-? sym rhs

View file

@ -451,7 +451,8 @@
;; Loop between reading tokens and skipping tokens via CPP logic.
(let iter ((pair (read-token)))
(case (car ppxs)
((keep) pair)
((keep) ;;(simple-format #t "lx=>~S\n" pair)
pair)
((skip-done skip-look skip)
(iter (read-token)))
(else (error "coding error"))))

View file

@ -277,12 +277,15 @@
((('ident . rval) ('ident . lval) . rest)
(iter stl chl (string-append " " rval) (cdr tkl)))
(((key . val) . rest)
(iter stl chl val rest))
(('space . rest)
(iter stl (cons #\space chl) nxt rest))
((('string . val) . rest)
(iter stl (cons #\" chl) val (cons #\" rest)))
(((key . val) . rest)
(iter stl chl val rest))
(otherwise
(error "no match" tkl)))))))

View file

@ -692,14 +692,14 @@
(define* (dev-parse-c99 #:key
(cpp-defs '()) ; CPP defines
(inc-dirs '()) ; include directories
(td-dict '()) ; typedef dictionary
(inc-help '()) ; typedef dictionary
(mode 'file) ; mode: 'file or 'code
(xdef? #f) ; expand def function: proc name mode
(debug #f)) ; debug
(catch
#t ;; 'c99-error 'cpp-error 'nyacc-error
(lambda ()
(let ((info (make-cpi debug cpp-defs (cons "." inc-dirs) td-dict)))
(let ((info (make-cpi debug cpp-defs (cons "." inc-dirs) inc-help)))
(with-fluid*
*info* info
(lambda ()

View file

@ -66,8 +66,8 @@
;; @example
;; (with-input-from-file "abc.c"
;; (parse-c #:cpp-defs '("ABC=123"))
;; #:inc-dirs (append '("." "./incs" "/usr/include") c99-std-dict)
;; #:inc-help '(("myinc.h" "foo_t" "bar_t"))
;; #:inc-dirs '(("." "./incs" "/usr/include"))
;; #:inc-help (append '("myinc.h" "foo_t" "bar_t") c99-std-help)
;; #:mode 'file))
;; @end example
(define* (parse-c99 #:key

View file

@ -394,6 +394,7 @@
;; |#
;; expression-statement
((expr-stmt) (sf ";\n"))
((expr-stmt ,expr) (ppx expr) (sf ";\n"))
((expr-stmt ,expr ,comm) (ppx expr) (sf "; ") (ppx comm))