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.
| export class Coroutine { | |
| constructor(generator) { | |
| this.generator = generator[Symbol.iterator](); | |
| this.current = this.generator?.next(); | |
| } | |
| get value() { | |
| return this.current.value; | |
| } |
| function /*1*/ foo /*2*/ (/*3*/) /*4*/ {/*5*/} /*6*/ |
| 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(); | |
| } |
| 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 = '-'; |
| 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; |
| const _ = Symbol('private'); | |
| class ReadOnlyMap { | |
| constructor(map) { | |
| this[_] = map; | |
| } | |
| static from(entries) { | |
| return new ReadOnlyMap(new Map(entries)); | |
| } |
| 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`); | |
| }, |
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.
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](https://www.linkedin.com/i
| (1) MINOTAUR RIPTIDE (2) | |
| (32) FUSION SHATTER! (31) | |
| MINOTAUR RIPTIDE | |
| SWITCHBACK HYPERSHOCK | |
| (16) SWITCHBACK LUCKY (15) | |
| (17) MALICE HYPERSHOCK (18) | |
| MINOTAUR RIPTIDE | |
| COBALT TANTRUM | |
| (8) SAWBLAZE END GAME (7) | |
| (25) BLIP TANTRUM (26) |