In this tutorial we're going to build a set of parser combinators.
We'll answer the above question in 2 steps.
- What is a parser?
- and, what is a parser combinator?
So first question: What is parser?
// from https://x.com/Cody_J_Bennett/status/1818025947565584873 | |
// demo https://jsfiddle.net/cbenn/Las0poyu | |
import * as THREE from "three"; | |
import Stats from "three/addons/libs/stats.module.js"; | |
import { OrbitControls } from "three/addons/controls/OrbitControls.js"; | |
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; | |
import { mergeVertices } from "three/addons/utils/BufferGeometryUtils.js"; | |
THREE.ShaderChunk.skinning_pars_vertex = |
This is the first post of a series about Algebraic Effects and Handlers.
There are 2 ways to approach this topic:
Both approaches are valuables and give different insights on the topic. However, not everyone (including me), has the prerequisites to grasp the concepts of Category theory and Abstract Algebra. On the other hand, the operational approach is accessible to a much wider audience of programmers even if it doesn't provide the full picture.
// We model the call stack using a linked list of Generators | |
// Each Generator has a _return field pointing back to its parent | |
function stepGen(gen, arg) { | |
const {done, value} = gen.next(arg) | |
if(done) { | |
if(gen._return) { | |
stepGen(gen._return, value) | |
} |
var $jscomp = $jscomp || {}; | |
$jscomp.scope = {}; | |
$jscomp.arrayIteratorImpl = function (h) { | |
var n = 0; | |
return function () { | |
return n < h.length ? { done: false, value: h[n++] } : { done: true }; | |
}; | |
}; | |
$jscomp.arrayIterator = function (h) { | |
return { next: $jscomp.arrayIteratorImpl(h) }; |
This is the final part of a series about Algebraic Effects and Handlers.
So we've come to the core topic. The reality is that we've already covered most of it in the previous parts. Especially, in the third part, where we saw delimited continuations at work.
This is the second part of a series about Algebraic Effects and Handlers.
Note: initially I planned a 3-part series, but since the current post on undelimited continuations ended up taking
This is the third part of a series about Algebraic Effects and Handlers.
In the preceding parts, we introduced the notions of continuations and control transfer. We saw how to capture the current
function isGenerator(x) { | |
return x != null && typeof x.next === "function" | |
} | |
function isFrame(x) { | |
return x != null && x._type_ === 'call_frame' | |
} | |
function call(genFunc, ...args) { |
/* | |
The MIT License (MIT) | |
Copyright (c) 2014 | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |