aboutsummaryrefslogtreecommitdiff
path: root/cpp
blob: bdc140d796bc5c77026e2f1d7755a793484d5cad (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
#!/usr/bin/env sh
# -*- mode: scheme -*-
here=$(dirname $(realpath $0))
. $here/env

exec $GUILE -e main -s "$0" "$@"
!#

(use-modules ((c preprocessor2) :select (preprocess-string make-default-environment))
             ((hnh util io) :select (read-file))
             ((c cpp-environment) :select (pprint-environment))
             ((c unlex) :select (unlex))
             (srfi srfi-71)
             (srfi srfi-88))

(define (main args)
  (let* ((content (read-file (cadr args)))
         (env tokens (preprocess-string content (make-default-environment))))
    (pprint-environment env (current-output-port))
    (newline)
    (display "== tokens ==")
    (newline)
    (display (unlex tokens))
    (newline)
    ))