all repos — hex @ dab4cefae4cab723ea9e597e7bfb9b6345438182

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Implemented support for {{sym<symbol>}} placeholder substitution.
h3rald h3rald@h3rald.com
Wed, 11 Dec 2024 13:53:11 +0100
commit

dab4cefae4cab723ea9e597e7bfb9b6345438182

parent

d73f0a2ba724e8082d30f3649eb1d2cbde762e10

2 files changed, 28 insertions(+), 4 deletions(-)

jump to
M scripts/web.hexscripts/web.hex

@@ -15,6 +15,10 @@ d-assets ls . "assets" :

d-releases ls . "releases" : d-templates "/page.html" cat "t-page" : +; Symbols to substitute with the corresponding links, +; if found in text. +("split" "run" "get" "puts") "symbol-links" : + ; Convenience symbol for debugging (dup puts) "_" :

@@ -34,6 +38,23 @@ while

pt-content ) "process-tag" : +; Replace symbol placeholder with link to spec +( + "t-symbol" : + "t-content" : + ("<a href=\"/spec#" t-symbol "-symbol\">" t-symbol "</a>") () map "" join "t-repl" : + ; Push replacement content on the stack + t-content + "sym-" t-symbol cat + t-repl + process-tag . + ; Free temporary symbols + "t-repl" # + "t-symtag" # + "t-symbol" # +) "process-symbol" : + +; Load releases content for changelog "" "releases-content" : ( releases

@@ -74,6 +95,8 @@ "release" meta-release process-tag .

"year" meta-year process-tag . "releases" releases-content process-tag . "new-content" : + ; Replace symbols with links + symbol-links (new-content swap process-symbol . "new-content" :) each (fn-content "home.html" ==) ( ; Process home page

@@ -87,6 +110,7 @@ if

" - Writing: " dst-file cat puts new-content dst-file write ) each + ; Write assets ("sh -c \"mkdir -p " d-out "/assets\"") () map "" join exec
M web/contents/home.htmlweb/contents/home.html

@@ -35,15 +35,15 @@ <pre><code>"ls" run 0x1 get "&bsol;n" split puts</code></pre>

<p>Note that <strong>no variable is used in the code above</strong>! Let's break it down:</p> <ul> <li>The string <code>"ls"</code> is pushed on the stack.</li> - <li>The <code>run</code> symbol is executed, which runs the command <code>ls</code> and pushes quotation on the + <li>The {{sym-run}} symbol is executed, which runs the command <code>ls</code> and pushes quotation on the stack containing three elements: the return code of the program, its standard output, and its standard error.</li> <li>The integer <code>0x1</code> is pushed on the stack.</li> - <li>The <code>get</code> symbol is executed, which retrieves the second element of the quotation (the standard + <li>The {{sym-get}} symbol is executed, which retrieves the second element of the quotation (the standard output).</li> <li>The string <code>"&bsol;n"</code> is pushed on the stack.</li> - <li>The <code>split</code> symbol is executed, which splits the string using the newline character as a + <li>The {{sym-split}} symbol is executed, which splits the string using the newline character as a separator.</li> - <li>The <code>puts</code> symbol is executed, which prints the quotation on the stack.</li> + <li>The {{sym-puts}} symbol is executed, which prints the quotation on the stack.</li> </ul> </article>