Skip to content

Instantly share code, notes, and snippets.

View coinconclusive's full-sized avatar
😞

coinconclusive

😞
View GitHub Profile
@coinconclusive
coinconclusive / comp.c
Created June 22, 2023 13:50
WIP (planned to be) selfhosting c subset compiler
#include <signal.h> /* raise, SIGTRAP (in fail, for debugging) */
#include <stdio.h> /* fprintf, stderr (in _DBG, for debugging) */
#include <unistd.h> /* write, read, _exit */
#include <fcntl.h> /* open */
#define _DBG(...) fprintf(stderr,__VA_ARGS__)
#define _DBGfn _DBG("%s:%d",__FILE__,__LINE__)
#define _TN ((char*[]){"EOF","NAM","INT"})[tok]
#define _pS(S) _DBG("%s\n",S)
#define _pD(S) _DBG("%d\n",S)
#define _pC(S) _DBG("'%c'\n",S)
@coinconclusive
coinconclusive / wse.c
Last active July 1, 2023 21:33
simple interpreter in C with a mark and sweep GC. wip.
/* Copyright © 2023 Anne Redko */
/* Under the MIT License. https://mit-license.org/ */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <stddef.h>
@coinconclusive
coinconclusive / lc.py
Last active April 8, 2023 19:59
lambda calculus in python 3.10
# by coinconclusive. in public domain.
from __future__ import annotations
from dataclasses import dataclass
from typing import ClassVar
@dataclass
class Lam:
name: str
body: Expr
def __str__(self):
@coinconclusive
coinconclusive / obfuscated0.c
Last active January 15, 2023 18:53
obfuscated integer and float parsing in c
// this compiles with -Wall -Wpedantic -Werror //
int s2i(char**s,int*n){
int z=1;for(*n=0;**s>47
;z*=10)*n=*n*10+*(*s)++
-48;;return z;}void s2f
(char**s,float*f){int n
,z;s2i(s,&n);*f=n;+**s^
46?0:(*f+=(++*s,z=s2i(s
,&n),(n+0.f)/z));}/*a*/