Continuing the discussion from Programming Language Jam:
I have finally, finally, FINALLY, FINALLY, FINALLY succeeded in making a programming language. (It doesn’t really have much to do with kittens)
It uses the file extension *.kitten
. The official repository can be found here.
You can use KittenScript by forking my template and then editing the main.kitten file.
Sooooo, here’s a little doc about it:
KittenScript doc
KittenScript Official Documentation
1 Variables
You can set variables by using this syntax:
let
variable of type
type be
value
variable: The name of the variable.
type: The type of the variable, see §1.2 for more info.
value: The value of the variable.
1.1 Constants
Constants are variables that cannot be changed. The constant syntax is similar to the variable syntax (§1):
const
variable of type
type be
value
variable: The name of the constant.
type: The type of the constant, see §1.2 for more info.
value: The value of the constant.
1.1.1 Constant-related Errors
When you try to change a constant using set
(§1.3), it will throw an error UNMODIFIABLE_LION
(sorry for the strange error names). See §3.1 for more info on this error.
1.2 Data types
In KittenScript, all variables are typed, meaning that they must have a specified data type. The list of data types are: int, float, and string. (Booleans will come in support later)
int: An integer, any whole number.
float: Any decimal or “floating-point”.
string: Any text of any length (sorry, spaces are not supported yet) or “strings”.
1.3 Changing variables
The following does not apply to constants.
You can change variables using set. The syntax is a little bit different (Note that you must still specify the type because variables can change types)
set
variable to
value with type
type
variable: The name of the variable.
value: The new value of the variable.
type: The new type of the variable, see §1.2.
1.4 Variable Expressions
In certain commands where expressions are supported, you can use variable expressions:
!var
variable
variable: The name of the variable.
This expression returns the value of the variable. See §4 for more info on this expression.
2 Console Operations
2.1 Printing
You can print text (strings) to the console using the print
command. Syntax:
print
text|expr
text|expr: The text to print to the console. Expressions supported (§4)
2.2 Clearing
You can clear the console using the clear
command:
clear
This command takes no parameters.
3 Errors
pass
4 Logic & Looping
4.1 If/Check-if/Otherwise
4.2 Looping
4.3 Conditions
4.4 exists
exists is a condition that checks if a variable exists. Syntax:
variable exists
Example:
if myvar exists
print existence
endif