A modern, Python-like programming language with C-style syntax, built in Go and running both as a CLI tool and in the browser via WebAssembly.
- Variables & Constants:
let x = 10;andconst PI = 3.14; - Functions:
func name(params) { ... } - Classes/Objects: Basic OOP support
- Control Flow:
if/else,while,forloops with{}blocks - Comments:
//single-line and/* */multi-line - WASM Ready: Runs in browsers via WebAssembly
- CLI Tool: Downloadable binary for local development
- Go 1.18+: Download from golang.org
- Git: For cloning the repository
- PowerShell 5.1+ or PowerShell Core 7+ (recommended)
- Python 3.x (optional, for development server): Download from python.org
- Make: Usually pre-installed or available via package manager
- Python 3.x (for development server): Usually pre-installed or
apt install python3/brew install python3
If you're on Windows and having trouble:
-
PowerShell Execution Policy: You may need to enable script execution:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Go Environment: Ensure Go is in your PATH by running
go version -
WASM Files: The scripts automatically handle copying
wasm_exec.jsfrom your Go installation -
Web Server: If Python isn't available, you can use any static file server like:
npx serve .(if you have Node.js)- Any other HTTP server of your choice
# Clone the repository
git clone https://github.com/pattygcoding/Tiger-Programming-Language.git
cd Tiger-Programming-Language
# Build everything
make build
# Run a Tiger file
./tiger-cli run myfile.tg
# Start interactive REPL
./tiger-cli repl# Clone the repository
git clone https://github.com/pattygcoding/Tiger-Programming-Language.git
cd Tiger-Programming-Language
# Build everything
.\build.ps1 build
# Run a Tiger file
.\tiger-cli.exe run myfile.tg
# Start interactive REPL
.\tiger-cli.exe repl# Clone the repository
git clone https://github.com/pattygcoding/Tiger-Programming-Language.git
cd Tiger-Programming-Language
# Build everything
build.bat build
# Run a Tiger file
tiger-cli.exe run myfile.tg
# Start interactive REPL
tiger-cli.exe replUnix/Linux/macOS:
- Build the WASM version:
make wasm - Start a web server:
make serve - Open
tiger_go.htmlin your browser
Windows PowerShell:
- Build the WASM version:
.\build.ps1 wasm - Start a web server:
.\build.ps1 serve - Open
tiger_go.htmlin your browser
Windows Command Prompt:
- Build the WASM version:
build.bat wasm - Start a web server:
build.bat serve - Open
tiger_go.htmlin your browser
| Command | Description |
|---|---|
make all |
Build CLI and WASM versions |
make cli |
Build CLI binary only |
make wasm |
Build WebAssembly version only |
make build |
Build everything including wasm_exec.js |
make serve |
Start development server |
make clean |
Clean build artifacts |
make test |
Run tests |
make build-all |
Build for all platforms |
| Command | Description |
|---|---|
.\build.ps1 all |
Build CLI and WASM versions |
.\build.ps1 cli |
Build CLI binary only |
.\build.ps1 wasm |
Build WebAssembly version only |
.\build.ps1 build |
Build everything including wasm_exec.js |
.\build.ps1 serve |
Start development server |
.\build.ps1 clean |
Clean build artifacts |
.\build.ps1 test |
Run tests |
.\build.ps1 build-all |
Build for all platforms |
| Command | Description |
|---|---|
build.bat all |
Build CLI and WASM versions |
build.bat cli |
Build CLI binary only |
build.bat wasm |
Build WebAssembly version only |
build.bat build |
Build everything including wasm_exec.js |
build.bat serve |
Start development server |
build.bat clean |
Clean build artifacts |
build.bat test |
Run tests |
// Variables (mutable)
let name = "Tiger";
let age = 5;
let height = 1.85;
let active = true;
// Constants (immutable)
const PI = 3.14159;
const GREETING = "Hello World";
// Function definition
func greet(name) {
print "Hello";
print name;
}
// Function with multiple parameters
func add(a, b) {
let result = a + b;
print result;
return result;
}
// Function calls
greet("Tiger");
add(5, 3);
// If-else statements (braces required)
if x > 10 {
print "x is greater than 10";
} else {
print "x is 10 or less";
}
// While loops
let counter = 0;
while counter < 5 {
print counter;
counter = counter + 1;
}
// For loops
for (let i = 0; i < 3; i = i + 1) {
print "Iteration";
print i;
}
// Class definition
class Person {
func greet(name) {
print "Hello";
print name;
}
func age() {
return 25;
}
}
// Class usage (basic implementation)
let person = Person;
| Type | Example | Description |
|---|---|---|
| String | "Hello" |
Text values |
| Integer | 42 |
Whole numbers |
| Float | 3.14 |
Decimal numbers |
| Boolean | true, false |
Boolean values |
// Single-line comment
/*
Multi-line comment
Can span multiple lines
*/
let x = 10; // Inline comment
const GREETING = "Welcome to Tiger!";
let user = "Developer";
let version = 1.0;
print GREETING;
print "User:";
print user;
print "Version:";
print version;
func calculateArea(radius) {
const PI = 3.14159;
let area = PI * radius * radius;
print "Area:";
print area;
return area;
}
let r = 5;
if r > 0 {
calculateArea(r);
} else {
print "Invalid radius";
}
print "Counting down:";
let count = 5;
while count > 0 {
print count;
count = count - 1;
}
print "Blast off!";
The Tiger language compiles to WebAssembly and can run directly in browsers. The main WebAssembly entry point is go/main_wasm.go (not a JavaScript file).
Quick WASM Test:
- Build:
make build(Unix) or.\build.ps1 build(Windows) - Serve:
make serve(Unix) or.\build.ps1 serve(Windows) - Open: http://localhost:8000/tiger_go.html
-
Include the WASM files in your web directory:
main.wasm # Compiled Tiger interpreter wasm_exec.js # Go's WebAssembly support library -
Add Tiger to your HTML:
<script src="wasm_exec.js"></script> <script> const go = new Go(); WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject) .then((result) => { go.run(result.instance); }) .catch((error) => { console.error("Failed to load Tiger WASM:", error); }); function runTiger(code) { return evalTiger(code); } </script>
-
Execute Tiger code from JavaScript:
// Wait for WASM to load, then: const result = evalTiger('let x = 42; print x;'); console.log(result);
Common Issues:
- "evalTiger is not defined": WASM hasn't finished loading yet
- "Failed to fetch main.wasm": File not found - run build first
- CORS errors: Use a proper web server, don't open HTML file directly
Build Steps:
- Unix/Linux/macOS:
make build - Windows PowerShell:
.\build.ps1 build - Windows Command Prompt:
build.bat build
This generates:
main.wasm- The compiled Tiger interpreterwasm_exec.js- Go's WebAssembly runtime (copied from Go installation)
# Run a Tiger file
./tiger-cli run program.tg
# Start interactive REPL
./tiger-cli repl# Run a Tiger file
tiger-cli.exe run program.tg
# Start interactive REPL
tiger-cli.exe repl>>> let x = 10
>>> print x
10
>>> func hello() { print "Hello Tiger!"; }
>>> hello()
Hello Tiger!
>>> exit
/
โโโ go/ # Go source code
โ โโโ main_cli.go # CLI entry point
โ โโโ main_wasm.go # WASM entry point (compiles to main.wasm)
โ โโโ lexer/ # Lexical analysis
โ โโโ parser/ # Syntax analysis
โ โโโ ast/ # Abstract Syntax Tree
โ โโโ eval/ # Interpreter/evaluator
โโโ tiger_go.html # WASM demo page
โโโ build.ps1 # PowerShell build script
โโโ build.bat # Windows batch build script
โโโ Makefile # Unix/Linux/macOS build system
โโโ README.md
Unix/Linux/macOS:
make deps # Install dependencies
make test # Run tests
make build # Build everything
make serve # Start dev serverWindows PowerShell:
.\build.ps1 deps # Install dependencies
.\build.ps1 test # Run tests
.\build.ps1 build # Build everything
.\build.ps1 serve # Start dev serverWindows Command Prompt:
build.bat test # Run tests
build.bat build # Build everything
build.bat serve # Start dev server- Simplicity: Easy to learn Python-like syntax
- Familiarity: C-style blocks with
{}and; - Modern: Built-in constants, proper scoping
- Portable: Runs everywhere (CLI + Web)
- Extensible: Clean codebase for easy feature addition
Problem: "execution of scripts is disabled on this system"
# Solution: Enable script execution (run as Administrator)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserProblem: "go: command not found" or "Go is not installed"
- Install Go from golang.org/dl/
- Restart your terminal/PowerShell
- Verify with:
go version
Problem: "Could not find wasm_exec.js in Go installation"
- Your Go installation may be incomplete
- Try reinstalling Go
- Or manually copy
wasm_exec.jsfrom your Go installation'slib/wasm/ormisc/wasm/directory
Problem: "Failed to load Tiger WASM" in browser
- Make sure you built the project:
.\build.ps1 build(Windows) ormake build(Unix) - Start a proper web server, don't open HTML files directly
- Check browser console for specific error messages
Problem: WebAssembly not working
- Ensure both
main.wasmandwasm_exec.jsare present - Check that files are served from a web server (not
file://URLs) - Clear browser cache and try again
Problem: Build fails
- Ensure Go 1.18+ is installed:
go version - Run dependency installation:
go mod tidy - Check that you're in the correct directory with
go.modfile
If you're still having issues:
- Check that Go is properly installed and in PATH
- Try building a simple Go program to verify your Go installation
- Make sure you're running commands from the project root directory
- Check file permissions on Unix systems
Built with โค๏ธ using Go and WebAssembly