a tiny brainfuck interpreter by TypeScript type system.
一个用 TS 类型体操写成的 Brainfuck 解释器
-
Accurate execution
-
Great excptions handling
-
BETTER than tsfuck of mine
// tsfxxk Tsfuck<'++[>+<-]>.', ''> // ❌ Type instantiation is excessively deep and possibly infinite. // tsfxxk2 Tsfuck<'++[>+<-]>.', ''> // ✔️ '\x02'npm i tsfxxk2 # or yarn add tsfxxk2import type { Tsfuck } from 'tsfxxk2' type Output = Tsfuck<',+.', 'a'> // extends 'b'Tsfuck provides an entry type:
type Tsfuck <ProgramString extends string, InputString extends string>Simple enough! This type receives ProgramString and InputString, then extends the output string.
// e.g. type Output = Tsfuck<',+.>,-.', 'ac'> // extends 'bb' type Output = Tsfuck<'++[>+++[>+<-]+<-]>.>.', ''> // extends '\x01\x07' // error type Output = Tsfuck<'[', ''> // extends 'TsfuckError: Unbalanced brackets' type Output = Tsfuck<',,,', 'ab'> // extends 'TsfuckError: Input not enough'