Skip to content

Instantly share code, notes, and snippets.

View conartist6's full-sized avatar

Conrad Buck conartist6

  • Boulder, CO
View GitHub Profile
conartist6 / cstml.cstml
Last active September 9, 2023 13:53
Proposal: tagType.parser
View cstml.cstml
<!docype cstml>
<CSTML "https://url/to/grammar"/>
<Regex "https://url/to/re/grammar"/>
<CSTML:TokenTag [Tag]>
<| Punctuator "<|" balanced="|>" startSpan="Tag" |>
<Identifier path="tagName">
<| Identifier "ID" |>
conartist6 / cstml.js
Last active September 18, 2023 00:39
CSTML BABLR grammar (will run with
View cstml.js
This file contains a formal grammar defined by yielding instructions to a state machine.
The grammar is extensible, because you can always wrap it in a higher-order grammar!
Formally the system is a VM exectuting an
The VM is not yet sufficiently finished to execute this grammar, but it soon will be.
Usage will be:
import { parse } from 'cst-tokens';
conartist6 / bracket.txt
Created May 2, 2023 14:59
Battlebots Bracket 2023
View bracket.txt
(25) BLIP TANTRUM (26)
conartist6 /
Last active April 2, 2023 15:38
A brief description of me

Who am I?

I am Conrad Buck (also known as conartist6): a software engineer, open source maintainer, and currently full time self-employed inventor.

I specialize in the creation of tools and platforms, with a particular attention to human factors both in the process of software develpment and in the way software affects the lives of the people who use it. I have an abiding love of all things playful, and see deep symmetry between the artistic, scientific, and engineering processes. I am a private pilot.

My history

Between the 2012 and 2020 I was a Frontend Engineer based in San Francisco, where I worked for MyVR, Spruce Media, Switchfly, VMWare, Facebook, and Plangrid (departed due to pandemic). I have most (-.5 credits) of a Bachelor of Arts in Computer Science degree from Bucknell University. A full accounting of this history is on [LinkedIn](

conartist6 /
Last active March 16, 2023 15:55
cst-tokens internal data stucture
  A range is represented as a [Token, Token] tuple.

  A range can only be iterated backwards, which creates the need to store tokens in an array!

  Each node must have its own tokens array to enable efficient editing.

  A context object often abbreviated `ctx` holds WeakMaps, including `paths` and `previousTokens`.

  Tokens reference their preceding token using the `previousTokens` WeakMap.
conartist6 / index.js
Last active March 1, 2023 19:33
cst-tokens grammar snippet
View index.js
import { prod, tok, sym, Grammar } from '@/helpers';
new Grammar({
productions: {
// This version of ImportSpecifier uses helpers to be concise:
*ImportSpecifier() {
yield eat(prod`Identifier:imported`);
yield eatMatch(tok`Keyword:as`, prod`Identifier:local`);
conartist6 / index.js
Last active January 28, 2023 00:00
View index.js
const _ = Symbol('private');
class ReadOnlyMap {
constructor(map) {
this[_] = map;
static from(entries) {
return new ReadOnlyMap(new Map(entries));
conartist6 / ranges.js
Last active January 22, 2023 18:10
Tokenizer ranges
View ranges.js
class Tokenizer {
constructor(source) {
this.source = source;
this.result = null; // result is a token, i.e. a stack of tokens
this.pathRangesByToken = new WeakMap();
this.prevTokensByToken = new WeakMap();
ownTokensFor(path) {
const { prevTokensByToken, pathRangesByToken } = this;
conartist6 / parse-grammar.js
Last active December 4, 2022 21:35
Parser spitballing
View parse-grammar.js
import { Grammar } from '@cst-tokens/grammar';
import { objectEntries } from '@cst-tokens/helpers/iterable';
import { eat, match } from '@cst-tokens/helpers/commands';
import { capture, ref, PN } from '@cst-tokens/helpers/shorthand';
// 2-+2+-2
$capture = '2';
$node = { type: 'Digit', value: $caputure };
$capture = '-';
conartist6 / bench.js
Created November 26, 2022 03:37
Common empties microbenchmark
View bench.js
console.time('new Set');
for (let i = 0; i < 1_000_000; i++) {
new Set();
console.timeEnd('new Set');
console.time('new Map');
for (let i = 0; i < 1_000_000; i++) {
new Map();