nyacc: more CPP fixes
This commit is contained in:
parent
50fc6f6966
commit
85cb3731cc
|
@ -1,3 +1,10 @@
|
|||
2017-01-18 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* lang/c99/parser.scm: check for EOF in end of CPP line
|
||||
|
||||
* lang/c99/mach.scm (c99-spec): decl for translation unit was
|
||||
updated to allow programs with no declarations or statements
|
||||
|
||||
2017-01-08 Matt Wette <mwette@alumni.caltech.edu>
|
||||
|
||||
* ../../test-suite/nyacc/lang/c99/exam.d/ex05.c: C99 does not
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
(if (not (eq? ch #\#)) #f
|
||||
(let iter ((cl '()) (ch (read-char)))
|
||||
(cond
|
||||
((eof-object? ch) (throw 'cpp-error "CPP lines must end in newline"))
|
||||
((eq? ch #\newline) (unread-char ch) (list->string (reverse cl)))
|
||||
((eq? ch #\\)
|
||||
(let ((c2 (read-char)))
|
||||
|
@ -350,6 +351,7 @@
|
|||
(cond
|
||||
((exec-cpp-stmts?)
|
||||
(let ((val (eval-cpp-cond-text (cadr stmt))))
|
||||
;;(simple-format #t "if val=~S\n" val)
|
||||
(cond
|
||||
((not val) (p-err "unresolved: ~S" (cadr stmt)))
|
||||
((zero? val) (set! ppxs (cons* 'skip1-pop 'skip-look ppxs)))
|
||||
|
@ -397,6 +399,7 @@
|
|||
(else (cons 'cpp-stmt stmt))))
|
||||
|
||||
(define (eval-cpp-line line)
|
||||
;;(simple-format #t "eval-cpp-line: ~S\n" line)
|
||||
(with-throw-handler
|
||||
'cpp-error
|
||||
(lambda () (eval-cpp-stmt (read-cpp-stmt line)))
|
||||
|
@ -421,10 +424,12 @@
|
|||
((read-comm ch bol) => assc-$)
|
||||
((read-cpp ch) =>
|
||||
(lambda (res) ;; if '() stmt expanded so re-read
|
||||
;;(simple-format #t "res=~S\n" res)
|
||||
(if (pair? res) (assc-$ res) (iter (read-char)))))
|
||||
(else (set! bol #f) (iter ch))))
|
||||
((read-ident ch) =>
|
||||
(lambda (name)
|
||||
;;(simple-format #t "read-ident=>~S\n" name)
|
||||
(let ((symb (string->symbol name)))
|
||||
(cond
|
||||
((and (x-def? name mode)
|
||||
|
|
|
@ -163,6 +163,9 @@
|
|||
(((key . val) . rest)
|
||||
(iter (cons val stl) (cdr tkl)))
|
||||
|
||||
(('space . rest)
|
||||
(iter (cons " " stl) rest))
|
||||
|
||||
(((? char? ch) . rest)
|
||||
(iter (cons (string ch) stl) rest))
|
||||
|
||||
|
@ -226,9 +229,13 @@
|
|||
(unread-char ch) (rtokl->string tkl))
|
||||
|
||||
((read-c-comm ch #f) =>
|
||||
(lambda (cp) (iter (acons `comm cp tkl) lvl (read-char))))
|
||||
(lambda (cp) (iter (acons `comm (cdr cp) tkl) lvl (read-char))))
|
||||
|
||||
((char-set-contains? c:ws ch)
|
||||
(if (and (pair? tkl) (char? (car tkl)))
|
||||
(iter (cons 'space tkl) lvl (read-char))
|
||||
(iter tkl lvl (read-char))))
|
||||
|
||||
((char-set-contains? c:ws ch) (iter tkl lvl (read-char)))
|
||||
((char=? #\( ch) (iter (cons ch tkl) (1+ lvl) (read-char)))
|
||||
((char=? #\) ch) (iter (cons ch tkl) (1- lvl) (read-char)))
|
||||
((char=? #\# ch)
|
||||
|
|
|
@ -699,8 +699,8 @@
|
|||
(lambda ($2 $1 . $rest) `(return (expr)))
|
||||
;; translation-unit => external-declaration-list
|
||||
(lambda ($1 . $rest) (tl->list $1))
|
||||
;; external-declaration-list => external-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'trans-unit $1))
|
||||
;; external-declaration-list =>
|
||||
(lambda $rest (make-tl 'trans-unit))
|
||||
;; external-declaration-list => external-declaration-list external-decla...
|
||||
(lambda ($2 $1 . $rest)
|
||||
(if (eqv? (sx-tag $2) 'extern-block)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -699,8 +699,8 @@
|
|||
(lambda ($2 $1 . $rest) `(return (expr)))
|
||||
;; translation-unit => external-declaration-list
|
||||
(lambda ($1 . $rest) (tl->list $1))
|
||||
;; external-declaration-list => external-declaration
|
||||
(lambda ($1 . $rest) (make-tl 'trans-unit $1))
|
||||
;; external-declaration-list =>
|
||||
(lambda $rest (make-tl 'trans-unit))
|
||||
;; external-declaration-list => external-declaration-list external-decla...
|
||||
(lambda ($2 $1 . $rest)
|
||||
(if (eqv? (sx-tag $2) 'extern-block)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
2 1 1 1 1 2 2 4 2 1 2 1 1 3 1 3 2 5 6 4 5 2 1 3 1 3 1 1 1 1 2 1 1 3 5 4 4
|
||||
3 6 6 5 4 4 4 3 2 1 3 2 1 2 1 3 1 3 2 2 1 1 3 2 1 1 2 1 3 5 4 4 3 6 5 6 4
|
||||
3 3 2 5 4 5 4 3 4 3 3 2 1 1 3 4 2 1 4 3 2 1 2 3 2 1 1 1 1 1 1 1 3 4 3 3 2
|
||||
1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 1 2 1 1 1 1 1 5 1 4 3 1 2 0
|
||||
1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 0 2 1 1 1 1 1 5 1 4 3 1 2 0
|
||||
1 1 1 1 1 1 1 2 1 1 1 1))
|
||||
|
||||
(define pat-v
|
||||
|
|
|
@ -609,7 +609,8 @@
|
|||
(external-declaration-list ($$ (tl->list $1)))
|
||||
)
|
||||
(external-declaration-list
|
||||
(external-declaration ($$ (make-tl 'trans-unit $1)))
|
||||
;;(external-declaration ($$ (make-tl 'trans-unit $1)))
|
||||
($empty ($$ (make-tl 'trans-unit)))
|
||||
(external-declaration-list
|
||||
external-declaration
|
||||
;; A ``kludge'' to deal with @code{extern "C" ...}:
|
||||
|
|
Loading…
Reference in a new issue