Cat ASCII Design Language
About
CADL (Cat ASCII Description Language) is a domain-specific programming language designed to describe cats using structured traits—such as mood, ears, body type, tail, and whiskers—and render those descriptions as ASCII art.
Unlike general-purpose languages that focus on numerical computation or data processing, CADL is purpose-built for visual description. Programs written in CADL define cat objects, assign and modify their traits, and control when and how those cats are drawn.
Motivation & Design Goals
The goal of CADL is to demonstrate how a full programming language implementation pipeline can be adapted to a playful, domain-specific application. While the language itself is intentionally creative and lightweight, the underlying system mirrors the structure of a real interpreted language.
CADL was desgined to:
- Demonstrate core language implementation concepts inlcuding a: lexer, parser, AST constructer, interpreter
- Explore how domain-specific abstractions simplify user intent
- Separate language semantics from rendering logic
- Provide immediate, visual feedback from program execution
How CADL Works
Internally, CADL follows the same execution pipline used by traditional interpreted programming languages:
- Lexing - Source code is tokenized into keywords, identifiers, literal, and operators.
- Parsing - Tokens are parsed according to the CADL grammar to produce an abstract syntax tree (AST).
- AST Construction - The hierarchical structure of the program is represented explicitly in node form.
- Interpretation - The interpreter travereses the AST, evaluates expressions, manages control flow, and updates the program state.
- ASCII Rendering - When a draw statement is encountered, the current state of a cat is passed to the renderer to generate ASCII output.
Symbol Table & Runtime Model
CADL uses a scoped symbol table to manage variables, functions, and cat objects at runtime. Cat objects are stored as dictionaries of traits, allowing them to be shared across scopes while still supporting local state within functions.
Function calls introduce new scopes, which are pushed onto the symbol table and popped upon return. This allows CADL to support parameter passing, local variables, and controlled side effects while still operating on shared cat data.
Example Program
The following example demonstrates a complete, valid CADL program. It defines a cat named Miso, assigns a mood and ear type, and then renders the cat as ASCII art. Running this program shows how a small set of declarative instructions is transformed into a visual representation through the CADL execution pipeline. Try running this example program yourself to see the ASCII representation of Miso!
cat Miso {
mood = "sleepy";
ears = "pointy";
}
draw Miso;
Where to Go Next
Want to explore more about CADL? Check out these other sections:
- Visit Editor to write and run your own CADL programs
- Explore Examples to see how traits, moods, and control flow interact
- Read the Documentation to learn the full grammar, available traits, and syntax for CADL
- View the source code on GitHub to see the full implementation