Language Reference › Canonical Structuresv0.1
Language Reference

Canonical Structures

The fixed internal structures of Pseudo. These never change - only the surface syntax is customizable via .pmap.

The default English patterns below are defined in default.pmap (ships with Pseudo, read-only). You can add more patterns via a custom pmap.

Complete default.pmap

default.pmap
[FUNC_DEF]
func {name:name}({args:any})
function {name:name}({args:any})
define {name:name}({args:any})
def {name:name}({args:any})
procedure {name:name}({args:any})
algorithm {name:name}({args:any})
recursive {name:name}({args:any})

[FOR_LOOP]
for {var:name} from {start:expr} to {end:expr} step {step:expr}
for {var:name} from {start:expr} to {end:expr}
loop {var:name} from {start:expr} to {end:expr}
repeat {var:name} from {start:expr} to {end:expr}

[FOR_EACH]
for each {item:name} in {collection:expr}
for every {item:name} in {collection:expr}
for {item:name} in {collection:expr}
loop through {collection:expr} as {item:name}

[WHILE_LOOP]
while {condition:expr}
keep going while {condition:expr}
as long as {condition:expr}

[UNTIL_LOOP]
until {condition:expr}
repeat until {condition:expr}

[IF]
@context TOP_LEVEL FUNCTION_BODY LOOP_BODY IF_BODY
if {condition:expr}
when {condition:expr}
check {condition:expr}
given {condition:expr}

[ELSE_IF]
else if {condition:expr}
elif {condition:expr}
otherwise when {condition:expr}

[ELSE]
else
otherwise
if not

[RETURN]
return {value:expr}
give back {value:expr}
output {value:expr}
return

[BREAK]
break
stop
exit loop

[CONTINUE]
continue
skip
next

[PRINT]
print {value:expr}
show {value:expr}
display {value:expr}
say {value:expr}

[INPUT]
$input
$input as {type:word}
$input({prompt:any})
$input({prompt:any}) as {type:word}

[ASSIGN]
@context TOP_LEVEL FUNCTION_BODY LOOP_BODY IF_BODY
{var:name} = {value:expr}
{var:name} := {value:expr}
{var:name} <- {value:expr}
set {var:name} to {value:expr}
let {var:name} be {value:expr}
store {value:expr} in {var:name}
{var:name} is {value:expr}

[TRY]
try
attempt

[CATCH]
catch {error:name}
except {error:name}
catch
on error {error:name}

[FINALLY]
finally
always
cleanup

[RAISE]
raise {error:any}
throw {error:any}

[SWAP]
swap {a:expr} and {b:expr}
exchange {a:expr} and {b:expr}

[GLOBAL]
global {var:name}

Context Flags

Some sections declare @context to resolve ambiguity. For example, x is 5:

ContextPatternResult
TOP_LEVEL{var:name} is {value:expr} (ASSIGN)x is 5 → assignment
CONDITION{a:expr} is {b:expr} (EQUALITY)if x is y → equality check

Range Behavior

pseudo
for i from 0 to 10    # → 0, 1, 2, ... 9 (10 is EXCLUSIVE)
for i from 10 to 0 step -1  # → 10, 9, 8, ... 1

Step defaults to 1. Backwards iteration requires an explicit negative step.

UNTIL Loop

pseudo
# "until" = loop WHILE condition is FALSE
repeat until x == 0
# equivalent to: while x != 0

Inline Blocks

Any block-starting line can have an inline body separated by a colon:

pseudo
if n == 10: print "ten"
for i from 0 to 3: print i
while x < 3: x = x + 1
if true: if true: print "nested"