PEWPEW.EXE

PEWPEW.HLP — Language Reference

🔫 PewPew — Syntax Reference

Full language reference for PewPew (.pew files).


Table of Contents


Data Types

PewPew TypeMeaningExample
wholeInteger/floatwhole x = 10
dottedDecimal numberdotted pi = 3.14
wordsStringwords name = "PewPew"
vibeBooleanvibe flag = yes
bagArraybag nums = [1, 2, 3]
kitMap (key→value)kit p = ["hp": 100]

Variables

whole x = 10
dotted pi = 3.14
words name = "PewPew"
vibe isAwesome = yes
bag scores = [95, 87, 100]

Reassignment (no type keyword needed):

x = 20
name = "BroPew"

Operators

» Arithmetic

whole a = 10 + 5    // 15
whole b = 10 - 3    // 7
whole c = 4 * 3     // 12
whole d = 10 / 2    // 5
whole e = 10 % 3    // 1

» Comparison

x == y    // equal
x != y    // not equal
x > y     // greater than
x < y     // less than
x >= y    // greater than or equal
x <= y    // less than or equal

» Logical

x && y    // AND
x || y    // OR
!x        // NOT

» String Concatenation

words msg = "Hello " + "World"
yell("Score: " + 100)

Conditions

check (x > 5) {
    yell("x is big fr")
} nah {
    yell("x is smol")
}

Without else:

check (x == 10) {
    yell("x is ten!")
}

Else-if chains with nah check:

check (x % 15 == 0) {
    yell("PewPew")
} nah check (x % 3 == 0) {
    yell("Pew")
} nah check (x % 5 == 0) {
    yell("Pew")
} nah {
    yell(x)
}

Loops

» While-style loop

whole i = 0
loop (i < 5) {
    yell("i is: " + i)
    i = i + 1
}

» Repeat loop

repeat 5 times {
    yell("pew!")
}

whole n = 3
repeat n times {
    yell("brrrr")
}

» Foreach loop (over bags)

bag names = ["pew", "bro", "yo"]
foreach name in names {
    yell("Hey " + name)
}

Functions

do add(whole a, whole b) {
    gimme a + b
}

whole result = add(5, 10)
yell("Result: " + result)

Functions with no return:

do greet(words name) {
    yell("Yo " + name + "!")
}

greet("PewPew")

» Functions are first-class

A do can be passed around by its bare name (no quotes, no call parens) — it becomes a function value. Mainly used to hand route handlers to the http module:

do home(words method, words path, words body) { gimme "yo" }

http->route(8080, home)        // pass the do itself, not "home"

whatisthis(home) reports do (the type word — skins print their own spelling, e.g. func in the professional skin).


Bags (Arrays)

Bags are PewPew's version of arrays.

bag scores = [95, 87, 42, 100, 73]

yell(scores)               // print whole bag
yell(sizeof(scores))       // get size
yell(peek(scores, 0))      // access item at index
swap(scores, 2, 99)        // update item at index
toss(scores, 55)           // add item to end
whole last = yoink(scores) // remove and return last item

check (inside(scores, 100)) {
    yell("100 is in the bag fr!")
}

foreach score in scores {
    yell("Score: " + score)
}

Kits (Maps)

Kits are PewPew's key→value type (a map / object). Keys are strings.

kit player = ["name": "pew", "hp": 100, "level": 3]

yell(player)                  // print whole kit
yell(player["hp"])            // read by key -> 100
player["hp"] = 50             // update a key
player["xp"] = 999            // add a new key
yell(player["mana"])          // missing key -> nothing

kit empty = [:]               // empty kit (the colon distinguishes it from [])

yell(sizeof(player))          // number of keys
check (has(player, "hp")) {   // key exists?
    yell("got hp")
}

foreach k in player {         // iterate keys
    yell(k + " = " + player[k])
}

Kits and bags nest freely:

kit inventory = ["items": ["sword", "shield"], "gold": 42]
yell(inventory["items"])      // [sword, shield]

Built-in Functions

» Output

FunctionDescriptionExample
yell(x)Print x with newlineyell("Yo!")
YELL(x)Print x in UPPERCASEYELL("loud")

» Bag Operations

FunctionDescriptionExample
sizeof(bag)Returns length of bagsizeof(nums)
peek(bag, i)Returns item at index ipeek(nums, 0)
swap(bag, i, val)Updates item at index iswap(nums, 0, 99)
toss(bag, val)Adds item to end of bagtoss(nums, 42)
yoink(bag)Removes + returns last itemyoink(nums)
inside(bag, val)Returns yes/no if val existsinside(nums, 5)

» Kit Operations

FunctionDescriptionExample
kit[key]Read value by key (missing→nothing)player["hp"]
kit[key] = valSet / add a keyplayer["hp"] = 50
sizeof(kit)Number of keyssizeof(player)
has(kit, key)Returns yes/no if key existshas(player, "hp")
keys(kit)Returns a bag of the keyskeys(player)
foreach k in kitIterate over keysforeach k in player

» Utility

FunctionDescriptionExample
rolldice(n)Random number between 0 and nrolldice(100)
chill(n)Sleep for n secondschill(2)
whatisthis(x)Prints the type of xwhatisthis(42)
sweardown(cond)Assert — crashes if condition falsesweardown(x > 0)

Comments

// this is a single line comment
whole x = 10  // inline comment

Example Programs

» Hello World

yell("Yo World!")

» FizzBuzz

whole i = 1
loop (i <= 20) {
    check (i % 15 == 0) {
        yell("PewPew")
    } nah check (i % 3 == 0) {
        yell("Pew")
    } nah check (i % 5 == 0) {
        yell("Pew")
    } nah {
        yell(i)
    }
    i = i + 1
}

» Functions + Bags

do sum(bag nums) {
    whole total = 0
    foreach n in nums {
        total = total + n
    }
    gimme total
}

bag scores = [10, 20, 30, 40]
whole result = sum(scores)
yell("Total: " + result)

» Goofy Mode

whole x = rolldice(100)
yell("You rolled: " + x)
whatisthis(x)
YELL("this is loud fr")
sweardown(x >= 0)
chill(1)
yell("okay im back")