Toy programming language for me to implement to learn how to write an interpreter. Syntax and features generated by chatgpt.
- Variables and data types (integers and strings)
- Arithmetic operations (addition, subtraction, multiplication, division)
- Control flow (if/else statements, loops)
- Input/output (printing to the console, reading user input)
Variables and Data Types
# Data types
int age = 30
string name = "John"
string address = "14_carroll_street"
# Addition
x = 5 + 3
# Subtraction
y = 10 - 2
# Multiplication
z = 2 * 4
# Division
w = 20 / 4
# If statement
if x > 3 {
print("x is greater than 3")
} else {
print("x is less than or equal to 3")
}
# While loop
i = 0
while i < 10 {
print(i)
i = i + 1
}
# Printing to the console
print("Hello, world!")
# Reading user input
name = read()
print("Hello, " + name + "!")