Thank you for your comment

Beau­tiful Racket / racket school 2019

  1. 12 & AB
    1
    12 & AB
    
    copy to clipboard
    12+97
    1
    12+97
    
    copy to clipboard
    ;; hello world!
    (* 62 719)
    1
    2
    ;; hello world!
    (* 62 719)
    
    copy to clipboard
    if True:
        print "hooray"
    1
    2
    if True:
        print "hooray"
    
    copy to clipboard
  2. if y > 0:
        x / y
    else:
        print("nope")
    1
    2
    3
    4
    if y > 0:
        x / y
    else:
        print("nope")
    
    copy to clipboard
    '(if (> y 0)
         :
         (/ x y)
         else:
         (print "nope"))
    1
    2
    3
    4
    5
    '(if (> y 0)
         :
         (/ x y)
         else:
         (print "nope"))
    
    copy to clipboard
    (if (> y 0)
      (/ x y)
      (print "nope"))
    1
    2
    3
    (if (> y 0)
      (/ x y)
      (print "nope"))
    
    copy to clipboard
  3. (define (read-syntax src ip)
      (define toks (tokenize-all ip))
      (define parse-tree (parse src toks))
      (strip-bindings
       (with-syntax ([PT parse-tree])
         #'(module mod-name expander-mod
             PT))))
    1
    2
    3
    4
    5
    6
    7
    (define (read-syntax src ip)
      (define toks (tokenize-all ip))
      (define parse-tree (parse src toks))
      (strip-bindings
       (with-syntax ([PT parse-tree])
         #'(module mod-name expander-mod
             PT))))
    
    copy to clipboard
  4. (define (read-syntax src ip)
      (define token-thunk (λ () (tokenize-one ip)))
      (define parse-tree (parse src token-thunk))
      (strip-bindings
       (with-syntax ([PT parse-tree])
         #'(module mod-name expander-mod
             PT))))
    1
    2
    3
    4
    5
    6
    7
    (define (read-syntax src ip)
      (define token-thunk (λ () (tokenize-one ip)))
      (define parse-tree (parse src token-thunk))
      (strip-bindings
       (with-syntax ([PT parse-tree])
         #'(module mod-name expander-mod
             PT))))
    
    copy to clipboard
  5. (module reader br
      (provide read-syntax)
      (define (read-syntax src ip)
        ···))
    1
    2
    3
    4
    (module reader br
      (provide read-syntax)
      (define (read-syntax src ip)
        ···))
    
    copy to clipboard
    (module+ reader
      (provide read-syntax))

    (define (read-syntax src ip)
      ···)
    1
    2
    3
    4
    5
    (module+ reader
      (provide read-syntax))
    
    (define (read-syntax src ip)
      ···)
    
    copy to clipboard
taco-compiler/test.rkt
#lang taco-compiler

"hello world"
(+ 1 (* 2 (- x)))
1
2
3
4
#lang taco-compiler

"hello world"
(+ 1 (* 2 (- x)))
copy to clipboard
taco-compiler/main.rkt
#lang br/quicklang

(module+ reader
  (provide read-syntax))

(define (tokenize ip)
  (for/list ([tok (in-port read-char ip)])
    tok))

(define (parse src toks)
  ;; ···
  )

(define (read-syntax src ip)
  (define toks (tokenize ip))
  (define parse-tree (parse src toks))
  (strip-bindings
   (with-syntax ([PT parse-tree])
     #'(module tacofied taco-compiler
         PT))))

(define-macro (mb PT)
  #'(#%module-begin
     (for-each displayln 'PT)))
(provide (rename-out [mb #%module-begin]))
 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
#lang br/quicklang

(module+ reader
  (provide read-syntax))

(define (tokenize ip)
  (for/list ([tok (in-port read-char ip)])
    tok))

(define (parse src toks)
  ;; ···
  )

(define (read-syntax src ip)
  (define toks (tokenize ip))
  (define parse-tree (parse src toks))
  (strip-bindings
   (with-syntax ([PT parse-tree])
     #'(module tacofied taco-compiler
         PT))))

(define-macro (mb PT)
  #'(#%module-begin
     (for-each displayln 'PT)))
(provide (rename-out [mb #%module-begin]))
copy to clipboard
← prev next →