Code Monkey home page Code Monkey logo

monty's Introduction

Monty

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. monty is an interpreter built specially for the said Monty Bytecodes files.

More About the Monty language

This is a language that contains specific instructions to manipulate data information (stacks or queues), where each instruction (called opcode) is sended per line. Files which contains Monty byte codes usually have the .m extension.

Example (file.m):

$ cat file.m
# Pushing element to the stack
push 0
push 1
push 2
# Printing all elements
pall
push 3
push 4
pop
# Rotating the stack to the bottom
rotr
pall
rotl
# Setting FIFO
queue
push 5
# Setting LIFO
stack
push 5
$

Technologies

  • Interpreter was written with C language
  • C files are compiled using gcc 4.8.4
  • C files are written according to the C90 standard
  • Tested on Ubuntu 20.04 LTS

Usage

To compile all files:

$ gcc -Wall -Werror -Wextra -pedantic *.c -o monty
$

The synopsis of the interpreter is the following:

$ ./monty [filename]
$

To run the interpreter:

$ ./monty file.m
2
1
0
0
3
2
1
$

Features

Opcodes

monty executes the following opcodes:

Opcode Description
push Pushes an element to the stack
pall Prints all the values on the 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
queue Sets the format of the data to a queue (FIFO)
stack Sets the format of the data to a stack (LIFO)
nop Doesn't do anything
add Adds the top two elements of the stack
sub Subtracts the top element of the stack from the second top element of the stack
mul Multiplies the second top element of the stack with the top element of the stack
div Divides the second top element of the stack by the top element of the stack
mod Computes the rest of the division of the second top element of the stack by the top element of the stack
pchar Prints the char at the top of the stack
pstr Prints the string starting at the top of the stack
rotl Rotates the stack to the top
rotr Rotates the stack to the bottom

Comments, indicated with #, are not executed by the interpreter.

When a nonextistent opcode is passed, the interpreter prints an error message and stops:

$ cat errorfile.m
push 1
pint
pcx
$ ./monty errorfile.m
1
L3: unknown instruction pcx

Return value

When there is no errors, monty returns 0. Otherwise, returns 1

Authors

Suara Ayomide
Chukwuoma Chizoba

monty's People

Contributors

raysonance avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.