Skip to content

Instantly share code, notes, and snippets.

View leostera's full-sized avatar
🛠️
ars longa vita brevis

Leandro Ostera leostera

🛠️
ars longa vita brevis
View GitHub Profile
use anyhow::{anyhow, Context, Error};
use std::fmt;
mod ffi;
#[derive(Clone, Debug)]
pub enum Sexp {
Atom(String),
List(Vec<Sexp>),
Nil,
use anyhow::{anyhow, Context, Error};
use std::fmt;
mod ffi;
#[derive(Clone, Debug)]
pub enum Sexp {
Atom(String),
List(Vec<Sexp>),
Nil,
./node_modules/.bin/prettier --write grammar.js
grammar.js 61ms
tree-sitter generate
tree-sitter test
s_expressions:
✗ atom
✓ empty
✓ single line
✓ multiple parts
✓ nested s-expressions
import load_lam from "./fib.js";
import run_js from "./fib_in_js.js";
document.onclick = () => {
run_js().then((_) => load_lam().then(lam => {
const run = () => {
lam.step();
requestAnimationFrame(run);
}
-module(fib).
-export([main/1]).
-export([add_entry/2]).
add_entry(_, _) -> ok.
fib(_, _, _, _) -> ok.
main(_) -> fib([], 1000, 1, 0).
-module(fib).
-export([main/1]).
add_entry(DomNode, Text) ->
NewNode = dom_document:create_element(<<"div">>),
dom_element:set_inner_text(NewNode, Text),
dom_element:append_child(DomNode, NewNode).
fib(DomNode, N, B, A) ->
let root = document.getElementById("js");
let t0 = Date.now();
let startedAt = document.createElement("div");
startedAt.innerText = "Started at: "+Date.now();
root.appendChild(startedAt)
let node = document.createElement("div");
node.innerText = "unstarted"
root.appendChild(node)
{module, grep}. %% version = 0
{exports, [{main,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 24}.
{function, print_matches, 3, 2}.
{module, grep}. %% version = 0
{exports, [{main,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 24}.
{function, print_matches, 3, 2}.
% Source code generated with Caramel.
-module(grep).
-export([main/1]).
print_matches(Word, [Word | T], File) ->
io:format(<<"~p: ~p\n">>, [File, Word]),
print_matches(Word, T, File);
print_matches(Word, [_ | T], File)->
print_matches(Word, T, File);