Monty 0.98 is a scripting language that is first compiled into Monty byte codes (Just like Python). It relies on a unique stack, with specific instructions to manipulate it. The goal of this project is to create an interpreter for Monty ByteCodes files to manipulate stacks.
File Name | Description |
---|---|
monty.h | Declaration of all functions to be used in the program, as well as libriaries and global variables |
main.c | Principal function |
operations.c | Contains the functions to be used |
errors_file.c | Contains all the posibles exits to the program |
executer.c | Contains the functions to open and read the file to execute |
opcodes.c | Contains the functions to call the functions to be execute |
helper_functions.c | Contains the functions like _strcmp and others, to be called in another file |
Makefile | Contains the compilation and clear functions |
generate_authors.sh | a file with all the names and corresponding emails of individual contributors |
bf | A directory that contains some files written in brainfuck |
bytecodes | Directory with the tests of the opcode |
Compilation
To compile the program this command has to be executed:
$ make all
This will create a compilation file, its name is montyfile
. You can run this file in your terminal with the next command:
$ ./montyfile <file>
Format
Format for user to write in "testfile.m":
opcode argument
Examples
$ cat opcodetestfile.m
push 1
push 2
push 3
pall
$ ./montyfile opcodetestfile.m
3
2
1
Opcode | Functionality |
---|---|
push | Add element to the 'top' of stack and 'end' of queue |
pop | Remove element from 'top' of stack and 'end' of queue |
pall | Print every member of the structure |
pint | Prints the member value at the top of stack |
swap | Swaps the order of the 1st and 2nd elements in stack |
add | Add top two member values |
sub | Subtract the top element from the 2nd top element |
div | Divide the 2nd element by the top element |
mul | Multiply the top two elements of the stack |
mod | The remainder when the 2nd element is divided by the top element |
comment | There is the ability to parse comments found in bytecode ->'#' |
nop | Opcode should do nothing |
If you find any bug, please, let us know.
All files have been written in the Betty Style.