Syntax - cyxigo/wi GitHub Wiki

Wi's syntax is C-like, meaning it feels a bit familiar to anyone who has used C, C++, C#, Java, or similar languages.

Comments

Wi comments are a bit different from usual C-like languages comments; usually, they are // for line comments and /* ... */ for block comments, but Wi uses // for integer division so it's reserved. Instead, Wi uses:

%% This is a single line comment

And block comments start with %* and end with *%:

%* This is an amazing block comment *%

Block comments nest, so this is a single comment:

%* outer %* inner *% still outer *%

A shebang line (#!) at the very start of a file is ignored as well.

Names

Names in Wi are ASCII only (a non-ASCII character outside of strings and comments is a compile error) and can include _, and numbers (but can't start with one):

_name
abc123
_1name
super_duper_ultra_long_name_in_snake_case
THIS_IS_ALL_CAPS
camelCaseIsBad
PascalCaseIsEvenWorse

Keywords (Reserved words)

Keywords (or reserved words) are words that are reserved for Wi and you can't use them as names! Wi has only 17 keywords:

if else null true false while
for break continue switch case default
return object new export import

Blocks

Code in Wi is organized into blocks. A block begins with { and ends with }

{
    a := 10;
    b := "b";
    %% and some other code...
}

Blocks are used in functions bodies, control flow statements (if, while, for), etc. Each block has its own variable scope.

Next: Values

⚠️ **GitHub.com Fallback** ⚠️