50 lines
1.4 KiB
Markdown
50 lines
1.4 KiB
Markdown
at-expr for guile. Almost.
|
|
|
|
Use like this:
|
|
|
|
``` scheme
|
|
#@list[1 2 3]{This is the fun part.
|
|
It also handles newlines and indentation.}
|
|
|
|
;;=> (1 2 3 "This is the fun part." "\n" "It also handles newlines and indentation.")
|
|
```
|
|
|
|
It differs from Racket's at-expr in that it is not a proper reader extension, but a hack using guile's read-hash-extend. I never had the time nor energy to find all the edge cases and work them out, so no fancy things.
|
|
|
|
# One weird thing
|
|
|
|
``` scheme
|
|
;; Any at-expr in the squiggly part of an at-expr should start without the #.
|
|
#@list{Here I want proper scheme expr: @(+ 1 2).
|
|
Look. No pound sign.}
|
|
;; ("Here I want proper scheme expr: " 3 ". " "\n" "Look. No pound sign.")
|
|
```
|
|
|
|
# grammar
|
|
|
|
```
|
|
@<cmd><[args ...]{squiggly ...}
|
|
|
|
```
|
|
|
|
|
|
Where all parts are optional, but you have to have at least one.
|
|
|
|
cmd and args are read with guile's normal reader. Squiggly is special. Any normal text between { and } is read as a string. If an @ is found, whatever follows is interpreted as an at-expr. To write a literal at, you have to do @"@".
|
|
|
|
Examples:
|
|
|
|
``` scheme
|
|
#@list(1 2 3) ;;=> (list 1 2 3)
|
|
#@list{My name is: @(read)} => (list "My name is: " (read))
|
|
#@+(1 2) ;; => (+ 1 2)
|
|
#@list{I can handle
|
|
source code indentation.
|
|
This line is indented by one space.}
|
|
;; => ("I can handle" "\n" "source code indentation." "\n" " This line is indented by one space.")
|
|
|
|
```
|
|
|
|
# Licence
|
|
|
|
Public domain or CC0 at your discretion.
|