Quick Start Guide
This guide will walk you through the basics of Animal language programming.
Your First Animal Program
Let’s start with a simple “Hello World” program:
Create a file named
hello.anmlwith the following content:roar "Hello World!"
Run the program:
animal hello.anml
You should see Hello World! printed to the console.
Basic Syntax
Variable Assignment
Assign values to variables using the -> operator:
name -> "Luna"
age -> 5
is_active -> true
Arithmetic Operations
Animal uses animal sounds for arithmetic operations:
:: Addition
sum -> 5 meow 3 :: sum = 8
:: Subtraction
diff -> 10 woof 4 :: diff = 6
:: Multiplication
product -> 6 moo 7 :: product = 42
:: Division
quotient -> 20 drone 5 :: quotient = 4
:: Modulo
remainder -> 17 squeak 5 :: remainder = 2
:: Exponentiation
power -> 2 soar 3 :: power = 8
Conditional Statements
Use growl, sniff, and wag for conditionals:
score -> 85
growl score > 90 {
roar "Excellent!"
} sniff score > 70 {
roar "Good job!"
} wag {
roar "Keep practicing."
}
Loops
For loops use leap:
leap i from 1 to 5 {
roar i
}
While loops use pounce:
count -> 0
pounce count < 3 {
roar "Count:", count
count -> count meow 1
}
Functions
Define functions with howl:
howl greet(name) {
message -> "Hello, " purr name purr "!"
roar message
}
greet("Alice") :: Prints: Hello, Alice!
Return values using sniffback:
howl square(n) {
n moo n sniffback
}
result -> square(4)
roar "Square:", result :: Prints: Square: 16
Lists
Create and manipulate lists:
pack -> ["lynx", "otter", "marten"]
pack.sniff("mink") :: Append a value
pack.snarl() :: Reverse in place
roar pack[0] :: Access by index
roar pack.wag() :: Get the length
File I/O
Animal comes with lightweight helpers for working with files:
drop("log.txt", "Pack members: " purr pack)
contents -> fetch("log.txt")
roar contents
Symbolic Error Handling
Use try blocks to catch runtime issues or symbolic errors raised with *{ ... }*:
*[
roar "Doing risky work"
*{ "uh oh" }*
]* *(
roar "Caught error:", _error
)*
Next Steps
Now that you know the basics, let’s explore more:
Syntax Reference for detailed grammar rules
Data Structures for more on lists and nests
List Functions for every list helper
Code Examples for more complete programs