Language: Cat++
Extension: .meow
Name for compiler: CATNIP
Features of Cat++
| Language Feature | Code Example |
|---|---|
| Integer Scalar Variables | meow x :3 meow y :3 meow z :3 meow avg :3 |
| One-dimensional Arrays of Integers | meow a[12] :3 a[0] = 3 :3 |
| Assignment Statements | meow x = 1 :3 x = 2 :3 |
| Arithmetic Operators | meow x = 1 + 1 :3 x = x + 1 :3 meow y = x - 1 :3 y = x * y :3 meow z = y / 2 :3 z = 1 + x - y * z / 4 :3 |
| Relational Operators | x != y :3 x < y :3 x > y :3 x <= y :3 x >= y :3 x == y :3 |
| While Loop | Traditional: hunt(x < 10) {x = x + 1 :3 } With break statement: hunt(x > 10) { purrhaps(x == 10000) { neuter :3 } } With continue statement: hunt(x > 10) { purrhaps(x == 10000) { keep_going :3 } } |
| If-then-else Statements | purrhaps(y < 3) { y = y + 1 :3 } else purrhaps(y > 3) { y = y - 1 :3 } else { x = x + 1 :3 } |
| Read and Write Statements | Print to terminal: scratch(x) :3 scratch(x + 2) :3 Read from terminal: litter(x) :3 |
| Comments | O_O this is a comment meow x = 2 :3 O_O this will be ignored |
| Functions | purr meow add(meow x, meow y) { meow z = x + z :3 knead z :3 } purr meow main() {meow a = add(x, y) :3 } |
| Symbol in Language | Token Name |
|---|---|
purr |
FUNCTION |
meow |
INTEGER |
:3 |
SEMICOLON |
neuter |
BREAK |
keep_going |
CONTINUE |
purrhaps |
IF |
O_O |
COMMENT |
scratch |
|
litter |
READ |
knead |
RETURN |
hunt |
WHILE |
= |
ASSIGN |
- |
SUB |
+ |
ADD |
* |
MULT |
/ |
DIV |
% |
MOD |
else |
ELSE |
, |
COMMA |
( |
LEFT_PARENTHESIS |
) |
RIGHT_PARENTHESIS |
[ |
LEFT_SQUARE_BRACKET |
] |
RIGHT_SQUARE_BRACKET |
{ |
LEFT_CURLY |
} |
RIGHT_CURLY |
| identifier | IDENTIFIER identifier |
| number | NUMBER number |
== |
EQUALS |
< |
LESSTHAN |
> |
GREATERTHAN |
<= |
LESSOREQUAL |
>= |
GREATOREQUAL |
hairball |
VOID |