TezzNative Language Guide

v1.0.0 syntax and semantics

Language fundamentals

This page documents the syntax most developers use daily in TezzNative v1.0.0.

Types and Variables

import "std"

fn main() -> int:
  age:int = 25
  score:float = 99.5
  name:str = "Rohit"
  ok:int = 1

  let MAX_USERS:int = 1024
  say(name)
  say(age + 1)
  ret 0

Operators

Arithmetic: + - * / %
Compare:    == != < <= > >=
Logical:    && ||
Assign:     = += -= *= /= %=
Cast:       value as int / float / str pointer types

Example:
  if (a > b) && (a != 0):
    say "a is larger"

if / else, while, for, switch

if x > 10:
  say "large"
else if x > 0:
  say "small"
else:
  say "zero-or-negative"

while i < 5:
  say i
  i = i + 1

for j:int = 0; j < 10; j = j + 1:
  if j == 3:
    continue
  if j == 8:
    break
  say j

switch code:
case 200:
  say "ok"
case 404:
  say "not found"
default:
  say "other"

Functions, Structs, Modules

struct User:
  id:int
  active:int

fn add(a:int, b:int) -> int:
  ret a + b

fn main() -> int:
  u:User
  u.id = 7
  u.active = 1
  say(add(2, 3))
  ret 0

# Module usage:
import "std"
import "net"
say(net.http_port())

Pointers and unsafe

fn main() -> int:
  p:*char = malloc(16)
  if p == 0:
    ret 1
  unsafe:
    p[0] = 65 as char
    p[1] = 0 as char
  say(p as str)
  free(p)
  ret 0

Input + Output

fn main() -> int:
  a:int = input("A = ") as int
  b:int = input("B = ") as int
  say(a + b)
  ret 0

# Legacy compatibility also accepted:
# input("A = ", INPUT_INT)

Build and Validate

tezz doctor
tezz run src/main.tn
tezz build src/main.tn --platform linux
tezz build src/main.tn --platform windows
tezz test --smoke