01The language
Source text and words
How the compiler reads a file - encoding, sentences, spaces, comments, names, literals and reserved words.
Before the compiler asks what a program means, it cuts the file into words. Burmese is written without spaces, and the compiler has no word list, so a few plain rules decide where one word ends and the next begins. This page states those rules, from the the file itself up to the literals.
Source files
A Zaka program is a text file in UTF-8, saved with the extension .zaka. The compiler
first puts the text into one standard form:
- a leading
U+FEFFmark is dropped; CR LFand a loneCReach count as one line break;- the text is normalized to Unicode NFC, and the signs of a Burmese vanna are put in
one fixed order. The asat
်comes before the dot below့, as inနှင့်andသည့်.
The last step is the reason two spellings that look the same lex the same. A name or a reserved word written with its signs in another order still matches.
Sentences and the full stop
A program is a list of statements. Each statement is a sentence that ends with the
Burmese full stop ။. A line break does not end a statement, so one statement can
cover several lines and several statements can share a line.
Expected output
တစ်
နှစ်
၃
A missing ။ is reported as ZK0201 ("expected ။"). The list separator is ၊, which
is used between arguments, parameters and the cells of a list literal; a comma is not a
Zaka character.
Expected error
error[ZK0101]: invalid character in ","
= help: lists are separated with "၊", not ","
Words and spaces
The lexer works in three steps: it cuts the text into vannas (Burmese letter clusters), digits and single other characters; it joins the pieces that touch into words; and it classifies each word. These rules decide the cuts.
- White space separates words. The seven white space characters are TAB, LINE FEED,
VERTICAL TAB, FORM FEED, CARRIAGE RETURN, SPACE and ZERO WIDTH SPACE (
U+200B, which the macOS Burmese input source enters forShift+Space). One of them or a run of them count the same, and none is a token. - Some characters are words on their own.
၊,။,၏and each ASCII punctuation character except_are cut out even with no space beside them, such as( ) + - * / % ; , .and the quote marks. That is the reason၁+၂andပြသပါ။need no spaces. A pair that forms one sign (<= >= == != << >> && ||) is joined when its two characters touch. - A name runs to the next white space or lone character. The name can mix scripts
(
အမှတ်_၁,age) as long as nothing separates the pieces. - A word made of reserved words alone is split.
ထက်ကြီးသည်isထက်ကြီးသည်, andတန်ဖိုးကိုisတန်ဖိုးကို. The split picks the fewest pieces, and a word that holds just particles (such asကိုကို) is not split. - A word with a vanna that is not reserved is a name.
အသက်ကိုis one name, notအသက်thenကို. - The words of a reserved phrase such as
စားသော စားလဒ်orအောက်ပါတို့ကို လုပ်ဆောင်ပါcan have white space between the words or none; both read the same.
အသက် ကို ပြသပါ။ အသက် | ကို | ပြသပါ | ။ a name, two reserved words, a stop
အသက်ကို ပြသပါ။ အသက်ကို | ပြသပါ | ။ one name: no reserved split
ထက်ကြီးသည် ထက် | ကြီး | သည် reserved words alone: split
၁+၂ ၁ | + | ၂ signs are cut out
The fourth rule gives the one habit a Zaka writer needs: put a space between a name and the particle after it. When the joined word is not a known name, the compiler guesses that a space is missing and reports it:
Expected error
error[ZK0206]: "ပြသပါ" needs "ကို|ဟု" after operand 1, found no particle
help: write "အသက် ကို" with a space: a name joined to a particle is read as one word
A polite ending (သည်, ပါ, ပါသည်) written attached to a comparison verb, to
မှန်, မမှန် or မဟုတ် is part of that word; the lexer keeps it as a note on the
token. With a space, သည် is the subject marker instead. Natural wording
tells which ending reads well where.
Comments
A comment starts at //, at ///, or at the word မှတ်ချက် ("note"), and runs to the
end of the line. A comment is not a token. There is no comment that spans lines. A marker
inside a string or character literal is just text, and မှတ်ချက် starts a comment just
when it is a word on its own.
Expected output
http://zaka.example // not a comment
၁
Names
A name starts with a letter of a script, an emoji, _, or a Burmese character that is
not a digit. After the first character it can also hold digits (Burmese or Western).
Upper and lower case differ: Age and age are two names. A name cannot be just a
reserved word or a row of reserved words.
Expected output
၁၅
Raw names
A name written between backticks is a raw name. It can hold reserved words, spaces and signs. It cannot hold a backtick or a line break, and it cannot be blank.
Expected output
၁၆
A raw name with no closing backtick on its line is ZK0108, and two backticks in a row are ZK0109. Writing a plain reserved word as a name gives ZK0201 ("expected a name").
Expected error
Numbers
A number literal is a run of digits. The digits are Burmese (၀ to ၉) or Western
(0 to 9), but one number holds one script alone (ZK0103). A literal has up to three
parts in a fixed order:
| Part | Written | Notes |
|---|---|---|
| base | အခြေ ၁၆ ဖြင့် | optional; a base from 2 to 36, itself written in base 10 (ZK0218) |
| kind | လက္ခဏာမဲ့ ၈ ဘစ် ကိန်းပြည့် | optional; see Kinds and values (ZK0216, ZK0217) |
| digits | ၂၅၅, FF, ၃.၁၄, 1.5e3 | in base 10, a fraction . and an exponent are allowed |
- Digits above 9 are the letters
AtoZ, in either case. A digit not below the base is ZK0219. - A fraction needs digits on both sides of the point:
၁.၅, not၁.or.၅. - An exponent (
eorE, an optional sign, digits) needs Western digits:1.5e3works,၂.၅e3is ZK0102. A fraction or an exponent makes a decimal number, and a base prefix cannot go with one. - There is no negative literal.
-၅is the minus sign applied to၅, and so isအနုတ် ၅. The compiler works it out before the program runs. - A literal with no kind prefix is flexible: it takes the kind that its place wants (see Expressions). A literal that does not fit its kind is an error: ZK0220 when the kind is written in front of it, and ZK0406 when the place gave the kind.
Expected output
၁၂၃
၁၂၃
၁၀
၂၅၅
၂၅၅
၃.၁၄
၁၅၀၀.၀
-၅
Numbers print with Burmese digits, whatever digits the program used.
Expected error
Expected error
error[ZK0219]: "၂" is not a digit in base 2
Characters and strings
A character literal holds one Unicode scalar value in single quotes: 'က', 'A',
'🔥'. A Burmese vanna with signs, such as ကို, is several scalar values, so
'ကို' is ZK0107. A string literal is text in double quotes. It has no kind of its
own: it can be printed and nothing else (ZK0223). A literal must close on the line where
it opens (ZK0104 for a string, ZK0105 for a character).
Escapes work in both. The backslash forms are for readers who know C, and the brace
forms are the Burmese spelling. A brace is reserved inside a literal, so a plain { or
} is doubled.
| Escape | Means |
|---|---|
{နောက်တစ်ကြောင်း} or \n | line feed |
\r, \t, \0 | carriage return, tab, the null character |
\\, \', \" | a backslash, a single quote, a double quote |
{{, }} | a brace {, a brace } |
\uHHHH or \uHHHHHHHH | the code point with 4 or 8 hex digits |
{ယူနီကုဒ် HHHH} or {ယူနီကုဒ် HHHHHHHH} | the same, in Burmese |
A code point must be a scalar value: a surrogate, a value above 10FFFF and a digit
count other than 4 or 8 are errors. Another {...} is ZK0106; braces are kept free so
that a later version can give them a use.
Expected output
တစ်
နှစ်
a\b
{ }
က
က
xAy
Expected error
Expected error
error[ZK0107]: a character literal must hold one character, found 2
Expected error
Reserved words
The words that Zaka gives a meaning to cannot be used as names. Reserved
words lists each of them. A reserved word that ends in
the written မည် also takes the spoken မယ်: ပြန်ပေးမည် and ပြန်ပေးမယ် are the
same word. To use a reserved word as a name, put it between backticks.
Each diagnostic of this page has a code from ZK0101 to ZK0109. Error
messages lists them with the others.