Source files
Cuarzo source uses the .cz extension and must be valid UTF-8 without NUL
bytes. Statements are normally separated by newlines. Blocks use explicit
keywords rather than braces.
// A line comment
/* A block
comment */The lexical rules are byte-oriented and ASCII outside of string and comment contents:
- identifiers match
[A-Za-z_][A-Za-z0-9_]*; - numeric literals use ASCII digits; a float needs digits on both sides of the
dot, such as
3.14; - whitespace is space or tab, and a newline is LF, CRLF, or a bare CR;
- strings and comments may contain any UTF-8 text, which is kept byte for byte;
- diagnostics have the form
[ERROR E0042] file:line:col: message, with a code that Diagnostics explains, a one-based line and a one-based UTF-8 byte column. Errors are reported up to ten at a time: after a syntax error, the compiler reads on from the next statement, and reports every syntax error of every file before it stops; without one, each statement with an error is left out while the rest are checked.
Integer literals keep their decimal meaning, so 007 is the integer 7.
A line break inside parentheses or brackets does not end a statement, so long calls, conditions, and array literals can span several lines:
str[] words = [
"one",
"two",
]
print(join(
words,
", "
))Code is laid out with four spaces for each block, one space around
operators and after commas, and none inside brackets or before a call's
parenthesis. cuarzo fmt lays files out that way in place, keeping their
line breaks and comments; cuarzo fmt --check lists the files it would
change, for CI.