https://github.com/synthetic-borealis/uwu-toolkit
An UwU source-to-source compilation library for Node.js, Deno & web browsers.
https://github.com/synthetic-borealis/uwu-toolkit
brainfuck deno esoteric-language javascript library nodejs typescript
Last synced: 3 months ago
JSON representation
An UwU source-to-source compilation library for Node.js, Deno & web browsers.
- Host: GitHub
- URL: https://github.com/synthetic-borealis/uwu-toolkit
- Owner: synthetic-borealis
- License: mit
- Created: 2022-01-22T16:13:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-24T13:35:08.000Z (over 2 years ago)
- Last Synced: 2025-01-29T05:18:08.049Z (4 months ago)
- Topics: brainfuck, deno, esoteric-language, javascript, library, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.05 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# UwU Toolkit
[](https://github.com/synthetic-borealis/uwu-toolkit/blob/main/LICENSE)
[](https://badge.fury.io/js/uwu-toolkit)

[](https://codecov.io/github/synthetic-borealis/uwu-toolkit)An UwU source-to-source compilation library for web-browsers, Node.js & Deno.
## Contents
1. [What is Uwu](#what-is-uwu)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Supported output languages](#supported-output-languages)
5. [Examples](#examples)## What is UwU?
UwU is an esoteric programming language created by [Kira Rose](https://github.com/KiraDotRose). It
is a member of the Brainfuck trivial substitution family of programming languages. An example
program written in UwU, and a list of commands can be
found [here](https://github.com/KiraDotRose/UwU).## Installation
Run `npm i uwu-toolkit` or `yarn add uwu-toolkit`.
## Usage
- Use `compileTo[LANGUAGE]()` where `[LANGUAGE]` is a supported output language/variant (
e.g. `compileToJsWeb()`).
- The web variant of the JavaScript transpiler generates a function that returns an object
containing two members:
1. `output` - The output of the program.
2. `cells` - The array of cells that were used by the program.
- See the [documentation](docs/API.md) for more information.## Supported Output Languages
- Brainfuck.
- C.
- C++.
- JavaScript.
- Python.### Table 1: Supported Commands by Output Language
| Language | OwO | °w° | UwU | QwQ | @w@ | >w< | \~w\~ | ¯w¯ | Memory Size |
|:---------------------| :-----: | :-----: | :-----: | :-----: | :-----: | :-----: | :-----: | :-----: | :------------: |
| Brainfuck | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Not Applicable |
| C | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 30,000 |
| C++ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 30,000/Dynamic |
| JavaScript (Web) | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | 30,000/Dynamic |
| JavaScript (Node.js) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 30,000/Dynamic |
| JavaScript (Deno) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 30,000/Dynamic |
| Python | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 30,000/Dynamic |## Examples
### CommonJS (Node)
```javascript
const uwuTK = require('uwu-toolkit');const helloUwu = 'UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO'
+ 'UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU'
+ 'UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯'
+ 'OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°'
+ 'QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@'
+ '@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@'
+ 'OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°'
+ '°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO'
+ 'UwU @w@ OwO OwO UwU UwU @w@';try {
const helloJS = uwuTK.compileToJsWeb(helloUwu);
const hello = new Function(`${helloJS}return main().output;`);console.log(hello());
} catch (err) {
console.error(`Error: ${err.message}`);
}
```### Program Validation - CommonJS (Node)
```javascript
const uwuTK = require('uwu-toolkit');const helloUwu = 'UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO'
+ 'UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU'
+ 'UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯'
+ 'OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°'
+ 'QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@'
+ '@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@'
+ 'OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°'
+ '°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO'
+ 'UwU @w@ OwO OwO UwU UwU @w@';const invalidUwu = 'UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO'
+ 'UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU'
+ 'UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯'
+ 'OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°'
+ 'QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@'
+ '@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@'
+ 'OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°'
+ '°w° QwQ QwQ QwQ QwQ QwQ QwQ ¯w¯ QwQ QwQ QwQ QwQ @w@ OwO OwO'
+ 'UwU @w@ OwO OwO UwU UwU @w@';const validSourceArray = uwuTK.tokenizeUwuSource(helloUwu);
const invalidSourceArray = uwuTK.tokenizeUwuSource(invalidUwu);console.log(uwuTK.isValidProgram(validSourceArray)); // true
console.log(uwuTK.isValidProgram(invalidSourceArray)); // false
```### ESM (Node)
```javascript
import * as uwuTK from 'uwu-toolkit';const helloUwu = 'UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO'
+ 'UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU'
+ 'UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯'
+ 'OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°'
+ 'QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@'
+ '@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@'
+ 'OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°'
+ '°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO'
+ 'UwU @w@ OwO OwO UwU UwU @w@';try {
const helloJS = uwuTK.compileToJsWeb(helloUwu);
const hello = new Function(`${helloJS}return main().output;`);console.log(hello());
} catch (err) {
console.error(`Error: ${err.message}`);
}
```### ESM (Deno)
```javascript
import * as uwuTK from "https://jspm.dev/uwu-toolkit";const helloUwu = "UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO"
+ "UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU"
+ "UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯"
+ "OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°"
+ "QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@"
+ "@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@"
+ "OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°"
+ "°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO"
+ "UwU @w@ OwO OwO UwU UwU @w@";try {
const helloJS = uwuTK.compileToJsWeb(helloUwu);
const hello = new Function(`${helloJS}return main().output;`);console.log(hello());
} catch (err) {
console.error(`Error: ${err.message}`);
}
```### TypeScript (Deno)
```typescript
import * as uwuTK from "https://cdn.jsdelivr.net/gh/synthetic-borealis/uwu-toolkit/deno/index.ts";const helloUwu = "UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO" +
"UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU" +
"UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯" +
"OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°" +
"QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@" +
"@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@" +
"OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°" +
"°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO" +
"UwU @w@ OwO OwO UwU UwU @w@";try {
const helloJS = uwuTK.compileToJsWeb(helloUwu);
const hello = new Function(`${helloJS}return main().output;`);console.log(hello());
} catch (err) {
console.error(`Error: ${err.message}`);
}
```### Web
```html
Hewwo Wowwd!
Run
const runButton = document.getElementById('run-button');
const outputBox = document.getElementById('output-box');
const helloUwu = 'UwU UwU UwU UwU UwU UwU UwU UwU ~w~ OwO'
+ 'UwU UwU UwU UwU ~w~ OwO UwU UwU OwO UwU UwU UwU OwO UwU UwU'
+ 'UwU OwO UwU OwO UwU UwU UwU UwU °w° °w° °w° °w° °w° QwQ ¯w¯'
+ 'OwO UwU OwO UwU OwO QwQ OwO OwO QwQ OwO UwU ~w~ °w° ¯w¯ °w°'
+ 'QwQ ¯w¯ OwO OwO @w@ OwO QwQ QwQ QwQ @w@ OwO OwO OwO QwQ @w@'
+ '@w@ °w° °w° °w° UwU UwU UwU UwU UwU UwU UwU UwU UwU UwU @w@'
+ 'OwO OwO @w@ °w° QwQ @w@ °w° @w@ OwO OwO OwO @w@ @w@ °w° °w°'
+ '°w° QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ QwQ @w@ OwO OwO'
+ 'UwU @w@ OwO OwO UwU UwU @w@';outputBox.value = '';
runButton.addEventListener('click', () => {
try {
const helloWorldProgram = uwuTK.compileToJsWeb(helloUwu);
const helloWorld = new Function(`${helloWorldProgram} return main().output;`);outputBox.value += helloWorld();
} catch (err) {
outputBox.value += `Error: ${err.message}`;
}
});
```