aboutsummaryrefslogtreecommitdiff
path: root/module/c/cpp-environment/function-like-macro.scm
blob: 59b47c9c40c1c13fd60116e222300b6021010d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(define-module (c cpp-environment function-like-macro)
  :use-module (hnh util object)
  :use-module (hnh util type)
  :use-module ((c lex2) :select (lexeme?))
  :use-module ((c unlex) :select (unlex))
  :export (function-like-macro
           function-like-macro?
           identifier
           identifier-list
           body
           variadic?))

(define-type (function-like-macro
              printer: (lambda (r p)
                         (format p "#<#define ~a~a ~a>"
                                 (identifier r)
                                 (append (identifier-list r)
                                         (if (variadic? r)
                                             '("...") '()))
                                 (unlex (body r)))))
  (identifier type: string?)
  (identifier-list type: (list-of string?))
  (body type: (list-of lexeme?))
  (variadic? type: boolean?
             default: #f))