Input & Output¶
Ooga Booga programs communicate with the user through two built-in statements: SAY (output) and HEAR (input).
SAY — print output¶
SAY evaluates an expression and prints it to standard output, followed by a newline.
Output:
SAY accepts any expression, including function calls and arithmetic:
The compiler emits println!("{}", expr); for every SAY.
HEAR — read input¶
HEAR reads one line from standard input and stores it in a WORDS variable. The variable must be declared with OOGA before HEAR can assign to it.
HEAR always produces WORDS
HEAR always stores a WORDS (String) value. To treat input as a number, convert it with a built-in:
Generated Rust for HEAR name:
{
let mut __ooga_input = String::new();
std::io::stdin().read_line(&mut __ooga_input).expect("UGH! CAVE EAR BROKEN");
name = __ooga_input.trim().to_string();
}
No external dependencies are needed — HEAR uses Rust's standard library.
Full interactive example¶
OOF Number guessing game
OOGA secret: ROCK BE 7
OOGA guess: ROCK BE 0
OOGA raw: WORDS
OOGA won: GRUNT BE NAH
UGGA WHILE NOT won
SAY "Guess a number between 1 and 10:"
HEAR raw
guess GETS NUMBR(raw)
IFF guess IS secret
SAY "YES! CAVE BRAIN CORRECT! UGH UGH!"
won GETS YEAH
NOPE IFF guess SMALLR secret
SAY "Too small! Think bigger, cave creature."
NOPE
SAY "Too big! Think smaller, cave creature."
UGHA
UGHA