Cantonese
Jump to navigation
Jump to search
- This is still a work in progress. It may be changed in the future.
Cantonese is an esolang using syntax based on the grammar of the Cantonese language
Syntax
Variable assignment
Variables are assigned with the following syntax:
var_name係value
The reserved variable `佢` is set by various functions in lieu of returns.
Control flow
Blocks use commas (,
) to separate statements rather than semicolons, and end in a semicolon. This means that blocks cannot be nested within each other since their ending punctuation would conflict. If required, just create another function
If block
如果expr,block
Else
否則,block
If statement (can appear in blocks)
如果expr就stmt
Else
否則就stmt
While block
只要expr,block
While statement (can appear in blocks)
只要expr就stmt
Functions
name:code
Literals
Literal | Value |
---|---|
堅 | true |
贋 | false |
Operators
Operator | Description |
---|---|
等於 | Equality |
唔等於 | Inequality |
大於 | Greater than |
小於 | Less than |
唔大於 | Not greater than (less than or equal) |
唔小於 | Not less than (greater than or equal) |
而且 | Logical AND |
或者 | Logical OR |
Operator | Description |
---|---|
唔 | Logical NOT |
Standard library
Function | Description |
---|---|
話「...」 | Println |
問「...」 | Prompt - stores user input into 佢 |
完 | End / Return |
Examples
Hello World
話「Hello World!」 完。
Cat Program
只要堅, 問; 話佢; 完。
Truth machine
問; 如果佢等於零, 話零; 否則只要堅, 話一; 完。
FizzBuzz
甲係一; 只要甲小於一百, 如果甲取模十五等於零就話「FizzBuzz」, 否則如果甲取模三等於零就話「Fizz」, 否則如果甲取模五等於零就話「Buzz」, 否則話甲, 甲係甲加一; 完。