whitten

Lisp Macro implementation

Jul 17th, 2016
7,640
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 1.16 KB | None | 0 0
  1. ;;from https://gist.github.com/jlongster (James Long)
  2. ;; outlet code for implementing traditional macro expansion
  3.  
  4. ;; macros
  5.  
  6. (define (expand form)
  7.   (cond
  8.    ((variable? form) form)
  9.    ((literal? form) form)
  10.    ((macro? (car form))
  11.     (expand ((macro-function (car form)) form)))
  12.    ((eq? (car form) 'quote)
  13.     form)
  14.    ((eq? (car form) 'lambda)
  15.     `(lambda ,(car (cdr form))
  16.        ,@(map expand (cdr (cdr form)))))  
  17.    (else (map expand form))))
  18.  
  19. (define _macros_ {})
  20.  
  21. (define (macro-function name)
  22.   (ref _macros_ (symbol->string name)))
  23.  
  24. (define (install-macro name func)
  25.   (put! _macros_ (symbol->string name) func))
  26.  
  27. (define (macro? name)
  28.   (not (eq? (ref _macros_ (symbol->string name))
  29.             undefined)))
  30.  
  31. ;; compiler
  32.  
  33. (define (read src)
  34.   (vector-to-list
  35.    (reader grammar src '[begin])))
  36.  
  37. (install-macro 'define (lambda (form)
  38.                          `(define* ,(car (cdr form))
  39.                             ,@(cdr (cdr form)))))
  40.  
  41. (let ((src (fs.readFileSync "example.ol" "utf-8")))
  42.   (pretty (expand (read src))))
  43.  
  44. ;; (define (foo x y z)
  45. ;;   (+ x y z))
  46. ;;
  47. ;; expand to:
  48. ;;
  49. ;; (define* (foo x y z)
  50. ;;   (+ x y z))
Advertisement
Comments
  • Vartotir
    233 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
Add Comment
Please, Sign In to add comment