CatType — User Guide
Version: 1.0 - Last updated 19/7/25 (dd/mm/yy)
Contents
- Introduction
- What’s New in Version 1.0
- Quick Start Example
- Language Features
- Commands Reference
- Additional Notes
- Introduction
CatType is a beginner-friendly scripting language specially designed for my Roblox game Programming playground .CatType supports variables, expressions, input/output, control flow, and basic data types including numbers, strings, and booleans.
Key features include:
- Declaring variables of types: number, string, and bool
- Assigning and re-assigning values to variables
- Input and output commands for interaction
- Arithmetic and string operations
- Logical operators with short-circuit evaluation
- Conditional statements (if, else if, else)
- Block scopes with variable lifetime management
- Automatic cleanup (garbage collection) of unused variables
- Support for negative numbers and unary minus, including flipping booleans
Internally, CatType uses three main components:
- Lexer: breaks your code into tokens
- Parser: builds a structured syntax tree from tokens
- Interpreter: runs the code, manages variables, and cleans up
- What’s New in Version 1.0
Version 1.0 introduces:
- Release of CatType with features such as:
- Garbage collection
- Conditions and basic logic
- Input and output.
- And more.
- Quick Start Example
Try this example to get started with CatType:
bool flag = true
output(flag)
flag = input("Enter true or false:")
if (flag) {
output("Flag is true")
} else {
output("Flag is false")
}
number n = -5
output(-n + 10) // Outputs 15
output(-true) // Outputs false
output(-false) // Outputs true
- Language Features
Comments
- Use
//for single-line comments.
Example:// This is a comment
Variable Declaration
- Declare variables with:
= - Supported types:
number,string,bool - Variable names must be unique within the same block scope — no reusing names inside the same scope.
Example:
number age = 25
string name = "cat"
bool isReady = true
Assignment
- Assign new values to existing variables with:
= - The new value must match the variable’s type.
- You cannot assign to undeclared variables.
Example:
age = 30
name = "dog"
isReady = false
Output Statement
- Use
output(...)to print values to the console. Multiple comma-separated expressions can be outputted in one call.
Example:
output(name)
output("Hello, ", name)
output(age + 5, " years old")
Mathematical Operations
- Supported operators:
+,-,*,/,%(modulo) - Use parentheses
()to control order of operations. - Negative numbers and unary minus supported (e.g.,
-5,-x) - Unary minus on booleans flips their state (
-true→false,-false→true)
Examples:
output(x + 2 * 3)
output((x + 2) * 3)
output(10 % 3) // Outputs 1
output(-true) // Outputs false
Logical Operators
- Use
and,or,notfor boolean logic. andandorperform short-circuit evaluation.
Example:
if (x > 0 and not (x == 10 or x == 20)) {
output("x is positive and not 10 or 20")
}
Boolean Literals
- Use
trueandfalseas boolean values.
Example:
bool flag = true
String Literals and Concatenation
- Strings can be enclosed in double quotes
"text", single quotes'text', or backticks`text`. - Use
+to join strings or concatenate with numbers (automatic conversion).
Example:
output("cat" + 2) // Outputs "cat2"
Identifiers (Variable Names)
- Start with a letter or underscore
_. - Follow with letters, digits, or underscores.
Input Statement and Expressions
- Prompt input using
input("Prompt")or justinput(). - Can be used as a statement or within variable declarations/assignments.
- Input is converted into the variable’s type (number, string, bool).
- If conversion fails, an error with line info is shown.
Example:
number age = input("Enter your age:")
bool confirmed = input("true or false?")
Conditional Statements
- Syntax supports
if,elseif, andelseblocks. - Each block introduces a new variable scope.
- Conditions support comparison (
==,!=,>,<,>=,<=) and logical operators.
Example:
if (flag) {
output("Flag is true")
} elseif (age > 18) {
output("Adult user")
} else {
output("Minor user")
}
Variable Scope and Garbage Collection
- Each block (e.g., if, else) forms a new scope.
- Variables are only visible inside their scope and its child scopes.
- Variables no longer referenced in remaining code are automatically deleted after each statement.
- Variables declared inside a block are deleted when the block ends or become unreferenced.
- All variables and scopes are cleaned up when the program ends.
- Commands Reference
-
number =
Declare a numeric variable.
Example:number score = 100
Example with input:number age = input("Enter age:") -
string =
Declare a string variable.
Example:string pet = "cat"
Example with input:string pet = input("Enter pet:") -
bool =
Declare a boolean variable.
Example:bool flag = true
Example with input:bool flag = input("Enter true or false:") -
=
Assign a new value to an existing variable.
Example:score = 200 pet = "dog" flag = false score = input("Enter new score:") -
output(, , ...)
Print one or more values to the console.
Example:output(score, pet) output(x + 2, "cat" + 2) output(flag) -
input("")
Prompt the user and return input as a value.
Example:input("Enter anything:") number n = input("Enter a number:") bool flag = input("Enter true or false:") -
if () {...}
Conditional execution with new variable scope.
Example:if (flag) { output("Flag is true") } -
elseif () {...}
Additional conditional branch with new scope. -
else {...}
Final conditional branch with new scope. -
//
Add single-line comments to your code.
- Additional Notes
- Variable names cannot be redeclared in the same scope.
- Variables are resolved starting from the innermost scope outward.
- The
+operator works for both numbers (addition) and strings (concatenation). - Modulo
%gives the remainder of division. - Input conversion respects the variable type; errors show the specific line number.
- Logical operators are supported in all expressions and conditions.
- Boolean variables accept only
trueorfalsevalues. - Unused variables are cleaned up automatically after each statement.
- The entire environment is cleaned when the script finishes.
- Unary minus works on numbers and booleans, flipping boolean values when applied.
