WidePepper is a dynamically typed, embeddable scripting language with a cat-themed syntax. Its design philosophy centers around simplicity, readability, and ensuring users are always entertained by its feline reserved words.
# Run a script file
widepepper script.wp
# Show tokens (for debugging)
widepepper -tokens script.wp
# Read from stdin
cat script.wp | widepepper -stdin
# Show help
widepepper -helpCreate a file named hello.wp:
yarn greeting = "Hello, WidePepper!";
meow greeting;
Run it:
widepepper hello.wp- Go 1.16 or higher
- Git
git clone https://github.com/BoyPlankton/WidePepper.git
cd WidePepper
make buildThe compiled binary will be in ./bin/widepepper.
make installThis installs the widepepper command to your $GOPATH/bin directory.
widepepper [OPTIONS] [SCRIPT.wp]
Options:
-help Show help message
-version Show version information
-tokens Display lexer tokens instead of parsed AST
-stdin Read script from standard input
# Parse and show AST
widepepper script.wp
# Show tokens for debugging
widepepper -tokens script.wp
# Pipe script from another command
echo 'meow "test";' | widepepper -stdin
# Display version
widepepper -versionWidePepper includes several example scripts in the examples/ directory:
| Example | Description |
|---|---|
01_hello_world.wp |
Simplest program - declare a variable and print it |
02_variables.wp |
Variables and arithmetic operators |
03_conditionals.wp |
If/else statements (pounce/hiss) |
04_loops.wp |
Looping with chase, continue (stretch), and break (claw) |
05_functions.wp |
Function definition and calling (purr) |
06_operators.wp |
Arithmetic, comparison, and logical operators |
07_complex_example.wp |
Complete program combining multiple features |
08_file_io.wp |
File I/O operations (read/write files) |
09_network_io.wp |
Network operations (HTTP GET/POST) |
# Run an example with make
make run-example EXAMPLE=01_hello_world
make run-example EXAMPLE=02_variables
# Or run directly
widepepper examples/01_hello_world.wp
widepepper examples/04_loops.wp
# Show tokens for an example
make run-tokens EXAMPLE=02_variablesAll reserved words in WidePepper are case-sensitive and cat-themed.
| Keyword | Purpose | Traditional Equivalent |
|---|---|---|
yarn |
Variable declaration | var, let |
purr |
Function definition | function, def |
pounce |
Conditional (if) | if |
hiss |
Else branch | else |
chase |
Loop (while) | while, for |
treat |
Return value | return |
meow |
Output/Print | print, log |
catnip |
Boolean true | true |
mice |
Boolean false | false |
claw |
Break loop | break |
stretch |
Continue loop | continue |
| Symbol | Purpose |
|---|---|
= |
Assignment |
==, !=, <, >, <=, >= |
Comparison |
+, -, *, / |
Arithmetic |
&&, ||, ! |
Logical (AND, OR, NOT) |
; |
Statement terminator |
{} |
Code blocks |
() |
Grouping, function calls |
[] |
Array indexing |
. |
Member access |
// Single-line comment (Whiskers style)
/* Multi-line comment (Nap time style)
Perfect for long explanations
*/
WidePepper supports several core data types:
| Type | Description | Example |
|---|---|---|
| Number | Integer or float | 42, 3.14 |
| String | Text in double quotes | "Hello, cat" |
| Boolean | Logical value | catnip (true), mice (false) |
| Array | Ordered collection | ["toy", "ball", 3] |
| Null | No value (reserved) | EmptyBowl |
Variables are declared with the yarn keyword and are dynamically typed.
// Declaration and initialization
yarn cat_name = "Whiskers";
yarn age = 5;
yarn is_happy = catnip;
// Reassignment (yarn omitted after first declaration)
age = age + 1;
// Output
meow cat_name;
Functions are defined with the purr keyword and use treat to return values.
// Function definition
purr greet(name) {
meow "Hello, " + name + "!";
}
// Function with return value
purr add(a, b) {
yarn sum = a + b;
treat sum;
}
// Using functions
greet("Mittens");
yarn result = add(5, 3);
meow result;
yarn age = 7;
pounce (age < 3) {
meow "Kitten!";
} hiss {
meow "Adult cat!";
}
// Nested conditionals
pounce (age > 10) {
meow "Senior kitty!";
} hiss pounce (age > 3) {
meow "Adult cat!";
} hiss {
meow "Young cat!";
}
// Loop with counter
yarn count = 0;
chase (count < 5) {
meow count;
count = count + 1;
}
// With continue (stretch)
yarn i = 0;
chase (i < 10) {
i = i + 1;
pounce (i == 5) {
stretch; // Skip this iteration
}
meow i;
}
// With break (claw)
yarn found = mice;
chase (found == mice) {
pounce (some_condition) {
found = catnip;
claw; // Exit loop
}
}
yarn a = 10;
yarn b = 3;
meow a + b; // 13
meow a - b; // 7
meow a * b; // 30
meow a / b; // 3.333...
yarn x = 5;
yarn y = 10;
meow x < y; // catnip (true)
meow x > y; // mice (false)
meow x == y; // mice
meow x != y; // catnip
yarn is_sunny = catnip;
yarn is_warm = catnip;
meow is_sunny && is_warm; // catnip
meow is_sunny || is_warm; // catnip
meow !is_sunny; // mice
- Grouping:
() - Unary:
!,- - Multiplication/Division:
*,/ - Addition/Subtraction:
+,- - Comparison:
<,>,<=,>= - Equality:
==,!= - Logical AND:
&& - Logical OR:
||
The meow keyword outputs values to the console.
meow "Hello"; // String
meow 42; // Number
meow catnip; // Boolean
meow 5 + 3; // Expression
WidePepper provides file operations through cat-themed built-in functions:
// Open a file (pounceFile = pounce on file to open)
yarn handle = pounceFile("data.txt", "r");
yarn line = lapLine(handle); // lapLine = lap up one line
yarn content = devourFile(handle); // devourFile = devour entire file
nuzzleClose(handle); // nuzzleClose = nuzzle to close
// Open a file for writing
yarn writeHandle = pounceFile("output.txt", "w");
scratchLine(writeHandle, "Hello, World!"); // scratchLine = scratch to write with newline
scratchString(writeHandle, "No newline"); // scratchString = scratch without newline
nuzzleClose(writeHandle);
// Append to a file
yarn appendHandle = pounceFile("log.txt", "a");
scratchLine(appendHandle, "Log entry");
nuzzleClose(appendHandle);
// Check if file exists (sniffFile = sniff to check)
pounce sniffFile("config.txt") {
meow "Configuration found";
}
// Delete a file (swatFile = swat to delete)
swatFile("temp.txt");
// List files in a directory (pounceDirectory = pounce on directory)
yarn files = pounceDirectory("./data");
WidePepper supports HTTP operations with cat-themed names:
// GET request (fetchURL = fetch from URL)
yarn response = fetchURL("https://api.example.com/data");
meow response;
// POST request (coughUpData = cough up data via POST)
yarn postData = "{\"key\": \"value\"}";
yarn result = coughUpData("https://api.example.com/api", "application/json", postData);
meow result;
The project includes a Makefile with convenient development targets:
# Build the project
make build
# Run all tests
make test
# Run tests with coverage
make test-cover
# Display coverage percentage
make coverage
# Run a specific example
make run-example EXAMPLE=02_variables
# Show tokens for debugging
make run-tokens EXAMPLE=02_variables
# Format code
make fmt
# Run linter
make vet
# Clean build artifacts
make clean
# View all available targets
make helpWidePepper/
├── ast/ # Abstract Syntax Tree definitions
├── lexer/ # Lexical analyzer
├── parser/ # Parser implementation
├── token/ # Token definitions
├── examples/ # Example WidePepper scripts (.wp files)
├── main.go # CLI entry point
├── go.mod # Go module definition
├── Makefile # Build and development targets
└── README.md # This file
Run tests with coverage:
make test-coverView detailed coverage:
make coverageGenerate HTML coverage report:
go tool cover -html=coverage.out -o coverage.html
open coverage.html- ✅ Lexer: 95.8% coverage, 21 comprehensive tests
- ✅ Parser: 69.4% coverage, 17 comprehensive tests
- ✅ AST: 57.6% coverage, 13+ comprehensive tests
- ✅ Builtins (I/O): 64.8% coverage, 11 comprehensive tests
- ✅ Total: 60+ passing tests across all packages
- ✅ File I/O: Read, write, append, delete, list operations
- ✅ Network I/O: HTTP GET and POST requests
The compiler is organized into modular packages:
- Token Package (
token/): Defines token types used by the lexer - Lexer Package (
lexer/): Tokenizes source code into a stream of tokens - AST Package (
ast/): Defines Abstract Syntax Tree node types - Parser Package (
parser/): Parses tokens into an AST - Builtins Package (
builtins/): Provides file I/O and network operations - Main Package (
main.go): CLI and script execution
Contributions are welcome! Areas for enhancement include:
- Full AST evaluation/interpretation (evaluator/interpreter)
- Variable scoping and execution environment
- More built-in functions (strings, math, time, etc.)
- Standard library modules
- REPL mode (interactive shell)
- Better error messages with line/column tracking
- Optimization passes
- Code formatting tool
- Language server protocol (LSP) support
This project is licensed under the MIT License - see the LICENSE file for details.
Happy scripting with WidePepper! 🐱
