{"id":13473857,"url":"https://github.com/fionafibration/owoScript","last_synced_at":"2025-03-26T19:34:55.073Z","repository":{"id":86467508,"uuid":"171959162","full_name":"fionafibration/owoScript","owner":"fionafibration","description":"An OwO based, stack-oriented programming language","archived":false,"fork":false,"pushed_at":"2019-06-06T20:18:47.000Z","size":182,"stargazers_count":140,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-13T04:32:20.240Z","etag":null,"topics":["antlr4-grammar","antlr4-python3","esoteric-programming-language","owo","owo-whats-this","programming-language","programming-languages","python","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fionafibration.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-21T23:08:35.000Z","updated_at":"2024-01-28T12:36:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"c3c94c96-3b8d-4610-9503-2dd54b91767a","html_url":"https://github.com/fionafibration/owoScript","commit_stats":null,"previous_names":["fionafibration/owoscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fionafibration%2FowoScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fionafibration%2FowoScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fionafibration%2FowoScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fionafibration%2FowoScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fionafibration","download_url":"https://codeload.github.com/fionafibration/owoScript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245722999,"owners_count":20661864,"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":["antlr4-grammar","antlr4-python3","esoteric-programming-language","owo","owo-whats-this","programming-language","programming-languages","python","python3"],"created_at":"2024-07-31T16:01:07.530Z","updated_at":"2025-03-26T19:34:52.993Z","avatar_url":"https://github.com/fionafibration.png","language":"Python","readme":"# owoScript\n\nowoScript is a stack based, imperative, and Turing complete programming language. \nowoScript works with a simple and descriptive language \nthat is then compiled to the best bytecode to ever exist on this planet.\n\nWhy is owoScript bytecode the best on the planet? Because it's entirely made out of \nOwO faces! Why have the speed and portability of the JVM when you can have the most *adorable* \ncode out of almost any language you can write in? And never fear, your owoScript bytecode can easily be turned\nback into the higher level form at any time.\n\nAdditionally, owoScript leaves its syntax and parsing files easily accessible to be inspected and verified by \nanyone. owoScript's grammar is written in ANTLR4, a parsing tool so out of this world reliable and efficient that \nyou'll wonder why your favorite programming language isn't using it yet.\n\n### Examples\nSee the `/examples` directory for a hello world, truth machine, and a proof of turing completeness via \nbrainfuck equivalents (does your fancy OOP language prove that it is capable of universal computation? \nCan you trust it if it doesn't?)\n\n### Usage\n\n##### Stack\n\nowoScript is written in a descriptive language consisting of stack operations, number literals, \n`while` loops, and `if {} else {}` statements.\nWhitespace is ignored. \n\nowoScript is stack-based, with only integer types. For example, \nthe following literal will push `6` onto the stack:\n```\nliteral 6;\n```\nand the following command will take that number off the stack and print it:\n```\nprintnum;\n```\noperations take their values off the stack in the order they came onto it:\n```\nliteral 8;\nliteral 2;\ndiv;\n```\ncorresponds to 8 / 2, not 2 / 8. However, in addition to the stack, an optional \"hashmap\", \nmapping integer keys to integer values, is available through the `store` and `get` commands\n\n##### Arithmetic \n\nBecause owoScript is stack-based, arithmetic is performed in postfix notation.\nThis means that writing something like (2+3)*(5/7)\nis written by taking the operator out of the middle of the expression and adding it on to the end.\nSo 2+3 is written as `literal 2; literal 3; add;` and 5/7 is written as `literal 5; literal 7; div;`\n\nThe final expression would thus be written as:\n\n```\nliteral 2;\nliteral 3;\nadd;\nliteral 5;\nliteral 7;\ndiv;\nmult;\n```\n\n##### Flow control\n\nFlow control is provided in `while` loops, functions, and `if {} else {}` statements\n\nWhile loops simply repeat the operation inside them until the top of the stack is 0, or falsy.\nThey do not pop values, and instead simply inspect the stack without changing it. While loops are skipped\nif the top of the stack is 0 when they are made.\n\nExample: \n```\n// Truth machine\n// When a truthy number is inputted, continue printing it forever\n// Otherwise print once and stop\ninputnum;\ndupe;\nprintnum;\nwhile {\n    dupe;\n    printnum;\n}\n```\n\nFunctions are defined at the top of the file and called like so, \nand can call other functions. Putting a function anywhere other than \nat the top of the file will result in very undefined behavior.\nFunctions do not take argument, and simply operate off of the stack.\n```\nfunc square {\n    dupe;\n    mult;\n}\nliteral 3;\nsquare();\n```\n\nIf statements have the syntax \n```\nif {\n    // statements or nop;\n}\nelse {\n    // statements or nop;\n}\n```\nand pop the top value of the stack. If it is truthy, the first block is executed. Otherwise,\nthe second one is.\n\n\n##### Commands\n\nCommands are single word operations (except for number literals and bignumber literals, see below)\n\n| Keyword    | Pops | Pushes                                                     |\n|------------|------|------------------------------------------------------------|\n| literal x  | None | hex value of x, x must be single hex digit (0-9, a-f)      |\n| number x   | None | int value of x, x is signed number [*]                     |\n| add        | a, b | a + b                                                      |\n| sub        | a, b | a - b                                                      |\n| mult       | a, b | a * b                                                      |\n| div        | a, b | a // b (floor division)                                    |\n| mod        | a, b | a % b (modulus)                                            |\n| exp        | a, b | a ^ b (exponent)                                           |\n| print      | a    | prints the character with code *a*                         |\n| printnum   | a    | prints the number literally                                |\n| printstack | None | prints entire stack                                        |\n| input      | None | number of character read from stdin                        |\n| inputnum   | None | decimal number read from stdin                             |\n| lt         | a, b | 1 if a \u003c b else 0                                          |\n| gt         | a, b | 1 if a \u003e b else 0                                          |\n| eq         | a, b | 1 if a == b else 0                                         |\n| neq        | a, b | 1 if a != b else 0                                         |\n| cmp        | a, b | if a == b: 0, if a \u003e b: 1, if a \u003c b: -1                    |\n| dupe       | a    | a, a (a repeated)                                          |\n| dupedeep   | a    | extend stack with last a values on stack                   |\n| swap       | a, b | b, a (top two values swapped)                              |\n| push       | a, b | puts a *b* layers deep in the stack                        |\n| fetch      | a    | pulls the number *a* deep in the stack to the top          |\n| stacklength| None | length of stack                                            |\n| store      | a, b | stores b in the *a* slot in the hashmap                    |\n| get        | a    | pushes the value stored in *a* slot in the hashmap         |\n| stop       | a    | exits with return code a                                   |\n| fetchdupe  | a, b | same as fetch but doesn't remove number from inside stack  |\n| pushdupe   | a    | same as push but doesn't remove number from top of stack   |\n| nop        | None | no operation, used for code clarity in if/else statements  |\n| hexmult    | a, b | a * 16 + b (hexadecimal digit appending)                   |\n| printhash  | None | prints entire hashmap                                      |\n\n\\* these number literals will be less space efficient in OwO form, so if your \nnumber is representable by a single hex digit, that form is recommended.\n\n##### CLI Usage\n\nThe python script `owo.py` is used for running owoScript bytecode or psuedocode, while the python\nscript `owoc.py` is the compiler/decompiler used to transform code from pseudocode or bytecode.\n\nThe script `bfowo.py` is used to convert brainfuck programs into owoscript. This conversion is moderately optimized, \nbut is still less efficient than really writing in owoscript would be. \n\nA command line option can be used to specify whether you'd like the transpiler to \"wrap\" the brainfuck cells \n(like an 8-bit unsigned int) or whether you'd like python-style ints.\n\nSee `sierpinski_bf.owop` and `mandelbrot_bf.owop` for examples of these conversions.\n\n### Turing completeness\nowoScript is provably Turing complete, via a simple reduction to brainfuck\n\n```/*\n\nBrainfuck equivalents for OwOScript\n\nStack is used to hold current pointer while hashmap is used for cells\n\n*/\n\n\n// \u003e Move pointer right\nliteral 1;\nadd;\n\n// \u003c Move pointer left\nliteral 1;\nsub;\n\n// + Increment cell\ndupe;\ndupe;\nget;\nliteral 1;\nadd;\n\n/*\nMod 256 wrapping if desired\nliteral 1;\nliteral 0;\nhexmult;\nliteral 0;\nhexmult;\nmod;\n*/\n\nstore;\n\n// - Decrement cell\ndupe;\ndupe;\nget;\nliteral 1;\nsub;\n\n/*\nMod 256 wrapping if desired\nliteral 1;\nliteral 0;\nhexmult;\nliteral 0;\nhexmult;\nmod;\n*/\n\nstore;\n\n// . Output char\ndupe;\nget;\nprint;\n\n// , Input char\ndupe;\ninput;\nstore;\n\n// [ ] Begin and end while loop\ndupe;\nget;\nwhile {\n    discard;\n    //statements\n    dupe;\n    get;\n}\ndiscard;\n```\n\n### Why\n\n\"The only reason someone would do something like this if they could, which they can't, would be because they could, which they can't.\" - Rick Sanchez\n\nI'm sure the question everyone is thinking is \"why.\" Why make a programming language entirely in OwO faces? \nWhy go out of my way to implement a formal grammar with a parser for a meme? \n\nThe simple answer, of course, is because \nI hate myself. The more accurate answer is because I wanted to try out writing a basic interpreter and grammar in\nANTLR, in preparation for possibly writing an LLVM compiler for a few esoteric programming languages in the near future\n\n### Credits\nI dedicate this project to all of my friends who answer the phone with \"hewwo\" so often I want to bash my head in.\n\n### Final Note\nThis project is mostly a joke I embarked on as a fun way of learning parsing and the basics of imperative language design. Any ridiculous statements inside this project are purely satire.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffionafibration%2FowoScript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffionafibration%2FowoScript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffionafibration%2FowoScript/lists"}