Operators

Animal language uses a unique set of operators, many of which are named after animal sounds or behaviors.

Arithmetic Operators

The core arithmetic operations in Animal use animal-themed keywords:

Animal Operator

Traditional

Description

Example

meow

+

Addition

5 meow 38

woof

-

Subtraction

10 woof 46

moo

*

Multiplication

6 moo 742

drone

/

Division

20 drone 54

squeak

%

Modulo (remainder)

17 squeak 52

soar

^

Exponentiation

2 soar 38

These operators work with both integer and floating-point numbers:

float_result -> 10.5 meow 2.3   :: 12.8
integer_div -> 7 drone 2        :: 3.5 (division always returns float)
mixed -> 5 moo 1.5              :: 7.5

Unary Operators

Animal supports unary plus and minus:

positive -> +5   :: Same as 5
negative -> -10  :: Negation

String Operations

For string operations, Animal provides:

Operator

Description

Example

purr

Concatenation

"hello" purr " world""hello world"

String and numeric values can be concatenated with automatic conversion:

greeting -> "Age: " purr 25   :: "Age: 25"

Assignment Operators

Animal uses an arrow for assignment:

Operator

Description

->

Assigns the value on the right to the variable on the left

Example:

name -> "Luna"
age -> 5

:: Multiple assignments
a -> b -> c -> 10   :: All three variables get value 10

Compound assignment operators (like +=, -=) are not supported in the current version.

Comparison Operators

Animal uses standard comparison operators:

Operator

Description

Example

==

Equal to

5 == 5true

!=

Not equal to

5 != 3true

>

Greater than

10 > 5true

<

Less than

3 < 7true

>=

Greater than or equal to

5 >= 5true

<=

Less than or equal to

4 <= 6true

Comparison operators work with numbers and strings (lexicographical comparison):

:: Number comparison
temperature -> 28
is_hot -> temperature > 25   :: true

:: String comparison
name -> "Alice"
alphabetical -> name < "Bob"  :: true (A comes before B)

Logical Operators

For combining boolean expressions:

Operator

Description

Example

and

Logical AND

true and falsefalse

or

Logical OR

true or falsetrue

These can be combined for complex conditions:

temp -> 28
is_sunny -> true

go_swimming -> temp > 25 and is_sunny   :: true

Operator Precedence

Operators in Animal follow this precedence order (highest to lowest):

  1. Parentheses ()

  2. Unary operators +, -

  3. Exponentiation soar

  4. Multiplication, Division, Modulo moo, drone, squeak

  5. Addition, Subtraction meow, woof

  6. String concatenation purr

  7. Comparison operators >, <, >=, <=, ==, !=

  8. Logical operators and, or

  9. Assignment ->

You can use parentheses to override default precedence:

:: Default precedence (multiplication before addition)
result1 -> 2 meow 3 moo 4   :: 2 + (3 * 4) = 14

:: With parentheses
result2 -> (2 meow 3) moo 4  :: (2 + 3) * 4 = 20