Skip to content

Instantly share code, notes, and snippets.

This gist expands on this Hacker News reply.


The official Jevko spec is meant to be fully generic, but in fact if you don't care about that then you can use this simplifed grammar to start (ABNF + RegExp):

tree = *sub text
sub  = text '[' tree ']'
text = /[^\[\]]*/
@djedr
djedr / javascript_and_numbers.md
Last active June 29, 2023 02:08
Observations about JavaScript numbers and their parsing. Reply to https://mastodon.social/@rauschma@fosstodon.org/110622841244599511
const smartQueryString = ((strs, ...params) => {
let ret = ''
for (let i = 0; i < strs.length - 1; ++i) {
const str = strs[i]
const param = params[i]
// or whatever escaping method is appropriate
ret += str + encodeURIComponent(param)
}
return ret
})
@djedr
djedr / ron-to-djevko.md
Last active April 23, 2023 14:04
RON -> Djevko

The main tricks I came up with in LAST are precisely basing it on quaternary and making up S-optimization. The former allows for streamlining of the basic BLC interpreter design (the 4 paths that handle the basic term elements are simplified), while the latter capitalizes on that by reducing repetition (nb. making the whole thing more efficient). I spent quite a bit of time working out and automating S-optimimization -- which is certainly the most interesting aspect of LAST and what sets it apart from RFNHS3 or other LC variants. I think it's pretty neat.

So of course if we get rid of the quaternary input, we'll immediately lose the advantage.

I noticed that using two separate tokens for variable handling allows BLC to interpret LAST in only 193 bits.

I think you can get that down to 181 bits, assuming 1:1 translation of S-deoptimized version of the LAST self-interpreter into BLC syntax (so not a valid BLC program, because the assumed input is different). Anyway 193 bits is also nice and I like how it's

@djedr
djedr / easyjevko.js
Last active October 1, 2022 22:33
A simple data format built on Jevko
// run this script with
//
// node --experimental-network-imports easyjevko.js
//
// on Node.js or
//
// deno run --allow-net easyjevko.js
//
// on Deno
@djedr
djedr / grammar.abnf
Created January 9, 2022 23:55
A nice grammar for Jevko
Value = Subvalues Suffix
Subvalue = Prefix "[" Value "]"
Subvalues = *Subvalue
Suffix = *Char
Prefix = *Char
Char = Escape / %x0-5a / %x5c / %x5e-5f / %x61-10ffff
Escape = "`" ("`" / "[" / "]")
@djedr
djedr / xsv.js
Last active August 19, 2021 23:55
A simplistic parser for an imaginary XSV format -- a simplified, configurable variant of CSV
// A simplistic parser for an imaginary XSV format -- a simplified, configurable variant of CSV
// where the first 3 characters specify (in order):
// 1. the escape character (a backslash "\" in the example below)
// 2. the column separator (a comma "," in the example below)
// 3. the row separator (a newline character "\n" in the example below)
const parseXsv = (input) => {
console.assert(input.length >= 3)
const escape = input[0]
const columnSeparator = input[1]
const rowSeparator = input[2]
@djedr
djedr / talk--static-types-and-javascript--2017-03-08.md
Last active March 8, 2017 18:03
Static types and JavaScript. TypeScript and Flow

Static types and JavaScript

2017-03-08

Dariusz Jędrzejczak

http://djedr.github.io

This is a quick overview and comparison of TypeScript and Flow compiled from different sources (see links throughout and at the end of this document).

General-purpose text preprocessing with the C preprocessor. Featuring JavaScript.

2017-02-15 Dariusz Jędrzejczak

http://djedr.github.io


Outline