An interpreter for Monty ByteCodes files.
monty runs on Ubuntu 14.04 LTS
All programs and functions will be compiled with gcc -Wall -Werror -Wextra -pedantic
version 4.8.4
All code is written in Betty style. Information about this style can be found at https://github.com/holbertonschool/Betty/wiki
Protoypes of all functions used are included in header file monty.h
Monty 0.98 is a scripting language that is first compiled into Monty byte codes. Monty relies on a unique stack, with specific instructions to manipulate it.
- Clone the repository:
$ git clone https://github.com/KRLoyd/monty.git
- Compile all files:
$ gcc -Wall -Werror -Wextra -pedantic *.c -o monty
To run a file containing Monty byte codes:
3. Run the executable: $ ./monty <file>
push
- Usage:
push <int>
- Pushes an element to the stack
- Usage:
pall
: prints all the values on the stack, starting from the top.pint
: prints the value at the top of the stackpop
: removes the top element of the stackswap
: swaps the two top elements of the stackadd
: adds the top two elements of the stacknop
: doesn't do anything (ADVANCED)sub
: subtracts the top element of the stack from the second top element of the stackdiv
: divides the second top element of the stack by the top element of the stackmul
: multiplies the second top element of the stack with the top element fo the stackmod
: computes the rest of the division of the second top element of the stack by the top element of the stack
Header file with prototypes for all functions and structs used in the interpreter.
main_monty.c
: themain_monty
function from which all other files' execution originates.check_funcs.c
: includes:check_args
: function to check if arguments are passedcheck_push_val
: function to assess ifpush
argument is an integer
free_func.c
: includes:free_everything
: function to call all free functionsfree_pointers
: function to free double pointersfree_stack
: function to free stack
helper_funcs.c
: includes:convert_push_arg
: converts string to integermake_struct
: mallocs space for global structstack_len
: finds the number of nodes in a stackfind_func
: searches for the op_code or prints message and return error
parsers.c
: includes:parse
: tokenizes buffer from getline into arguments for assessmentparse_check
: checks that buff is not NULL and mallocs space for tok_args
op_math.c
: includes:op_add
: setting first node's value to the sum of the first two nodes' valuesop_sub
: sets first node's value to the remainder of subtracting the second node and it is removedop_mul
: multiply first and second node's values and store in the first nodeop_div
: divides second node's value by the first and stores in first nodeop_mod
: divides second nodes's value by first and remainder is stored in first node
op_other.c
: includes:op_pall
: prints alln
values on stackop_pint
: printn
value at the top of the stackop_nop
: does nothing!
op_stack_manipulation.c
: includes:op_push
: pushes a new node withn
value to the stackop_pop
: removes/frees value at top of stackop_swap
: swaps the first twon
values in the stack with one another
Currently, monty does not have comment handling capability.
There are no known bugs at this time. If a bug is encountered, please contact one of the authors, listed below.
Public Domain, no copywrite protection