zedocs
GitHub ↗
Language

Syntax overview

Learn Ze variables, conditions, loops, functions, lists, and error handling.

Ze uses Python-style indentation — blocks open with a colon : and an indented body. There are no braces or mandatory end keywords (though end / tapos / kataposan are accepted as no-ops for style).

Every example below is valid Ze. English, Tagalog, and Bisaya keywords can be mixed freely within the same file.


Variables

Declare and assign with a set keyword, then the variable name, =, and a value. After the first declaration you can reassign without a keyword.

EnglishTagalogBisaya
set / letitakda / lagyanibutang / butangi
set name = "Zyron"
itakda edad = 25
ibutang score = 100

# Shorthand reassignment -- no keyword needed
name = "Aiden"
score = score + 10

Values can be numbers, strings (single or double quotes), booleans, lists, or nothing / wala.

set pi    = 3.14159
set flag  = true
set empty = nothing
set nums  = [1, 2, 3]

Output

EnglishTagalog & Bisaya
show / print / displayipakita / iprint
show "Hello, World!"
ipakita "Kamusta!"
show "Score: " + word(score)
show ""                     # blank line

Input

Reads one line from the user and stores it as a string in the named variable.

EnglishTagalogBisaya
ask / inputtanongpangutana / pangutan-a
ask username
show "Welcome, " + username

tanong edad
ipakita "Edad mo: " + edad

pangutana ngalan
ipakita "Imo ngalan: " + ngalan

Comments

Comments run from the keyword to the end of the line and are ignored by the interpreter.

# universal hash comment
// C-style double-slash
tala   ito ay komento (Tagalog -- "note")
sulat  ito rin        (Tagalog alt -- "written note")
nota   komento        (Bisaya -- "note")

Conditionals

# -- English -----------------------------------------
if score is at least 75:
    show "Passed!"
elif score is at least 50:
    show "Almost."
else:
    show "Try again."

# -- Tagalog ------------------------------------------
kung score ay hindi bababa sa 75:
    ipakita "Pumasa!"
kung_hindi score ay hindi bababa sa 50:
    ipakita "Malapit na."
kundi:
    ipakita "Subukan ulit."

# -- Bisaya -------------------------------------------
kung score dili moubos sa 75:
    ipakita "Nakaagi!"
apan_kung score dili moubos sa 50:
    ipakita "Hapit na."
kung_dili:
    ipakita "Sulayi pag-usab."
TokenEnglishTagalogBisaya
IFifkungkung
ELIFelif / elseifkung_hindiapan_kung
ELSEelse / otherwisekundikung_dili / kundi_man

Loops

While

Runs the body as long as the condition is true.

# English
set i = 1
while i is at most 5:
    show i
    set i = i + 1

# Tagalog
itakda i = 1
habang i ay hindi lalampas sa 5:
    ipakita i
    itakda i = i + 1

# Bisaya
ibutang i = 1
samtang i dili molapas sa 5:
    ipakita i
    ibutang i = i + 1
WHILEwhilehabangsamtang

Repeat N Times

Runs the body a fixed number of times. times / beses / pilo is optional.

repeat 5 times:
    show "Hello!"

ulitin 3 beses:
    ipakita "Uli!"

balik-balik 2 pilo:
    ipakita "Balik!"
REPEATrepeatulitinbalik-balik / pabalikon

For-in

Iterates over every item in a list or range().

for fruit in fruits:
    show fruit

para item sa listahan:
    ipakita item

for i in range(1, 6):
    show i

For-range (from / to / step)

for i from 1 to 10 step 2:
    show i

para i gikan 1 hangtod 10 hakbang 2:
    ipakita i

Break and Continue

# English
break           # exit loop immediately
continue        # skip to next iteration

# Tagalog
tigil           # break
laktaw          # continue

# Bisaya
hunong          # break
priso           # continue

# Multi-word forms also work
stop loop           itigil ang pag-ulit      hunong sa pag-balik
skip this           laktawan ito             priso kini

Functions

Define with a define keyword. Call by name — the call prefix is optional.

FUNCdefine / function / actiongawin / gumawabuhaton / buhat
# English
define greet(name):
    show "Hello, " + name + "!"
    return "done"

call greet("Zyron")
greet("World")              # 'call' is optional

# Tagalog
gawin magdagdag(a, b):
    ibalik ang a + b

# Bisaya
buhaton doble(x):
    iuli ang x * 2
RETURNreturn / give backibalik / ibalik angiuli / iuli ang

Functions are closures — they capture variables from the surrounding scope.


Lists

set fruits = ["mansanas", "saging", "mangga"]

# Append
add "ubas" to fruits
idagdag "papaya" sa fruits      # Tagalog
idugang "atis" sa fruits        # Bisaya

# Remove
remove "saging" from fruits
alisin "saging" mula fruits     # Tagalog
kuhaa "saging" gikan fruits     # Bisaya

# Length
show count fruits
ipakita bilang fruits           # Tagalog
ipakita ihap fruits             # Bisaya

# Index access (zero-based)
show fruits[0]
fruits[1] = "lanzones"

# Iterate
for fruit in fruits:
    show fruit

Error Handling

Wrap risky code in a try block. If anything throws, the catch block runs with the error stored in the named variable.

# English
try:
    set result = 10 / 0
if it fails err:
    show "Error: " + word(err)

# Tagalog
subukan ito:
    itakda result = 10 / 0
kung mabigo err:
    ipakita "Kamalian: " + word(err)

# Bisaya
sulayi kini:
    ibutang result = 10 / 0
kung mapalpak err:
    ipakita "Sayop: " + word(err)
TRYtry / try thissubukan / subukan itosulayi / sulayi kini
CATCHcatch / if it failshulihin / kung mabigodakpa / kung mapalpak

Type Checks

Append a type-check phrase to any expression — it evaluates to true or false.

set x = 42
show x is a number          # true
show x is a word            # false
show x is empty             # false
show x is not empty         # true

# Tagalog
ipakita x ay isang numero
ipakita x ay isang Ze
ipakita x ay walang laman
ipakita x ay may laman

# Bisaya
ipakita x numero kini
ipakita x pulong kini
ipakita x walay sulod
ipakita x may sulod

Values and Types

ValueExampleType name
Number42, 3.14"number"
String"hello", 'hi'"word"
Booleantrue / totoo / tinuod"truth"
List[1, 2, 3]"list"
Nullnothing / wala"null"

Type-conversion functions: num(x), word(x), bool(x), list(x) — see builtins.md.

Help make these docs better.Edit this page on GitHub ↗

Find a guide or search the language reference.