gooberscript-compiler
v1.2.0
Published
The GooberScript toolchain (Compiler, Lexer, Parser, Transpiler) for ES2020 JavaScript.
Maintainers
Readme
🥳 GooberScript Toolchain
GooberScript is an enthusiastic new language that transpiles directly to clean ES2020 JavaScript. This repository contains the complete, self-contained compiler (goobc.js).
✨ Quick Start (CDN Integration)
For immediate use in environments like CodeHS, load the compiler directly via jsDelivr. Since goobc.js is self-contained and exposes the global Goobc object, you are ready to compile immediately.
Include the Compiler:
Use the Compiler API:
// Example GooberScript Code
const gooberSource = `
dear goober;
heck name iskinda "World" ya;
goober greet() {
yippee;
holler("Hello, " + name + "!"); ya;
} ya;
greet(); ya;
thanks, goober;
`;
// Compile and Execute
const { js, errors } = Goobc.compile(gooberSource);
if (errors && errors.length > 0) {
console.error("GooberScript Compilation Failed:", errors);
} else {
// Execution (Run the resulting JavaScript)
console.log("--- Transpiled JS ---");
console.log(js);
console.log("--- Execution Output ---");
try {
new Function(js)();
} catch (e) {
console.error("Runtime Error:", e);
}
}🛠️ Deployment Instructions (Mac/Terminal)
Follow these steps to deploy your own version of the GooberScript toolchain to NPM and make it available on jsDelivr.
Step 1: Initialize Project
In your macOS Terminal:
Create and enter the project directory
mkdir gooberscript-repo cd gooberscript-repo
Initialize NPM
npm init -y
Step 2: Create Files
Save the content of goobc.js and package.json into the root of the gooberscript-repo directory.
Step 3: Publish to NPM
Before publishing, ensure you are logged into NPM (npm login).
This publishes your package and makes it available globally
npm publish --access public
Step 4: CDN Availability
Once published, your package is immediately mirrored by jsDelivr. The URL for CodeHS/web usage will be:
https://cdn.jsdelivr.net/npm/gooberscript-compiler@/goobc.js
(Replace with your published version, e.g., 1.0.0).
📜 GooberScript Language Reference
Here is a quick reference for all GooberScript tokens and their corresponding JavaScript equivalents.
| GooberScript Token | JS Equivalent | Category | Rule / Notes |
| :--- | :--- | :--- | :--- |
| dear goober; | // Start | Structure | MANDATORY File Header. |
| thanks, goober; | // End | Structure | MANDATORY File Footer. |
| ya; | ; | Syntax | MANDATORY Statement Terminator. |
| yippee; | // Check Pass | Syntax | MANDATORY once per function body (GBR004). |
| goober | var | Variable | Function-scoped variable. |
| heck | let | Variable | Block-scoped variable. |
| nochange | const | Variable | Block-scoped constant (must be initialized). |
| whatif | if | Flow | Conditional flow start. |
| otherwise whatif | else if | Flow | Chained conditional. |
| otherwise | else | Flow | Else block. |
| loopity | while | Flow | While loop. |
| gimme | return | Flow | Returns a value from a function. |
| heckyeah | break | Flow | Exits a loop immediately. |
| nah | continue | Flow | Skips the current loop iteration. |
| holler | console.log | Output | Standard output/logging. |
| nada | null | Value | Null value. |
| andwhat | && | Operator | Logical AND. |
| orelse | \|\| | Operator | Logical OR. |
| nuhuh! | ! | Operator | Logical NOT. |
| isexactly | === | Operator | Strict equality check. |
| iskinda | == | Operator | Loose equality check. |
| aint | !== | Operator | Strict inequality check. |
| x goUp ya; | x++; | Operator | Increment operator. |
| x goDown ya; | x--; | Operator | Decrement operator. |
| //goob / /*goob | // / /* */ | Comments | Goober-specific comments (ignored by transpiler). |
