{"id":19827105,"url":"https://github.com/mohamed-mostafaaa/monty","last_synced_at":"2025-07-07T15:36:18.886Z","repository":{"id":207675330,"uuid":"718592400","full_name":"Mohamed-Mostafaaa/monty","owner":"Mohamed-Mostafaaa","description":"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.","archived":false,"fork":false,"pushed_at":"2023-11-17T11:43:40.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T20:56:15.116Z","etag":null,"topics":["brainfuck","bytecode","c","data-structures","monty","queue","stack"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mohamed-Mostafaaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-14T12:06:04.000Z","updated_at":"2023-11-29T10:48:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d1debc5-5e6b-42be-9ca3-681a4b488bf6","html_url":"https://github.com/Mohamed-Mostafaaa/monty","commit_stats":null,"previous_names":["mohamed-mostafaaa/monty"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mohamed-Mostafaaa/monty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohamed-Mostafaaa%2Fmonty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohamed-Mostafaaa%2Fmonty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohamed-Mostafaaa%2Fmonty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohamed-Mostafaaa%2Fmonty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mohamed-Mostafaaa","download_url":"https://codeload.github.com/Mohamed-Mostafaaa/monty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohamed-Mostafaaa%2Fmonty/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264103697,"owners_count":23557983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brainfuck","bytecode","c","data-structures","monty","queue","stack"],"created_at":"2024-11-12T11:12:29.516Z","updated_at":"2025-07-07T15:36:18.848Z","avatar_url":"https://github.com/Mohamed-Mostafaaa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"![img](https://assets.imaginablefutures.com/media/images/ALX_Logo.max-200x150.png)\n  \u003e monty \n\n# :snake: Monty Interpreter\n\nWelcome to the Monty Bytecode Interpreter. This interpreter was built in the C language and is compliant with `ISO90`, `ISO99`, \u0026 `ISO11`. It reads Monty bytecode files of any extension (preferably `.m` although it doesn't matter), and interprets the opcodes contained.\n\nMonty 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.\n\nOur interpreter can be run as either a stack (LIFO) or queue (FIFO). Mode can be switched mid-script. The interpreter can handle a variety of Monty opcodes, including printing, mathematical operations, and more - all handled opcodes are listed below.\n\n## :running: Getting Started\n\n* [Ubuntu 14.04 LTS](http://releases.ubuntu.com/14.04/) - Operating system reqd.\n\n* [GCC 4.8.4](https://gcc.gnu.org/gcc-4.8/) - Compiler used\n\n## :arrow_down: Installing and Using\n\nClone the repository into a new directory:\n\n```\ngit clone https://github.com/Mohamed-Mostafaaa/monty.git\n```\nCompile with the following:\n\n```\ngcc -Wall -Werror -Wextra -pedantic *.c -o monty\n```\n\nRun the interpreter on a file:\n\n```\n./monty file.m\n```\n## :wrench: Header file [monty.h](./monty.h)\n\n### Data structures \nUse the following data structures, dont forget to include them in the header file.\n\n```c\n/**\n * struct stack_s - doubly linked list representation of a stack (or queue)\n * @n: integer\n * @prev: points to the previous element of the stack (or queue)\n * @next: points to the next element of the stack (or queue)\n *\n * Description: doubly linked list node structure\n * for stack, queues, LIFO, FIFO\n */\ntypedef struct stack_s\n{\n        int n;\n        struct stack_s *prev;\n        struct stack_s *next;\n} stack_\n```\n\n```c\n\n/**\n * struct instruction_s - opcode and its function\n * @opcode: the opcode\n * @f: function to handle the opcode\n *\n * Description: opcode and its function\n * for stack, queues, LIFO, FIFO\n */\ntypedef struct instruction_s\n{\n        char *opcode;\n        void (*f)(stack_t **stack, unsigned int line_number);\n} instruction_t;\n```\n\n## :wrench: Monty Opcodes\n\n* **push**\n  * Usage: `push \u003cint\u003e`\n  * Pushes an element to the stack.\n  * The parameter `\u003cint\u003e` must be an integer.\n\n* **pall**\n  * Prints all values in the stack/queue, starting from the top.\n\n* **pint**\n  * Prints the top value of the stack/queue.\n\n* **pop**\n  * Removes the top element of the stack/queue.\n\n* **swap**\n  * Swaps the top two elements of the stack/queue.\n\n* **nop**\n  * Does not do anything.\n\n* **add**\n  * Adds the top two elements of the stack/queue.\n  * The result is stored in the second element from the top and the top element is popped.\n\n* **sub**\n  * Subtracts the top element of the stack/queue from the second element from the top.\n  * The result is stored in the second element from the top and the top element is removed.\n\n* **mul**\n  * Multiplies the top two elements of the stack/queue.\n  * The result is stored in the second element from the top and the top element is removed.\n\n* **div**\n  * Divides the second element from the top of the stack/queue by the top element.\n  * The result is stored in the second element from the top and the top element is removed.\n\n* **mod**\n  * Computes the modulus of the second element from the top of the stack/queue divided by the top element.\n  * The result is stored in the second element from the top and the top element is removed.\n\n* **pchar**\n  * Prints the character value of the top element of the stack/queue.\n  * The integer at the top is treated as an ASCII value.\n\n* **pstr**\n  * Prints the string contained in the stack/queue.\n  * Prints characters element by element until the stack/queue is empty, a value is `0`, or an error occurs.\n\n* **rotl**\n  * Rotates the top element of the stack/queue to the bottom.\n\n* **rotr**\n  * Rotates the bottom element of the stack/queue to the top.\n\n* **stack**\n  * Switches a queue to stack mode.\n\n* **queue**\n  * Switches a stack to queue mode.\n\n:arrow_forward: Opcodes preceeded by a `#` are treated as comments and the corresponding line is ignored.\n\n:arrow_forward: Lines can be empty and can contain any number of spaces before or after an opcode and its argument (only the first opcode and/or argument is taken into account).\n\n## :blue_book: Authors\n\n* **Mohamed Mostafa** - [@Mohamed-Mostafaaa](https://github.com/Mohamed-Mostafaaa)\n\n* **Eman Elkamel** - [@emanelkamel](https://github.com/emanelkamel)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamed-mostafaaa%2Fmonty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamed-mostafaaa%2Fmonty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamed-mostafaaa%2Fmonty/lists"}