Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
zehnpaard / machine.py
Created Oct 3, 2021
Implementation of the SECD Abstract Machine (based on Henderson's "Functional Programming Application & Implementation")
View machine.py
from dataclasses import dataclass
from machine_vars import Int, Symbol, Op
@dataclass
class Cons:
car : int
cdr : int
SIZE = 10000
@zehnpaard
zehnpaard / llast.py
Last active Sep 22, 2021
Interpreter for LispKit Lisp (based on Henderson's "Functional Programming Application & Implementation")
View llast.py
from dataclasses import dataclass
@dataclass
class Alpha:
s : str
@dataclass
class Num:
n : int
@zehnpaard
zehnpaard / llast.py
Created Sep 20, 2021
Lexer and Parser for LispKit Lisp (based on Henderson's "Functional Programming Application & Implementation")
View llast.py
from dataclasses import dataclass
@dataclass
class Alpha:
s : str
@dataclass
class Num:
n : int
@zehnpaard
zehnpaard / grammar
Last active Sep 18, 2021
Python Implementation of Memory-Efficient Packrat Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | assign | list | list_assign;
assign : NAME '=' NAME;
list_assign : list '=' list;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Last active Sep 18, 2021
Python Implementation of Cache-Clearing Packrat Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | assign | list | list_assign;
assign : NAME '=' NAME;
list_assign : list '=' list;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Last active Sep 18, 2021
Python Implementation of Packrat Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | assign | list | list_assign;
assign : NAME '=' NAME;
list_assign : list '=' list;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Last active Sep 18, 2021
Python Implementation of Backtracking Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | assign | list | list_assign;
assign : NAME '=' NAME;
list_assign : list '=' list;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Created Sep 8, 2021
Python Implementation of LL(2) Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | assign | list;
assign : NAME '=' NAME;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Last active Sep 8, 2021
Python Implementation of LL(1) Recursive Descent Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : NAME | list;
NAME : ('a'..'z' | 'A'..'Z')+;
@zehnpaard
zehnpaard / grammar
Last active Sep 8, 2021
Python Implementation of LL(1) Non-Recursive Parser based loosely on Language Implementation Patterns
View grammar
list : '[' elements ']';
elements : element (',' element)*;
element : ('a'..'z' | 'A'..'Z')+;