Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro emit (language file &body body)
- `(with-open-file (str ,file
- :direction :output
- :if-exists :supersede)
- (format str "~A" (cond ((eq ',language 'html)
- (with-html-output-to-string (s nil :prologue t :indent t) ,@body))
- ((eq ',language 'javascript)
- (ps ,@body))
- ((eq ',language 'json)
- (remove #\; (ps ,@body)))))))
- (emit json "blah.txt"
- (create "name" "Blah"
- "description" "Blah."
- "version" "1.0"
- "manifest_version" 3
- "background" (create "service_worker" "blah.js")
- "permissions" (array "storage")
- "action" (create "default_title" "Blah"
- "default_popup" "blah.html")))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; slime-expand-1
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (WITH-OPEN-FILE
- (STR "blah.txt" :DIRECTION :OUTPUT :IF-EXISTS
- :SUPERSEDE)
- (FORMAT STR "~A"
- (COND
- ((EQ 'JSON 'HTML)
- (WITH-HTML-OUTPUT-TO-STRING (S NIL :PROLOGUE T :INDENT T)
- (CREATE "name" "Blah" "description"
- "Blah." "version" "1.0"
- "manifest_version" 3 "background"
- (CREATE "service_worker" "blah.js") "permissions"
- (ARRAY "storage") "action"
- (CREATE "default_title" "Blah" "default_popup"
- "blah.html"))))
- ((EQ 'JSON 'JAVASCRIPT)
- (PS
- (CREATE "name" "Blah" "description"
- "Blah." "version" "1.0"
- "manifest_version" 3 "background"
- (CREATE "service_worker" "blah.js") "permissions"
- (ARRAY "storage") "action"
- (CREATE "default_title" "Blah" "default_popup"
- "blah.html"))))
- ((EQ 'JSON 'JSON)
- (REMOVE #\;
- (PS
- (CREATE "name" "Blah" "description"
- "Blah." "version"
- "1.0" "manifest_version" 3 "background"
- (CREATE "service_worker" "blah.js") "permissions"
- (ARRAY "storage") "action"
- (CREATE "default_title" "Blah" "default_popup"
- "blah.html"))))))))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; compilation output
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; processing (DEFMACRO EMIT ...)
- ; processing (EMIT JSON ...)
- ; file: /tmp/slimeNopc75
- ; in: EMIT JSON
- ; (PARENSCRIPT:CREATE "name" "Blah" "description" "Blah." "version" "1.0"
- ; "manifest_version" 3 "background"
- ; (PARENSCRIPT:CREATE "service_worker" "blah.js") "permissions" ...)
- ;
- ; note: deleting unreachable code
- ; file: /tmp/slimeNopc75
- ; in: EMIT JSON
- ; (ARRAY "storage")
- ;
- ; caught WARNING:
- ; The function ARRAY is undefined, and its name is reserved by ANSI CL so that
- ; even if it were defined later, the code doing so would not be portable.
- ; (PARENSCRIPT:CREATE "name" "Blah" "description" "Blah." "version" "1.0"
- ; "manifest_version" 3 "background"
- ; (PARENSCRIPT:CREATE "service_worker" "blah.js") "permissions" ...)
- ;
- ; caught STYLE-WARNING:
- ; undefined function: PARENSCRIPT:CREATE
- ;
- ; compilation unit finished
- ; Undefined functions:
- ; ARRAY CREATE
- ; caught 1 WARNING condition
- ; caught 1 STYLE-WARNING condition
- ; printed 1 note
- CL-USER>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement