(module slides_for-syntax racket (provide amkhlv/formula-syntax) (define (amkhlv/formula-syntax #:autoalign-formula-prefix auto-prefix #:manual-formula-prefix formula-prefix #:display-math-prefix display-math-prefix #:size-change-notation size-change-id #:size-increase-notation size-increase-id #:size-restore-notation size-restore-id stx) (let* ( [calc-align (lambda (s) (list '+ 'manual-base-alignment s))] [calc-size (lambda (s) (list '+ 'formula-size (* 2 s)))] [auto `(define ,(string->symbol auto-prefix) (lambda u (amkhlv/formula #:shell-command formula-processor #:use-depth #t #:aa-adjust autoalign-adjust #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))))] [disp `(define ( ,(string->symbol display-math-prefix) #:label (lbl #f) #:hspace (hsp 4) #:size (n formula-size) . x ) (amkhlv/equation #:label lbl #:hspace hsp #:size n #:shell-command formula-processor #:aa-adjust autoalign-adjust #:database formula-database #:formulas-in-dir formula-dir-name x) )] [old-formula-size (string->unreadable-symbol "oldfsize")] [old-autoalign-adjust (string->unreadable-symbol "old-aa-adjust")] [oldsz `(define ,old-formula-size formula-size)] [oldaa `(define ,old-autoalign-adjust autoalign-adjust)] [ch-sz `(define (,(string->symbol size-change-id) (i #f) (aaadj #f)) (if i (begin (set! ,old-formula-size formula-size) (set! formula-size i) (when aaadj (begin (set! ,old-autoalign-adjust autoalign-adjust) (set! autoalign-adjust aaadj)))) (begin (set! formula-size ,old-formula-size) (set! autoalign-adjust ,old-autoalign-adjust) )) )] [inc-sz `(define (,(string->symbol size-increase-id) i (aaadj #f)) (set! ,old-formula-size formula-size) (set! formula-size (+ formula-size i)) (when aaadj (begin (set! ,old-autoalign-adjust autoalign-adjust) (set! autoalign-adjust aaadj))))] [rs-sz `(define (,(string->symbol size-restore-id)) (set! formula-size ,old-formula-size) (set! autoalign-adjust ,old-autoalign-adjust) )] [initf `(define amkhlv/setupformuladatabase (amkhlv/initialize-formula-collection formula-database-name formula-dir-name))] [l `(define ,(string->symbol formula-prefix) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))))] [l+0 `(define ,(string->symbol (string-append formula-prefix "+0")) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))))] [l-0 `(define ,(string->symbol (string-append formula-prefix "-0")) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))))] [l+0+ (lambda (z) `(define ,(string->symbol (string-append formula-prefix "+0+" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size ,(calc-size z) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l-0+ (lambda (z) `(define ,(string->symbol (string-append formula-prefix "-0+" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size ,(calc-size z) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l+0- (lambda (z) `(define ,(string->symbol (string-append formula-prefix "+0-" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size ,(calc-size (- z)) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l-0- (lambda (z) `(define ,(string->symbol (string-append formula-prefix "-0-" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align 0) #:size ,(calc-size (- z)) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l+ (lambda (m) `(define ,(string->symbol (string-append formula-prefix "+" (number->string m))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align m) #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l- (lambda (m) `(define ,(string->symbol (string-append formula-prefix "-" (number->string m))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align (- m)) #:size formula-size #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l++ (lambda (m z) `(define ,(string->symbol (string-append formula-prefix "+" (number->string m) "+" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align m) #:size ,(calc-size z) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l+- (lambda (m z) `(define ,(string->symbol (string-append formula-prefix "+" (number->string m) "-" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align m) #:size ,(calc-size (- z)) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l-+ (lambda (m z) `(define ,(string->symbol (string-append formula-prefix "-" (number->string m) "+" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align (- m)) #:size ,(calc-size z) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [l-- (lambda (m z) `(define ,(string->symbol (string-append formula-prefix "-" (number->string m) "-" (number->string z))) (lambda u (amkhlv/formula #:shell-command formula-processor #:align ,(calc-align (- m)) #:size ,(calc-size (- z)) #:database formula-database #:formulas-in-dir formula-dir-name (apply string-append u))) ))] [def-list+ (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l+ i))] [def-list- (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l- i))] [def-list+0+ (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l+0+ i))] [def-list-0+ (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l-0+ i))] [def-list+0- (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l+0- i))] [def-list-0- (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (l-0- i))] [def-list++ (apply append (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (for/list ([z '(1 2 3 4 5 6 7 8 9)]) (l++ i z))))] [def-list+- (apply append (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (for/list ([z '(1 2 3 4 5 6 7 8 9)]) (l+- i z))))] [def-list-+ (apply append (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (for/list ([z '(1 2 3 4 5 6 7 8 9)]) (l-+ i z))))] [def-list-- (apply append (for/list ([i '(1 2 3 4 5 6 7 8 9)]) (for/list ([z '(1 2 3 4 5 6 7 8 9)]) (l-- i z))))] ) (syntax-case stx () [(_ x) (datum->syntax #'x (append (list 'begin auto disp oldsz oldaa ch-sz inc-sz rs-sz initf l l+0 l-0) def-list+ def-list- def-list+0+ def-list+0- def-list-0+ def-list-0- def-list++ def-list+- def-list-+ def-list-- ) #'x #'x #'x)]) ) ) )