Skip to main content
OCat is a line-oriented language. A program is a sequence of statements, and each statement occupies its own logical position in the file. There is no statement terminator — the parser uses the keyword that opens each statement to determine where it begins.

Program structure

An OCat file is read top-to-bottom. Every statement must start with a recognized keyword: import, print, a type keyword (number, string, bool), set, func, const, or call. Anything else is a parse error.
// A complete OCat program
import "utils"

number count = 42
string greeting = "Hello, world!"
bool active = true

func greet() {
    print(greeting)
}

call greet()

Whitespace

Whitespace (spaces, tabs, newlines) is ignored by the parser. You may indent your code freely for readability. There are no significant-indentation rules.
func example() {
    number x = 1
    print(x)
}

Comments

OCat supports both line comments and block comments. Both are skipped by the lexer and have no effect on execution.
A line comment starts with // and continues to the end of the line.
// This is a line comment
number x = 10  // inline comment
A block comment is delimited by /* and */ and may span multiple lines.
/*
  This is a
  multi-line block comment
*/
string name = "Alice"

Keywords

The following words are reserved by the language and cannot be used as identifiers:
KeywordPurpose
printOutput a value to the console
importLoad another OCat file
numberDeclare a numeric variable
stringDeclare a string variable
boolDeclare a boolean variable
setMutate an existing variable
constMark a variable as immutable
funcDefine a function
callInvoke a function

Identifiers

An identifier is any name that is not a reserved keyword. Identifiers are used for variable names and function names. Pattern: /[a-zA-Z_]\w*/ An identifier must:
  • Start with a letter (az, AZ) or an underscore (_)
  • Contain only letters, digits (09), or underscores after the first character
// Valid identifiers
number count = 0
string _name = "Alice"
number value2 = 99

// Invalid — starts with a digit
// number 2value = 5
Identifiers are case-sensitive: count, Count, and COUNT are three different names.

Operators

OCat currently defines one operator:
OperatorMeaning
=Assignment

Delimiters

The following characters are used as structural delimiters:
DelimiterUsage
( )Argument lists for print, func, and call
{ }Function body
,Separator between parameters

Complete example

The following program demonstrates all major syntactic features together:
// Import a module
import "config"

/*
  Variable declarations
*/
number width = 800
number height = 600
string title = "My App"
bool debug = false

// A function that prints a summary
func printInfo() {
    print(title)
    print(width)
    print(height)
}

// Call the function
call printInfo()

// Mutate a variable
set number width = 1024

Variables

Learn how to declare and mutate variables.

Functions

Learn how to define and call functions.

Build docs developers (and LLMs) love