Skip to content

Instantly share code, notes, and snippets.

View SimonMeskens's full-sized avatar

Simon Meskens SimonMeskens

View GitHub Profile
@SimonMeskens
SimonMeskens / scarlet.md
Last active March 6, 2025 22:21
Programming language that resembles redstone

Scarlet - A mini-language vaguely based on redstone

MIT license

Overview

Scarlet is a 2D programming language where the output of the program looks like the source code, but colored based on the signals propagating.

Semantics

  • [a-Z]: Solid block, turns white if receiving a signal
  • [0-9]: Like a solid block, but only pass their signal to nearby blocks after X ticks, where X is their number
  • +: Dust, 16 states, 0 being off, can receive signal from a solid block
@SimonMeskens
SimonMeskens / stream-machines.md
Last active March 20, 2025 15:57
WIP - Stream automata for a turing machine equivalent to concatenative programming.

Copyright 2025 Simon Meskens Licensed under the MIT License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided this license is preserved. This software is offered as-is, without any warranty.

Stream Machine: An abstract machine with a transition table, no machine state and a finite number of lazy stacks. One of the stacks is the program stack and after each transition, the top of the program stack is popped off.

@SimonMeskens
SimonMeskens / lambdastack.js
Last active February 5, 2025 01:06
Defunctionalized continuations in JS using algebraic data types
// Copyright 2025 Simon Meskens
// Licensed under the MIT License
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided this license is
// preserved. This software is offered as-is, without any warranty.
// Based on: https://www.youtube.com/watch?v=O6s8_4agu4c
// https://gist.github.com/paf31/16f25ef70eaf256fbf301b571db6d533
@SimonMeskens
SimonMeskens / direct.zig
Last active February 5, 2025 01:07
Threaded code in Zig
// Copyright 2024 Simon Meskens
// Licensed under the MIT License
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided this license is
// preserved. This software is offered as-is, without any warranty.
// https://godbolt.org/z/TK5r79esP
pub const VM = struct {
code: []const Inst,

mlatu specification

https://mlatu-lang.github.io/mlatu/

Syntax

A rule is composed of a non-empty sequence of non-quotation terms, followed by the symbol =, followed by a possibly empty sequence of terms, followed by the symbol .. The first sequence of terms is known as the pattern or the redex, and the second sequence of terms is known as the replacement or the reduction. If two rules with the same replacement are defined, it is undefined behaviour.

A term is either a primitive symbol (+, -, >, <, ,, or ~), a word, or a quotation - the symbol (, followed by a possibly empty sequence of terms, followed by the symbol ). A word is composed of a sequence of Unicode characters which does not include whitespace or any of the syntactical or primitive symbols (+-><,~()=.)

Pick either the second or third paragraph and the final one is optional.

Copyright (c) 2024 «AUTHORS»

In the name of a free and open culture, you may do anything with this software that copyright law would normally restrict, provided this license is preserved. This software is offered as-is, without any warranty.

To the extent permitted under applicable law, worldwide, all copyright holders fully waive their copyrights to this software and dedicate it to the public domain.

This software or any derivatives of this software can only be distributed with their source code publicly available; software that is distributed with this software as part of it should also require the same. Services can only make use of this software provided that any modifications are publicly available.

const top = (stack) => stack.length - 1;
const zero = ({ left }) => left.push(0);
const pop = ({ right }) => right.pop();
const increment = ({ left }) => (left[top(left)] = (left[top(left)] + 1) % 256);
const decrement = ({ left }) =>
(left[top(left)] = (left[top(left)] + 255) % 256);
const shift = ({ left, right }) => right.push(left.pop());
@SimonMeskens
SimonMeskens / UTF-8
Last active February 4, 2025 06:01
UTF-8 Explained using one diagram
UTF-8 Code point: a bb bb cc cc dd dd ee ee ff ff
0 e ee ff ff
10 ------- ----------- ---- ERROR -----------
110 d dd ee 10 ee ff ff
1110 cc cc 10 dd dd ee 10 ee ff ff
11110 a bb 10 bb cc cc 10 dd dd ee 10 ee ff ff
111110 ------- ----------- ---- ERROR -----------
@SimonMeskens
SimonMeskens / 00Pattern.purs
Last active February 5, 2025 01:07
Brzozowski derivatives in PureScript - MIT License
module Patterns
( Pattern(..)
, unite
, concat
, repeat
, complement
, derivative
) where
import Data.Boolean (otherwise)
@SimonMeskens
SimonMeskens / lexer.js
Last active February 5, 2025 01:09
JavaScript climbing parser
// Copyright 2023 Simon Meskens
// Licensed under the MIT License
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided this license is
// preserved. This software is offered as-is, without any warranty.
const types = [
[null, /[^\P{Pattern_White_Space}\n]+/msuy],
["break", /\n/msuy],