- FIFO: First In, First Out
- The first element to be inserted into the data structure is accessed first when accessing the data structure and so on.
- LIFO: Last In, First Out
- The last element to be inserted into the data structure is accessed first when accessing the data structure
A linear data structure implementing a LIFO approach where both insertion and deletion take place from just one end, that is, from the top.
Can be:
- static - array is used, memory statically allocated meaning size of the stack should be known beforehand
- dynamic - linked list is used, memory is dynamically allocated at run time.
A data structure implementing a FIFO approach
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.
Files containing Monty byte codes usually have the .m
extension. Most of the industry uses this standard but it is not required by the specification of the language.
- There is not more than one instruction per line.
- There can be any number of spaces before or after the opcode and its argument.
- Any additional text after the opcode or its required argument is not taken into account
- Monty byte code files can contain blank lines (empty or made of spaces only)
Example file:
cat bytecodes/000.m
push 0
push 1
push 2
push 3
pall
push 4
push 5
push 6
pall
Compilation:
gcc -Wall -Werror -Wextra -pedantic -std=c89 *.c -o monty
Usage:
./monty file
file
is the path to the file containing Monty byte code.
The monty program runs the bytecodes line by line and stop if either:
- it executed properly every line of the file
- it finds an error in the file
- an error occured