Skip to content

Commit

Permalink
Merge pull request #218 from gilch/compose-macro
Browse files Browse the repository at this point in the history
Compose macro fixes
  • Loading branch information
gilch committed Jun 3, 2023
2 parents d6d3c24 + 7a4b80a commit 3443d48
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/hissp/macros.lissp
Original file line number Diff line number Diff line change
Expand Up @@ -2218,44 +2218,44 @@ except ModuleNotFoundError:pass"
(let ($#stack (list $#args))
(.reverse $#stack)
,@(i#starmap
XY#(case X (let (obj (next (.reads reader (.replace X "`" ""))))
`(.append ,'$#stack
,(if-else (|| (literal? obj)
(.startswith Y ",")
(hissp.reader..is_lissp_string obj)
(control-word? obj)
(module-handle? obj)
(quotation? obj))
(if-else (depth Y)
`(op#getitem (.pop ,'$#stack) ,obj)
obj)
(if-else (|| (depth Y) (not (method? obj)))
`(,obj ,@(XYZW#.#"(X+1-Y-Z)*W"
(depth Y)
(method? obj)
(kwargs? Y)
`((.pop ,'$#stack
,(op#sub -1 (kwargs? Y)))))
: ,@(when (kwargs? Y)
`(:** (dict (.pop ,'$#stack)))))
`((op#attrgetter ',.#"obj[1:]")
(.pop ,'$#stack))))))
.#"/" `(.pop ,'$#stack ,(op#sub -1 (depth Y)))
.#"&" `(.append ,'$#stack (,'XY#.#"X[-1-Y]" ,'$#stack ,(depth Y)))
.#"@" `(.append ,'$#stack (.pop ,'$#stack ,(op#sub -2 (depth Y))))
.#"[" `(.append ,'$#stack
(-<>> (tuple (iter ,'$#stack.pop
(getattr unittest.mock..sentinel
"hissp.]")))
,@(when Y `(op#itemgetter
(:<> (,'$#stack.pop))))))
.#"]" `(.insert ,'$#stack
(op#sub (len ,'$#stack) ,(depth Y))
(getattr unittest.mock..sentinel "hissp.]"))
.#"*" `(.extend ,'$#stack
(reversed (tuple (.pop ,'$#stack
,(op#sub -1 (depth Y))))))
: ())
XY#(case X
(let (obj (next (.reads reader (.replace X "`" ""))))
`(.append ,'$#stack
: :? ,(if-else (|| (literal? obj)
(.startswith Y ",")
(hissp.reader..is_lissp_string obj)
(control-word? obj)
(module-handle? obj)
(quotation? obj))
(if-else (depth Y)
`(op#getitem (.pop ,'$#stack) ,obj)
obj)
(if-else (|| (depth Y) (not (method? obj)))
`(,obj ,@(XYZ#.#"(X+1-Y)*Z"
(depth Y)
(kwargs? Y)
`((.pop ,'$#stack
,(op#sub -1 (kwargs? Y)))))
,@(when (kwargs? Y)
`(: :** (dict (.pop ,'$#stack)))))
`((op#attrgetter ',([#1:] obj))
(.pop ,'$#stack))))))
.#"/" `(.pop ,'$#stack ,(op#sub -1 (depth Y)))
.#"&" `(.append ,'$#stack (,'XY#.#"X[-1-Y]" ,'$#stack ,(depth Y)))
.#"@" `(.append ,'$#stack (.pop ,'$#stack ,(op#sub -2 (depth Y))))
.#"[" `(.append ,'$#stack
(-<>> (tuple (iter ,'$#stack.pop
(getattr unittest.mock..sentinel
"hissp.]")))
,@(when Y `(op#itemgetter
(:<> (,'$#stack.pop))))))
.#"]" `(.insert ,'$#stack
(op#sub (len ,'$#stack) ,(depth Y))
(getattr unittest.mock..sentinel "hissp.]"))
.#"*" `(.extend ,'$#stack
(reversed (tuple (.pop ,'$#stack
,(op#sub -1 (depth Y))))))
: ())
(reversed (re..findall
"([/&@[\]*:]|(?:[^,%^`/&@[\]*:]|`[,%^/&@[\]*:])+)(%?,?\^*)"
(hissp..demunge s))))
Expand Down

0 comments on commit 3443d48

Please sign in to comment.