/monty

Primary LanguageC

Monty Interpreter

Interpreter for Monty ByteCodes files.

Usage

monty file_name

Monty byte code files

Monty files rules:

  • One instruction per line.
  • Text after the command or its argument is ignored.
  • Any number of spaces before or after the command and its argument.
  • Blank lines allowed (empty or made of spaces).
  • A monty file can be or not ended in '.m'.

Example:

user$ cat -e bytecodes/000.m
push 0$
push 1$
push 2$
  push 3$
                   pall    $
          $
$
push 4$
    push 5    $
      push    6        $
pall$
user$

Available functions

File Description
PUSH Pushes an element to the stack
PALL Prints all the values on the stack, starting from the top of stack
PINT Prints the value at the top of the stack
POP Removes the top element of the stack
SWAP Swaps the top two elements of the stack
ADD Adds the top two elements of the stack

Installation

Download

git clone https://github.com/Naveduran/monty.git

Compilation

cd monty && gcc -Wall -Werror -Wextra -pedantic *.c

Installation

sudo mv monty /usr/local/bin

Now you can use the command monty since any directory in your linux machine.

Monty programming language

Easy to use and amazing performance! To know more about this programming language, click here.

This repository

The program was made under this general schema:

File Description
main.c Entry point.
initialize_data.c Inicialize an empty structure, as preparation to save the program information.
open_file.c Open the path of the file and saves the file's content.
_strtok.c Split a string lines, and then in words.
search_and_exec.c Compare the instruction give in each line with the available functions list.
f_push_and_pall.c f_pint_and_pop.c f_swap_and_add.c f_f_nop.c.c These files contain the named functions.
h_list.c Helpers to manage double linked list.
h_errors.c Helpers to manage error messages.
h_free_memory.c Helpers to manage memory.
h_others.c Other helpers, to compare strings.
monty.h Header file.

Environment

This project has been tested on Ubuntu 14.06.6 LTS

Authors