Skip to main content
OCat is an explicitly typed language. Every variable declaration names the type of value it holds. There are three types you write directly in source code, and one internal type used by the runtime.

Value types

A sequence of characters enclosed in double quotes.Declaration keyword: stringLiteral pattern: "(?:[^\\"]|\\.)*" — any characters between double quotes, with backslash escape support.
string name = "Alice"
string empty = ""
string escaped = "line one\nline two"
Interpolation: Inside a string literal, you can embed the current value of a variable using ${varName}.
string user = "Bob"
string msg = "Welcome, ${user}!"
print(msg)
The interpolation is resolved at the time the variable is declared (or reassigned). The variable named inside ${...} must already exist in the current context; if it does not, the runtime raises an UndeclaredVariableError.
An integer or decimal numeric value.Declaration keyword: numberLiteral pattern: \d+(\.\d+)? — one or more digits, optionally followed by a . and more digits.
number count = 0
number pi = 3.14159
number negScore = 0
OCat does not currently support negative number literals. To represent a negative value, use 0 and reassign with set if needed, or encode the value as a string.
A boolean truth value.Declaration keyword: boolValid literals: true or false (lowercase only).
bool enabled = true
bool debug = false

Type reference table

TypeKeywordExample literalNotes
Stringstring"hello"Double-quoted; supports ${var} interpolation
Numbernumber42, 3.14Integer or decimal
Booleanbooltrue, falseLowercase only

The identifier type

OCat has a fourth type, identifier, which is used internally by the runtime. It is not a type you declare in source code — it appears when the parser encounters a bare variable name in a position that accepts a value, such as in print.
number score = 99
print(score)  // 'score' is resolved as an identifier at runtime
When print receives an identifier, the runtime looks up the variable’s actual value in the current context and outputs it. If the variable has not been declared, the runtime raises an UndeclaredVariableError.
You will only encounter the identifier type if you are reading runtime error messages or working with the OCat AST directly. It does not appear in source code.

Type usage in declarations

Types appear in three positions in OCat source:
1

Variable declaration

The type keyword opens the statement:
number age = 30
string city = "Paris"
bool active = true
2

Mutation with set

The type keyword is repeated after set (parsed, but enforcement is not yet active in the current runtime):
set number age = 31
set string city = "Lyon"
3

Constant declaration

The type keyword follows const (parsed, but immutability is not yet enforced in the current runtime):
const number MAX = 100
const string VERSION = "1.0.0"

Type enforcement

The parser enforces that the literal you provide matches the declared type. Declaring a number variable with a string literal, for example, is a parse error. There is no implicit conversion between types.
// Valid
number x = 10
string y = "10"

// Invalid — string literal for a number type
// number z = "10"

Variables

How to declare, mutate, and scope variables.

Syntax overview

Keywords, identifiers, and overall program structure.

Build docs developers (and LLMs) love