Monty is an interpreter for Monty Bytecode files. Monty is a stack-based language that uses a stack to perform operations.
Monty is a simple stack-based programming language. The Monty interpreter reads Monty Bytecode files and executes the specified operations. It supports various stack manipulation and arithmetic operations.
- GCC (GNU Compiler Collection)
- Make
-
Clone the repository:
git clone https://github.com/Isaac-Ndirangu-Muturi-749/monty.git
-
Navigate to the project directory:
cd monty
-
Compile the Monty interpreter:
make
This will generate the monty
executable.
Run the Monty interpreter with a Monty Bytecode file:
./monty path/to/your/file.m
A Monty Bytecode file is a text file containing Monty commands. Each command is written on a new line.
push
: Pushes an element onto the stack.pop
: Removes the top element of the stack.pall
: Prints all the values on the stack.pint
: Prints the value at the top of the stack.swap
: Swaps the top two elements of the stack.add
: Adds the top two elements of the stack.nop
: No operation, does nothing.
push 5
push 10
add
pall
Output:
15
push 1
push 2
swap
pall
Output:
2
1
Follow me on Twitter 🐦, connect with me on LinkedIn 🔗, and check out my GitHub 🐙. You won't be disappointed!
👉 Twitter: https://twitter.com/NdiranguMuturi1
👉 LinkedIn: https://www.linkedin.com/in/isaac-muturi-3b6b2b237
👉 GitHub: https://github.com/Isaac-Ndirangu-Muturi-749