စံကား

Docs

Zaka Docs

The full rules of the Zaka language, how the compiler and the VM work, and the ideas behind them.

These pages are the manual of Zaka (စံကား). Where Learn teaches the language one small example at a time, the manual states the rules in full: what each sentence means, what the compiler checks, what the VM does while a program runs, and the reasons behind each choice.

How the manual is laid out

ChapterForWhat it holds
The languageprogrammersthe exact rules of words, kinds, sentences, functions, pointers, ownership and lists
The compilerprogrammersthe zakac commands, the stages a program passes through, and its messages
The VMprogrammershow the Zaka VM runs a program, holds its data, and stops on a mistake
Conceptsthe curiousthe ideas behind the design, explained with scenarios
Inside the compilercontributorshow the code of the compiler is built, crate after crate

The reference pages at the end list the reserved words, the operator precedence and each error code.

From a sentence to a running program

Each chapter looks at one part of this road:

 program.zaka                    The language: what the sentences mean
      │
      ▼
 ┌─────────┐   words   ┌────────┐   tree   ┌──────────────────────────┐
 │  lexer  │ ────────▶ │ parser │ ───────▶ │ natural wording,         │
 └─────────┘           └────────┘          │ names and kinds          │
                                           └────────────┬─────────────┘
      The compiler: what it checks                      │ tree
                                                        ▼
 ┌────────────────┐   IR   ┌──────────────────┐  ┌──────────────┐
 │ borrow checker │ ◀───── │ fold constants   │◀─│ lower to IR  │
 └───────┬────────┘        └──────────────────┘  └──────────────┘
         │ IR
         ▼
 ┌────────────────┐   instructions   ┌──────────────┐
 │ code generator │ ───────────────▶ │   Zaka VM    │
 └────────────────┘                  └──────────────┘
                                       The VM: how it runs

A mistake the compiler finds stops the program before it runs, with a message and a code such as ZK0701. A mistake that slips past the checks stops the program while it runs, with a message that starts the program stopped:.

Reading the examples

The examples in the manual run, just as the ones in Learn do: press Run to see the output, or change the program and run it again. Each example is checked against the compiler, so the output shown is the output the program prints now.

စံကား

Expected output

မင်္ဂလာပါ

An example meant to fail states it, and names the code of the message it gives. A program that prints Western digits in its source still prints Burmese digits (၁၂၃).

Start with the language, or open the table of contents.

Chapters

  1. 01The language
    1. Source text and words
    2. Kinds and values
    3. Conversions
    4. Expressions
    5. Statements
    6. Names and scope
    7. Functions
    8. Pointers
    9. Ownership and borrowing
    10. Lists
    11. Natural wording
  2. 02The compiler
    1. Commands
    2. Stages
    3. Diagnostics
    4. Pointer checks
  3. 03The VM
    1. Running a program
    2. Checked and packed blocks
    3. When a program stops
    4. Instructions
  4. 04Concepts
    1. The case for sentences
    2. Finding words in Burmese
    3. Ownership, explained
    4. Checks in the VM and in native code
  5. 05Inside the compiler
    1. The lexer
    2. The parser
    3. Names and kinds
    4. The borrow checker
    5. IR and code