{"id":13609431,"url":"https://github.com/cerus/edina","last_synced_at":"2025-04-11T00:53:03.354Z","repository":{"id":56579258,"uuid":"522329304","full_name":"cerus/edina","owner":"cerus","description":"Edina - A simple stack-oriented compiled programming language.","archived":false,"fork":false,"pushed_at":"2023-06-08T00:08:28.000Z","size":165,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-11T00:52:56.627Z","etag":null,"topics":["compiled-language","concatenative","concatenative-language","imperative","imperative-language","jvm-language","language","programming-language","stack-based","stack-based-language","stack-oriented"],"latest_commit_sha":null,"homepage":"","language":"Java","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/cerus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["cerus"]}},"created_at":"2022-08-07T21:31:59.000Z","updated_at":"2023-08-21T19:23:54.000Z","dependencies_parsed_at":"2023-09-24T02:01:45.671Z","dependency_job_id":null,"html_url":"https://github.com/cerus/edina","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fedina","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fedina/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fedina/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fedina/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cerus","download_url":"https://codeload.github.com/cerus/edina/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322609,"owners_count":21084336,"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":["compiled-language","concatenative","concatenative-language","imperative","imperative-language","jvm-language","language","programming-language","stack-based","stack-based-language","stack-oriented"],"created_at":"2024-08-01T19:01:34.842Z","updated_at":"2025-04-11T00:53:03.329Z","avatar_url":"https://github.com/cerus.png","language":"Java","readme":"\u003cimg src=\"https://cerus.dev/img/edina_lang_logo.png\" alt=\"Logo\" align=\"right\" width=140 height=140 /\u003e\n\u003ch1 align=\"left\"\u003eedina 📚\u003c/h1\u003e\n\nEdina is a simple multi-paradigm programming language. It currently features a JVM compiler, a REPL and an ever expanding\nstandard library.\n\nEdina is mostly a hobby project. Due to its stack-oriented design it's a little restrictive and hard to program in, but that's what makes it fun in my\nopinion.\n\nParadigms: [imperative](https://en.wikipedia.org/wiki/Imperative_programming)\n, [concatenative](https://en.wikipedia.org/wiki/Concatenative_programming_language)\n, [stack-oriented](https://en.wikipedia.org/wiki/Stack-oriented_programming)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"400\" src=\"https://cerus.dev/img/hello_world_edina2.png?\" alt=\"\u0026quot;Hello World\u0026quot; program\" /\u003e\n\u003c/p\u003e\n\u003cdetails align=\"center\"\u003e\n  \u003csummary\u003eSource code -\u003e Java bytecode\u003c/summary\u003e\n  \u003cimg src=\"https://cerus.dev/img/edina_edinaj_transformation.png\" alt=\"Java bytecode\"/\u003e\n\u003c/details\u003e\n\n## Contents\n\n1. [Try it out](#try-it-out)\n2. [Specification](#specification)\n3. [Running the JVM compiler](#running-the-jvm-compiler)\n4. [Building](#building)\n5. [Included scripts](#included-scripts)\n6. [EdinaJ development](#edinaj-development)\n7. [Credit](#credit)\n\n## Try it out\n\nTo try out Edina follow these steps:\n\n1. Clone the repository\n2. Build the project (see [Building](#building))\n3. Create `script.edina`\n4. Copy the contents of `examples/hello_world.edina` into `script.edina`\n5. Compile the script (`java -jar edinaj/target/edinaj.jar -P my.script -F script.edina -O script.jar`)\n6. Run the compiled Jar (`java -jar script.jar`)\n\nYou can also invite the [Edina Discord bot](discord-bot/README.md) to your server and try it there without performing any of these manual steps.\n\n## Specification\n\nEdina programs are usually called scripts, even though they are compiled. A script contains many commands. Edina is not whitespace sensitive, and you\ndo not have to terminate your statements. The only place where a terminator command is needed is in routine-, loop- and if-blocks.\n\nLet's start with the most important feature first: Comments! Edina comments are started with a `#` and span across the rest of the line.\n\nComments are very important for the readability of code - the stack-oriented design can make it difficult to understand what code is doing with a\nquick glance. Documenting your Edina code helps others understand what is going on. This is usually done with so-called stack diagrams.\n\nA stack diagram in Edina describes how the stack will look like after a set of operations has finished. Stack diagrams usually look like\nthis `[a, b, c]` where the leftmost item represents the top and the rightmost item represents the bottom of the stack.\n\n```r\n# This is a comment\n1 2 3 pop swap  # This is another comment\n\n# How stack diagrams are used:\nrt multi_dup\n  # [N, X]\n  # X = Item to duplicate\n  # N = How many times to duplicate X\n  \n  while\n    # [N, X]\n    swap dup   # [X, X, N]\n    1 3 rroll  # [N, X, X]\n    1 swap -   # [N-1, X, X]\n  end\n  # [N(0), X, ...]\n  pop  # [X, ...]\nend\n```\n\nEdina features a small set of commands which, when combined, can be used to create powerful and complex programs.\n\n```r\n# General commands\npop         # Drop the topmost element from the stack     [a] -\u003e []\ndup         # Duplicate the topmost item of the stack     [a] -\u003e [a, a]\nswap        # Swap the two topmost items of the stack     [a, b] -\u003e [b, a]\nover        # Duplicate the 2nd topmost item to the top   [a, b] -\u003e [b, a, b]\nlroll       # Roll X items N times to the left            [X(3), N(1), a, b, c] -\u003e [b, c, a]\nrroll       # Roll X items N times to the right           [X(3), N(1), a, b, c] -\u003e [c, a, b]\nend         # End the code block / Only used in routines, ifs and loops\n\n# Comparison commands\n# Peeks two values and pushes result (either 1 or 0 (true or false))\neq         # True if topmost two items are equal          [a, b] -\u003e [a==b, a, b]\nneq        # True if topmost two items are not equal      [a, b] -\u003e [a!=b, a, b]\ngt         # True if topmost item \u003e 2nd topmost item      [a, b] -\u003e [a\u003eb, a, b]\ngte        # True if topmost item \u003e= 2nd topmost item     [a, b] -\u003e [a\u003e=b, a, b]\nlt         # True if topmost item \u003c 2nd topmost item      [a, b] -\u003e [a\u003cb, a, b]\nlte        # True if topmost item \u003c= 2nd topmost item     [a, b] -\u003e [a\u003c=b, a, b]\n\n# Arithmetic / bitwise commands\n# Remember: Top of the stack in stack diagrams is left\n+           # Pop top two items and push sum              [a, b] -\u003e [a+b]\n-           # Pop top two items and push difference       [a, b] -\u003e [a-b]\n*           # Pop top two items and push product          [a, b] -\u003e [a*b]\n/           # Pop top two items and push quotient         [a, b] -\u003e [a/b]\n\u0026           # Pop top two items and push ANDed result     [a, b] -\u003e [a\u0026b] \n|           # Pop top two items and push ORed result      [a, b] -\u003e [a|b] \n^           # Pop top two items and push XORed result     [a, b] -\u003e [a^b] \n~           # Pop top item and push flipped result        [a] -\u003e [~a]\n\n\n3 5 -   # 5 - 3\n1 8 +   # 8 + 1\n4 3 ^   # 3 ^ 4\n```\n\nIn addition to these commands, any signed integer (limited to 64 bits) and string (enclosed by two quotation marks) will act as a push command and\nwill be pushed to the stack.\n\n```r\n123         # [] -\u003e [123]\n-123        # [] -\u003e [-123]\n\"abc\"       # Len + chars as bytes / [] -\u003e [3, 99, 98, 97]\n            # Strings are naturally reversed due to the stack\n```\n\nEdina also supports routines (aka functions, methods, sub-routines, ...), ifs, loops and importing other scripts.\n\n```r\n# ------ Imports ------\n# Import statements have to be placed at the beginning of the script\nimport \"stdlib/io/std\"\n# You can assign custom names to imported scripts\nimport \"stdlib/math/ints\" as custom_import_name\n# You can call the declared global routines of the imported scripts\n\"Hi\" :std.println_out               # -\u003e import \"stdlib/io/std\"\n123 :custom_import_name.int_to_str  # -\u003e import \"stdlib/math/ints\" as custom_import_name\n\n# ------ Routines ------\n# Declaring a routine called my_routine\n# Routines whose name starts with an underscore are internal and can not be called by\n# other scripts\nrt my_routine\n  # Insert routine code here\nend\n.my_routine  # Calling my_routine\n\n# ------ If ------\n# if will pop the top stack value and check if it is greater than zero\nif\n  # Code\nelse if\n  # Else if code\nelse\n  # Else code\nend\n\n# ------ Loops ------\n# while (peek_top_stack_item() != 0)\nwhile\n  # Code\nend\n# while (peek_top_stack_item() == 0)\nuntil\n  # Code\nend\n```\n\nIn order to interact with the host system, Edina features a few so-called \"native calls\". These native calls are heavily inspired by Linux syscalls.\n\n```r\nnative_stack_debug      # Print the stack contents to stdout    [] -\u003e []\nnative_open             # Open a file                           [FLAGS, PATH] -\u003e [FD]\nnative_write            # Write data to file descriptor         [FD, DATA] -\u003e [RES]\nnative_read             # Read data from file descriptor        [FD, AMT] -\u003e [RES]\nnative_close            # Close an opened file descriptor       [FD] -\u003e [RES]\nnative_time             # Get current time in seconds           [] -\u003e [TIME]\n```\n\n## Running the JVM compiler\n\nPlease refer to the [EdinaJ README](edinaj/README.md) to see the possible command line arguments.\n\nEdinaJ requires at least Java 17. The generated Jars require at least Java 8.\n\n## Building\n\nTo build Edina you will need Java 17, Git and Maven.\n\n1. `git clone https://github.com/cerus/edina.git`\n2. `cd edina`\n3. `mvn clean package` or [`./scripts/full_build.sh`](#included-scripts)\n\nFinal EdinaJ Jar: `edinaj/target/edinaj.jar`\\\nFinal CLI / REPL Jar: `cli/target/edina-cli.jar`\\\nFinal EdDoc Jar: `eddoc/target/eddoc.jar`\n\n## Included scripts\n\nThis repository contains a few scripts in the `scripts/` directory that make Edina development easier.\n\n`generate_asm.sh`: Generate OW2 ASM for the EdinaJ Stack, Natives and Launcher classes\\\n`cleanup.sh`: Delete any `asm_*.txt` files (generated by generate_asm.sh)\\\n`asm_to_code.sh`: Integrate generated ASM files into the respective compiler steps\\\n`full_build.sh`: `generate_asm.sh \u0026\u0026 asm_to_code.sh \u0026\u0026 cleanup.sh`\n\n## EdinaJ development\n\nDeveloping the JVM compiler is pretty straight forward. The `asm` package contains \"templates\" for the Launcher, Stack and Natives classes. These\ntemplates can be converted to OW2 ASM code and inserted into their respective compiler steps.\n\nMost of the compilation process is split up into `CompilerStep`s. This is an attempt to keep the code clean and organized. Each command has their own\ncompiler step for example.\n\nSee the [compiler step package](edinaj/src/main/java/dev/cerus/edina/edinaj/compiler/step)\nor [Compiler class](edinaj/src/main/java/dev/cerus/edina/edinaj/compiler/Compiler.java) for more details.\n\n## Credit\n\nInspired by Forth \u0026 Porth by Daily Tsoding\n\nLogo was generated by DALL·E mini / craiyon.com\n\n'hello_world.edina' banner was created with carbon.now.sh\n\nDedicated to Edina Of Coboldcastle (*2008-†2020)","funding_links":["https://github.com/sponsors/cerus"],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerus%2Fedina","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcerus%2Fedina","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerus%2Fedina/lists"}