Something not unlike racket's at-expr but not fancy.
Find a file
2021-08-05 16:36:43 +02:00
syntax initial commit. 2021-08-05 16:34:22 +02:00
LICENCE initial commit. 2021-08-05 16:34:22 +02:00
README.md Fixed readme 2021-08-05 16:36:43 +02:00

at-expr for guile. Almost.

Use like this:

#@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

;; 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:

#@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.