Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Red [
- Title: "Lispy reader macros"
- Dedication: "to the spirit that lives in the computer"
- Author: 9214
- Date: 24-Aug-2017
- Usage: {
- o plug in REPL with do %<filename>.red or simply copypaste;
- o have fun!
- }
- Tip: "use backtick to quote paren! (i.e. s-expressions)"
- Example: [
- SICP ex. 2.25
- cadaddr `(1 3 (5 7) 9)
- caar `((7))
- cadadadadadadr `(1 (2 (3 (4 (5 (6 7))))))
- ]
- ]
- system/lexer/pre-load: function [src part][
- new: object [
- _: {}
- rst: does [clear _]
- fmt: func ['word][form reduce [space :word space]]
- add: func ['word][append _ fmt :word]
- -a-: does [add first]
- -d-: does [add next]
- ]
- c~r: [#"c" some [#"a" (-a-) | #"d" (-d-)] #"r"]
- tweak: quote (s: change/part s _ e rst)
- lisp: compose/only [s: (c~r) e: (tweak) :s | skip]
- rule: reduce ['any lisp]
- set '` :quote
- parse src bind rule new
- ]
- 'ok
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement