nyacc: worked c99/util2.scm udecl->mspec

This commit is contained in:
Matt Wette 2017-02-19 08:26:30 -08:00 committed by Jan Nieuwenhuizen
parent 047590bd5e
commit a301ce53df
3 changed files with 11 additions and 4 deletions

View file

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

View file

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

View file

@ -587,10 +587,17 @@
(m-decl (reverse (cons m-specl m-declr)))) (m-decl (reverse (cons m-specl m-declr))))
m-decl)) m-decl))
;; @deffn udecl->mspec/comm decl [dict] [#:def-comm ""]
;; Convert declaration tree to an mspec
;; @example
;; (decl ... (comment "state vector")
;; =>
;; ("x" "state vector" (array-of 10) (float "double")
;; @end example
(define* (udecl->mspec/comm decl #:optional (dict '()) #:key (def-comm "")) (define* (udecl->mspec/comm decl #:optional (dict '()) #:key (def-comm ""))
(let* ((comm (sx-ref decl 3)) (let* ((comm (or (and=> (sx-ref decl 3) cadr) def-comm))
(spec (udecl->mspec decl dict))) (spec (udecl->mspec decl dict)))
(cons* (car spec) (or comm `(comment ,def-comm)) (cdr spec)))) (cons* (car spec) comm (cdr spec))))
;; @deffn fix-fields flds => flds ;; @deffn fix-fields flds => flds
;; This will take a list of fields from a struct and remove lone comments. ;; This will take a list of fields from a struct and remove lone comments.