boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

022-initial-defines.scm (586B)


      1 ;; Initial macros from -D flags: pass an alist as initial-defines.
      2 ;; #define-equivalent: BAR maps to INT 99.
      3 (define (LL c) (%loc "t.c" 1 c))
      4 (define bar-macro (%macro 'obj '() (list (%tok 'INT 99 (LL 0) '()))))
      5 (define defs (list (cons "BAR" bar-macro)))
      6 
      7 (define input
      8   (list (%tok 'IDENT "BAR" (LL 1) '())
      9         (%tok 'NL    #f    (LL 4) '())
     10         (%tok 'EOF   #f    (LL 4) '())))
     11 (define out (pp-expand input defs))
     12 (if (= (length out) 2) 0 (sys-exit 11))
     13 (if (eq? (tok-kind (car out)) 'INT) 0 (sys-exit 12))
     14 (if (= (tok-value (car out)) 99)    0 (sys-exit 13))
     15 (sys-exit 0)