Cat Language Download, Sources, and Introduction

A prototype Cat interpreter, has just been released into the public domain, and is available for download with C# source code at An introduction to Cat is available at

Cat is a stack based functional language inspired by the Joy programming language Like Joy, Cat is a cross between Forth and the FP language.

Cat has no variables, no arguments, no constants, and no side-effects. Every Cat program takes a single stack as input, and returns a single stack as output. A Cat program is made up of a sequence of sub-programs. A sub-program may be either a user-defined or atomic (built-in) program. That's about it. It is very easy to implement, analyze, rewrite and optimize.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Bug in EBNF?

program ::= statement* ;
statement ::= def operation = operation* ;

I got the distinct impression one could write
1 2 + ;
and have it be a valid program. Conversely, if the EBNF is not in error, what is the entry point for a Cat program?

Good catch. My EBNF is not

Good catch. My EBNF is not accurate. In the interpreter you can write: "1 2 +" (with or without a trailing semicolon) and it will execute. The interpreter prints the top of the stack for you automatically.

A file would typically contain just a series of functions. So the entry point is just the name of whatever function you want. For example:

  def a = 1 2 +;
  def b = 3 4 +;

You can enter the program at either "a" or "b". Am I clearing things up, or just making it murkier?

Yep, clear

Yeah it's clear now. Reading all this LtU has made me pay maybe a little to much attention to (E)BNF grammars and my brain goes nuts when it can't parse something ;)

Another bug in EBNF

It doesn't mention square brackets.

Postscript anyone???

My first view of CAT (and Joy, to which some CAT related site refers) reminded me strongly of Postscript.

I like the definition of operators in Postscript a lot more:

/symbol { ...program... } def

No special syntax is required here. You could for example do the following to generate two synonymous program definitions

{ ...program... } dup /name1 exch def /name2 exch def

or have Postscript programs generate or modify Postscript programs.

My favorite however is the Postscript interpreter in Postscript:

{ currentfile token { exec } { exit } ifelse } loop