Permalink
Browse files

misc reorganizing/sketching

  • Loading branch information...
xkapastel committed Jan 5, 2019
1 parent a9aeccc commit 7a87a1a9d2aa9b0623633f33eba0ea167e763428
@@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta lang="en-US">
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<style>
</style>
</head>
@@ -21,7 +21,8 @@ const version = "0.0.2";
const cacheName = `denshi-${version}`;
const cacheUrls = [
"/",
"/static/denshi.mjs",
"/lib/app.js",
"https://fonts.googleapis.com/css?family=Roboto:300,400,500",
];

async function onInstall(event) {
File renamed without changes.
@@ -15,28 +15,42 @@
// License along with this program. If not, see
// <https://www.gnu.org/licenses/.

// The idea here is to convert a string of ABCD in to a vector,
// "embedding" it in a "latent space". Vector arithmetic in this
// latent space will hopefully correspond to semantic operations on
// the original bytecode.
export class Codec {
import normalize from "./normalize.js";

export default class Module {
constructor() {
this.data = new Map();
}

set(key, value) {
key = key.trim();
value = value.trim();
if (key === value) {
this.data.delete(key);
} else {
this.data.set(key, value);
}
}

// The set of strings seen by the codec determines the structure of
// the latent space.
add(string) {
get(key) {
if (this.data.has(key)) {
return this.data.get(key);
}
return key;
}

delete(key) {
this.data.delete(key);
}

// Convert a string of code to a vector.
encode(string) {
return [];
normalize(src) {
return normalize(src, {
module: (key) => this.get(key),
quota: 100,
});
}

// Convert a vector to a string of code.
decode(vector) {
return "";
include(prefix, reference) {
// XXX TODO Module#include
}
}
@@ -3,3 +3,8 @@ Analyze, normalize, and otherwise manipulate ABCD.
The main data structure related to ABCD from the Awelon project is the
*dictionary*: essentially a key-value store mapping names to blocks,
with efficient manipulation of group of keys by their prefix.

The guiding concept behind acceleration is
[*arithmetic*](http://typedefs.org): sums, products, exponentials are
recognized and accelerated, and therefore data structures made of
these types have reasonable performance.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

This file was deleted.

Oops, something went wrong.
@@ -29,8 +29,8 @@
// Rewrite a string of bytecode until it reaches normal form. Doesn't
// handle quotas, uses a simplistic evaluation strategy. Note that
// this will hang if the bytecode is some sort of infinite loop.
export default function normalize(src) {
let fst = parse(src);
export default function normalize(src, ctx) {
let fst = parse(src, ctx);
let snd = solve(fst);
return quote(snd);
}
@@ -128,7 +128,7 @@ function error(x) {
}

// Convert a string of code in to a term.
function parse(src) {
function parse(src, ctx) {
const isLbracket = (x) => x == "[";
const isRbracket = (x) => x == "]";
const isLparen = (x) => x == "(";
@@ -175,6 +175,8 @@ function parse(src) {
var term = variable(word);
build.push(term);
index++;
} else if (word.length === 0) {
index++;
} else {
error(`couldn't parse word ${word}`);
}
File renamed without changes.
@@ -15,7 +15,7 @@
// License along with this program. If not, see
// <https://www.gnu.org/licenses/.

import Hn from "../web/HackerNews.js";
import Hn from "./web/HackerNews.js";

(async function() {
let links = await Hn.frontPage();
File renamed without changes.
File renamed without changes.
File renamed without changes.
No changes.
No changes.
No changes.
@@ -1,7 +1,7 @@
const path = require("path");

let app = {
entry: "./src/app/index.js",
entry: "./src/app.js",
output: {
path: path.resolve(__dirname, "lib"),
filename: "app.js",
@@ -28,7 +28,7 @@ fs.readdirSync("node_modules")

let bot = {
target: "node",
entry: "./src/bot/index.js",
entry: "./src/bot.js",
output: {
path: path.resolve(__dirname, "bin"),
filename: "bot.js",

0 comments on commit 7a87a1a

Please sign in to comment.