Maroon is a pirate-themed programming language that makes coding as adventurous as sailing the high seas! Written in Python, it features a unique syntax inspired by pirate parlance while maintaining functional programming capabilities.
while counter be less_than 3 bark counter
plunder each coin from treasure_chest bark coin
repeat 3 times bark "BOOM!"
choose x:
case 1: bark "one"
default: bark "unknown"
end choose
brace for impact:
bark "Dangerous waters"
if capsized, bark "Error!"
- List comprehension:
list of 1, 2, 3 where each times 2
- Filter:
coins where it greater_than 5
- Reduce:
reduce coins with result plus it
- Upper/lower case:
"hello" upper
- Split/join:
"hello world" split " "
dialect Caribbean:
"shout" be "bark"
"expedition" be "voyage"
end dialect
bark roll_dice sails with 20
bark random_float sails with
bark random_float sails with 10, 20
crew be list of 1, 2, 3, 4, 5
bark random_pick sails with crew
bark random_sample sails with crew, 3
bark normal_random sails with
# Math operations
x be 5
bark factorial sails with x
angle be 3.14159
bark sin sails with angle
bark cos sails with angle
bark tan sails with angle
bark exp sails with 2
bark log sails with 10
bark log sails with 8, 2
# Statistical operations
numbers be list of 2, 4, 6, 8, 10
bark mean sails with numbers
bark median sails with numbers
bark sum sails with numbers
# Gaming functions
bark flip_coin sails with
bark roll_multiple sails with 3, 6
bark roll_multiple sails with 2, 20
- Pirate-themed syntax that's both fun and functional
- Built-in type system with support for numbers, strings, booleans, and lists
- Function definitions using
voyage
keyword - Rich set of mathematical and logical operations
- Built-in debugging tools
- Scope management with variable stacking
- Exception handling with pirate-flavored error messages
treasure be 42
message be "Ahoy, world!"
plus
: Additionminus
: Subtractiontimes
: Multiplicationdivided_by
: Divisionmodulo
: Moduluspower
: Exponentiation
bark
: Print outputcount_booty
: Length functionplunder
: Maximum valueabandon
: Minimum valuedebug_chest
: Debug current scopesqrt
,abs
,round
: Mathematical operationsto_int
,to_float
,to_str
: Type conversion
voyage greet(name):
bark "Ahoy," name
end voyage
crew be list of "Jack", "Anne", "Mary"
add "Blackbeard" to crew
if gold be greater_than 100, then bark "Rich!" else bark "Poor!"
The interpreter provides detailed error messages through the PirateException
class, helping developers navigate through rough seas of debugging.
The interpreter is built with clean, modular Python code featuring:
- Regular expression parsing
- Robust type system
- Comprehensive operator support
- Modular function handling
- Clone the repository
- Run Maroon scripts with
.maroon
extension - Start writing your pirate-themed programs!
Example:
treasure be 42
bark "Me treasure chest holds" treasure "gold pieces!"
- Run the script with: python main.py yourfilename or python main.py for the shell
MIT License! Steal at yer own risk 💀🏴☠️
Join our crew! Contributions are welcome through pull requests.