all repos — hex @ 136b4042edbd7b9cada803c17989dbc037ec5d46

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

Implemented simple ssg.
h3rald h3rald@h3rald.com
Sat, 30 Nov 2024 16:57:30 +0100
commit

136b4042edbd7b9cada803c17989dbc037ec5d46

parent

fa251d0c16a7ab1549b0adff6231daf675396b52

7 files changed, 182 insertions(+), 105 deletions(-)

jump to
M .gitignore.gitignore

@@ -56,3 +56,4 @@ hex

# Other example.hex +web/out/
M MakefileMakefile

@@ -6,10 +6,22 @@

hex: hex.c $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ -.PHONY: clean, test, debug-test +.PHONY: clean clean: rm hex + +.PHONY: test test: ./hex tests.hex + +.PHONY: dtest dtest: ./hex -d tests.hex + +.PHONY: web +web: + ./hex web.hex + +.PHONY: dweb +dweb: + ./hex -d web.hex
A web.hex

@@ -0,0 +1,42 @@

+"web/assets" "d_assets" store +"web/templates" "d_templates" store +"web/contents" "d_contents" store +"web/out" "d_out" store + +; Get all files from a directory +("ls " swap cat run 0x1 get "\n" split) "ls" store + +; Get relevant files +d_contents ls i "contents" store +d_assets ls i "assets" store +d_templates "/page.html" cat "t_page" store + +"*** Generating hex web site..." puts +; Write contents +contents +( + "fn_content" store + "fn_content" ".html" "" replace "id_content" store + d_contents "/" fn_content cat cat read "content" store + t_page read "{{content}}" content replace "new_content" store + (fn_content "home.html" ==) + (d_out "/index.html" cat "dst_file" store) + ((d_out id_content "index.html") "/" join "dst_file" store) + if + " - Writing: " dst_file cat puts + new_content dst_file write +) each + +; Write assets +("mkdir -p " d_out "/assets") () map "" join exec +assets +( + "fn_asset" store + (d_out "assets" fn_asset) () map "/" join "dst_file" store + (d_assets fn_asset) () map "/" join "src_file" store + " - Writing: " dst_file cat puts + ("cp" src_file dst_file) () map " " join exec +) each + +"*** Done!" puts +
A web/assets/styles.css

@@ -0,0 +1,66 @@

+html { + margin: 0; + padding: 0; + font-size: 12px; + line-height: 16px; +} + +body { + margin: 1rem; + padding: 0; + font-family: Monospace; + font-size: 1rem; + background-color: black; + color: white; +} + +h1, +h2, +h3 { + margin: 1rem 0 0.5rem 0; + font-size: 1rem; + font-weight: 700; +} + +header { + font-size: 120%; + margin: 0; +} + +header h1 { + display: inline; + font-size: 100%; + font-weight: 400; + margin: 0; +} + +footer { + font-size: 80%; + text-align: center; + margin: auto; +} + +a { + color: lime; + text-decoration: underline; +} + +a:visited { + color: limegreen; +} + +a[href^=http] { + text-decoration-style: dashed; +} + +strong { + font-weight: 600; +} + +em { + font-style: italic; +} + +li { + margin: 0.5rem 0; +}
A web/contents/home.html

@@ -0,0 +1,27 @@

+<article> + <h2>Welcome</h2> + <p>Welcome to the <strong>hex</strong> programming language.</p> + <p><strong>hex</strong> is a tiny minimalist, concatenative, stack-based and slightly-esoteric programming language + that can run on many platforms (including <a href="/play">the browser</a>) and can be used as an embedded + language, to create shell scripts, or simply to learn more about concatenative programming.</p> + <p>Its syntax is heavily inspired by the <a href="https://min-lang.org">min</a> programming language, and features + space-separated tokens, no unnecessary punctuation characters, and round brackets to delimit lists.</p> + <h2>Features</h2> + <ul> + <li>Support <strong>32bit integers</strong>, <em>written only in hexadecimal format</em>, both positive and + negative (represented via <a href="https://en.wikipedia.org/wiki/Two%27s_complement">two's complement</a>), + <strong>strings</strong>, and <strong>quotations</strong> (lists). + </li> + <li><strong>64 native symbols</strong> implementing simple arithmetic, boolean logic, bitwise operations, + comparison of integers, read/write from/to stdin/stdout/stderr, read and write files, execute external + processes, work with quotations and strings, create and delete user symbols (variables), error handling, and + manipulate the stack.</li> + <li>Fully <strong>homoiconic</strong> (everything is data).</li> + <li>Includes a simple <strong>REPL</strong>.</li> + <li>Includes an integrated <strong>help system</strong>.</li> + <li>Implemented as <strong>a single <a href="https://github.com/h3rald/hex/blob/master/hex.c">.c file</a> and a + single <a href="https://github.com/h3rald/hex/blob/master/hex.h">.h file</a></strong>, making it easier + to + embed in other programs and port to different platforms.</li> + </ul> +</article>
D web/templates/index.html

@@ -1,104 +0,0 @@

-<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>hex programming language</title> - <style> - html { - margin: 0; - padding: 0; - font-size: 12px; - line-height: 16px; - } - body { - margin: 1rem; - padding: 0; - font-family: Monospace; - font-size: 1rem; - background-color: black; - color: white; - } - - h1, h2, h3 { - margin: 1rem 0 0.5rem 0; - font-size: 1rem; - font-weight: 700; - } - - header { - white-space: pre-wrap; - margin: 0; - } - - header h1 { - display: inline; - margin: 0; - } - - footer { - font-size: 80%; - text-align: center; - margin: auto; - } - - a { - color: lime; - text-decoration: underline; - } - - a:visited { - color: limegreen; - } - - a[href^=http] { - text-decoration-style: dashed; - } - - strong { - font-weight: 600; - } - - em { - font-style: italic; - } - - li { - margin: 0.5rem 0; - } - </style> -</head> -<body> - <header> - _*_ _ - / \<h1><a href="/">hex</a></h1>\* programming language - *\_/_/_/ - * - </header> - <nav> - <a href="/get-started">Get Started</a> | - <a href="/manual">Manual</a> | - <a href="/play">Play</a> | - <a href="/changelog">Changelog</a> | - <a href="/about">About</a> - </nav> - <article> - <h2>Welcome</h2> - <p>Welcome to the <strong>hex</strong> programming language.</p> - <p><strong>hex</strong> is a tiny minimalist, concatenative, stack-based and slightly-esoteric programming language that can run on many platforms (including <a href="/play">the browser</a>) and can be used as an embedded language, to create shell scripts, or simply to learn more about concatenative programming.</p> - <p>Its syntax is heavily inspired by the <a href="https://min-lang.org">min</a> programming language, and features space-separated tokens, no unnecessary punctuation characters, and round brackets to delimit lists.</p> - <h2>Features</h2> - <ul> - <li>Support <strong>32bit integers</strong>, <em>written only in hexadecimal format</em>, both positive and negative (represented via <a href="https://en.wikipedia.org/wiki/Two%27s_complement">two's complement</a>), <strong>strings</strong>, and <strong>quotations</strong> (lists).</li> - <li><strong>64 native symbols</strong> implementing simple arithmetic, boolean logic, bitwise operations, comparison of integers, read/write from/to stdin/stdout/stderr, read and write files, execute external processes, work with quotations and strings, create and delete user symbols (variables), error handling, and manipulate the stack.</li> - <li>Fully <strong>homoiconic</strong> (everything is data).</li> - <li>Includes a simple <strong>REPL</strong>.</li> - <li>Includes an integrated <strong>help system</strong>.</li> - <li>Implemented as <strong>a single <a href="https://github.com/h3rald/hex/blob/master/hex.c">.c file</a> and a single <a href="https://github.com/h3rald/hex/blob/master/hex.h">.h file</a></strong>, making it easier to embed in other programs and port to different platforms.</li> - </ul> - </article> - <footer> - &copy; 2024 Fabio Cevasco - </footer> -</body> -</html>
A web/templates/page.html

@@ -0,0 +1,33 @@

+<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>hex programming language</title> + <link rel="stylesheet" href="/assets/styles.css"> +</head> + +<body> + <header> + <pre> + _*_ _ + / \<h1><a href="/">hex</a></h1>\* programming language + *\_/_/_/ + * + </pre> + </header> + <nav> + <a href="/get-started">Get Started</a> | + <a href="/manual">Manual</a> | + <a href="/play">Play</a> | + <a href="/changelog">Changelog</a> | + <a href="/about">About</a> + </nav> + {{content}} + <footer> + &copy; 2024 Fabio Cevasco + </footer> +</body> + +</html>