Value types
string
string
A sequence of characters enclosed in double quotes.Declaration keyword: Interpolation: Inside a string literal, you can embed the current value of a variable using The interpolation is resolved at the time the variable is declared (or reassigned). The variable named inside
stringLiteral pattern: "(?:[^\\"]|\\.)*" — any characters between double quotes, with backslash escape support.${varName}.${...} must already exist in the current context; if it does not, the runtime raises an UndeclaredVariableError.number
number
An integer or decimal numeric value.Declaration keyword:
numberLiteral pattern: \d+(\.\d+)? — one or more digits, optionally followed by a . and more digits.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.bool
bool
A boolean truth value.Declaration keyword:
boolValid literals: true or false (lowercase only).Type reference table
| Type | Keyword | Example literal | Notes |
|---|---|---|---|
| String | string | "hello" | Double-quoted; supports ${var} interpolation |
| Number | number | 42, 3.14 | Integer or decimal |
| Boolean | bool | true, false | Lowercase 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.
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:Mutation with set
The type keyword is repeated after
set (parsed, but enforcement is not yet active in the current runtime):Type enforcement
The parser enforces that the literal you provide matches the declared type. Declaring anumber variable with a string literal, for example, is a parse error. There is no implicit conversion between types.
Variables
How to declare, mutate, and scope variables.
Syntax overview
Keywords, identifiers, and overall program structure.