This is an interpreter for the Monty programming language.
- Each Monty bytecode command is implemented as a separate function.
- The
main
function reads a Monty bytecode from a file and execute it accordingly.
Requirements | |
---|---|
Language | C |
OS | Ubuntu 20.04 LTS |
Compiler | gcc |
Style guidelines | Betty style |
Editors | vi, vim, emacs |
monty.h
: Header file containing function prototypes, data structures, and necessary includes.main_monty.c
: Main file with themain
function for Monty interpreter execution.run_instructions.c
: Executes Monty bytecode instructions based on parameters.push_op.c
: Implements the push commandpall_op.c
: Implements the pall commandpint_op.c
: Implements the pint commandpop_op.c
: Implements the pop commandnop_op.c
: Implements the nop commandswap_op.c
: Implements the swap commandadd_op.c
: Implements the add commandsub_op.c
: Implements the sub commandmod_op.c
: Implements the mod commanddiv_op.c
: Implements the div commandmul_op.c
: Implements the mul command
gcc -Wall -Werror -Wextra -pedantic *.c -o monty
Run the interpreter with a Monty bytecode file as an argument:
./monty bytecodes/file.m
~/holbertonschool-monty# cat bytecodes/00.m
push 1
push 2
push 3
pall
~/holbertonschool-monty# ./monty bytecodes/00.m
3
2
1
=========================================
Command | Description |
---|---|
push | Pushes an integer onto the stack. |
pall | Prints all the values on the stack, starting from the top. |
pint | Prints the value at the top of the stack. |
pop | Removes the top element of the stack. |
nop | Does nothing. |
swap | Swaps the top two elements of the stack. |
sub | subtracts top element of the stack from the second top element of the stack |
mul | multiplies second top element of the stack with top element of the stack |
mod | Adds the top two elements of the stack. |
div | computes remainder of division, second top by top stack element. |
- Chloe Correia
- Clement Mascret