A programming language for Singaporeans, by not a Singaporean yet. Can one lah!
- Overview
- Documentation
- Features
- Installation
- Usage
- Language Examples
- CLI Options
- Project Structure
- Architecture
- Testing
- Contributing
- Support
- Star History
- License
Lahlang is a fun, expressive programming language inspired by Singlish and Singaporean culture. Itβs designed for learning, experimentation, and joy, with syntax and keywords that reflect local slang and humor.
For a complete guide on how to use Lahlang, check out our extensive documentation:
- Installation Guide: Node.js/pnpm prerequisites and global CLI installation.
- VS Code Extension: How to get syntax highlighting.
- Getting Started: Your first
.lahfile and "Hello World". - Variables and Types: Data handling with Singlish types.
- Control Flow: Logic with
confirm or notandwhich one lah. - Loops: Iteration with
keep going lahandevery one also. - Functions: Defining and calling reusable blocks.
- Error Handling: Wholesome and Spicy πΆοΈ tiers.
- CLI Reference: Commands, debugging, and meta keywords.
- Examples Walkthrough: Deep dive into the
examples/folder.
- Singlish Syntax: Keywords like
eh listen lah,ok lah bye,oi,confirm or not,keep going lah, etc. - Interactive REPL: Run
lahlangwith no arguments to enter the REPL β type Singlish code line by line with multi-line support. - VS Code Support: Get syntax highlighting with the Lahlang VS Code Extension.
- Variables & Constants:
eh got,confirm got - Control Flow:
confirm or not(if),or maybe(else if),abuden(else),keep going lah(while),one by one lah(for),every one also(foreach),hantam lah...until(do-while) - Functions:
steady lah do this,here take,eh do this,one time only,jio(casual call) - Error Handling:
see how lah,aiyoh kena,confirm do,jialat throw,paiseh warn,hong gan lah,chao cb assert,act blur(silent try) - Types:
words(string),nombor(number),can cannot(boolean),whole list(array),all the things(object) - Singlish Expressions:
kaypoh(typeof),gostan(reverse),swee(pretty print),agak agak(round),makan(pop),tabao(clone),chope(freeze),sabo(delete),die die must(assert),sian/lepak(sleep) - Built-in Methods: String methods (
.upper(),.lower(),.trim(),.split(), etc.), array methods (.push(),.pop(),.map(),.filter(), etc.), object methods (.keys(),.values(),.entries()), and global helpers (panjang,to_nombor,to_words, math functions) - String Escapes:
\n,\t,\r,\\,\"inside double-quoted strings - Operators:
same same(==),not same(!=),and also(&&),or can(||),add some more(+=),minus a bit(-=) - Comments:
// shiok:(single-line),wahlau start ... wahlau end(multi-line) - Meta:
chiong bring in(import),share out(export),eh check this(debug/inspect) - Spicy Error Types:
JialatError,BoJioError,SiaoError,TokKokError,TanKuKuError,SuayError,WahLauError,GoneCase,CbError,LanJiaoError,CcbError
Install globally using pnpm:
pnpm i -g lahlangRun a .lah file:
lahlang myfile.lahOr start the interactive REPL:
lahlanglah> oi "Hello from REPL!"
Hello from REPL!
lah> eh got x = 42
lah> oi x + 8
50
Type Singlish code directly β no need for eh listen lah / ok lah bye wrappers. Multi-line blocks (with {}) are supported. Press Ctrl+C to exit.
To close REPL with a keyword, type bye lah on its own line.
eh listen lah
oi "Hello World";
ok lah bye
eh listen lah
one by one lah (i from 1 to 15) {
confirm or not (i % 15 same same 0) {
oi "FizzBuzz";
} or maybe (i % 3 same same 0) {
oi "Fizz";
} or maybe (i % 5 same same 0) {
oi "Buzz";
} abuden {
oi i;
}
}
ok lah bye
eh listen lah
eh got my_list = [1, 2, "shiok", can];
oi my_list;
every one also (item in my_list) {
oi item;
}
eh got my_bag = {
food: "Chicken Rice",
price: 4.5,
tasty: can
};
oi my_bag;
ok lah bye
eh listen lah
steady lah do this makeCounter(start) {
eh got count = start;
steady lah do this increment() {
eh change count = count + 1;
here take count;
}
here take increment;
}
eh got my_counter = makeCounter(10);
oi my_counter();
ok lah bye
eh listen lah
// typeof
oi kaypoh "hello"; // "words"
oi kaypoh 42; // "nombor"
// reverse
oi gostan "lahlang"; // "gnalhal"
oi gostan [1, 2, 3]; // [3, 2, 1]
// round
oi agak agak 3.7; // 4
// pretty print
eh got obj = { name: "Ah Beng", age: 25 };
swee obj;
// clone and freeze
eh got copy = tabao obj;
chope obj;
// silent error handling
act blur {
jialat throw "this error is swallowed";
}
// assert
die die must (1 + 1 same same 2);
ok lah bye
eh listen lah
eh got i = 0;
hantam lah {
oi i;
eh change i = i + 1;
} until (i less than 5)
ok lah bye
eh listen lah
// String methods
eh got s = "hello world";
oi s.upper(); // "HELLO WORLD"
oi s.split(" "); // ["hello", "world"]
oi panjang(s); // 11
// Array methods
eh got arr = [3, 1, 2];
oi arr.sort(); // [1, 2, 3]
oi arr.map(steady lah do this(x) { here take x * 2; });
// Type conversion
oi to_nombor("42"); // 42
oi to_words(100); // "100"
ok lah bye
lahlang <file.lah>: Run a Lahlang program.lahlang: Start the interactive REPL.- Only
.lahfiles are accepted. - Errors are reported in Singlish style, e.g.
[TOK KOK],[RUNTIME ERROR],[FATAL],[ALAMAK].
lahlang/
βββ src/ # Source code (lexer, parser, interpreter, CLI)
βββ examples/ # Example .lah programs
βββ tests/ # Unit and integration tests
βββ package.json # Project metadata and scripts
βββ tsconfig.json # TypeScript config
βββ vitest.config.ts # Test config
- Lexer: Tokenizes source code using Singlish keywords.
- Parser: Builds AST from tokens, supports all language features.
- Interpreter: Executes AST, manages environment, handles errors.
- CLI: Entry point for running
.lahfiles, handles file I/O and error reporting.
Run all tests with:
pnpm test- Uses Vitest for unit and integration tests.
- Test coverage includes lexer, parser, interpreter, error handling, and full language features.
Contributions are welcome! Please open issues or pull requests for:
- Bug fixes
- Feature requests
- Documentation improvements
- New examples
If Lahlang helps you or made you smile, you can support the project here:
- GitHub Sponsors: https://github.com/sponsors/suryanshkushwaha
- Buy Me a Coffee: https://buymeacoffee.com/suryanshkushwaha
MIT License