Skip to content

Commit

Permalink
Add , -data
Browse files Browse the repository at this point in the history
  • Loading branch information
gilch committed May 28, 2023
1 parent d613fa6 commit 65469a6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hissp/macros.lissp
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,8 @@ except ModuleNotFoundError:pass"
The language is applied right-to-left, like function calls.
Magic characters are

``,`` -data
Suffix interprets callable as data. Write before any ``^``.
``%`` -kwargs
Suffix interprets top element as **kwargs. Write before any ``^``.
``^`` -depth
Expand Down Expand Up @@ -2058,13 +2060,14 @@ except ModuleNotFoundError:pass"

Callables (default depth 1) pop args to their depth and push their
result. These are categorized at read time. Literals are always data,
but elements that read as `tuple` or `str` types are sometimes
ambiguous, in which case they are assumed callable.
but an element that reads as `tuple` or `str` type may be ambiguous,
in which case they are presumed callable, unless it ends with a ``,``.

Methods at depth one are converted to attribute lookups.

#> (^#.__class__.__name__ :x)
'str'

"
(let (reader (hissp..reader.Lissp : ns (.get hissp.compiler..NS))
literal? X#(not (op#contains (# tuple str) (type X)))
Expand All @@ -2081,6 +2084,7 @@ except ModuleNotFoundError:pass"
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)
Expand Down Expand Up @@ -2114,7 +2118,7 @@ except ModuleNotFoundError:pass"
,(op#sub -1 (depth Y))))))
: ())
(reversed (re..findall
"([/&@[\]*:]|(?:[^%^`/&@[\]*:]|`[%^/&@[\]*:])+)(%?\^*)"
"([/&@[\]*:]|(?:[^,%^`/&@[\]*:]|`[,%^/&@[\]*:])+)(%?,?\^*)"
(hissp..demunge s))))
(.pop $#stack)))))

Expand Down

0 comments on commit 65469a6

Please sign in to comment.