{"id":24335560,"url":"https://github.com/viddem/vm-lang","last_synced_at":"2025-07-13T02:03:57.101Z","repository":{"id":62218779,"uuid":"480321792","full_name":"ViddeM/vm-lang","owner":"ViddeM","description":"A simple programming language ","archived":false,"fork":false,"pushed_at":"2022-11-18T22:18:02.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-18T05:19:01.364Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/ViddeM.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}},"created_at":"2022-04-11T09:57:36.000Z","updated_at":"2022-10-22T14:35:55.000Z","dependencies_parsed_at":"2023-01-23T15:45:20.482Z","dependency_job_id":null,"html_url":"https://github.com/ViddeM/vm-lang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViddeM%2Fvm-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViddeM%2Fvm-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViddeM%2Fvm-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViddeM%2Fvm-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ViddeM","download_url":"https://codeload.github.com/ViddeM/vm-lang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243076640,"owners_count":20232435,"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":["hacktoberfest"],"created_at":"2025-01-18T05:19:05.018Z","updated_at":"2025-03-11T16:46:03.255Z","avatar_url":"https://github.com/ViddeM.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VM_Lang\nA basic interpreted programming language written in Rust as a fun exercise.\n\n## Basic structure\nA program written in the language is made up of a number of functions, one of which must be named `main`, take no arguments and have return type `void`.\n\n### Functions\nHas a name, a list of arguments and an optional return type followed by a block statement.\n\nEx:\n```\nfn some_func(a: int, b: [string]): boolean {\n    // Statements\n    return true\n}\n```\n\nIf a function has a return type it MUST use a `return` statement on every path through the function, otherwise a `return` is optional.\n\n### Comments\nAny text after `//` in a line is ignored (unless the `//` are within a string literal).\n\n### Statements\n\n#### Let\nDeclares a variable, type is inferred.\n\nEx:\n```\nlet a = 0;\n```\n\n#### While\nA loop that continues as long as the provided expression holds true.\n\nEx:\n```\nwhile true {\n    // Statements\n}\n```\n\n#### For\nA for-each loop going iterating through a list.\n\nEx:\n```\nlet some_list = [1, 4, 9];\nfor (a in some_list) {\n    // Statements\n}\n```\n\n#### If\nA branching statement, runs the block if the expression holds true.\n\nEx:\n```\nif true {\n    // Statements\n}\n```\n\n#### If else\nA branching statement, runs the first block if the expression holds true, otherwise runs the `else` block.\n\nEx:\n```\nlet i = 4;\nif i \u003c 2 {\n    // Statements\n} else {\n    // Statements\n}\n```\n\n#### Return type\nReturns from the current function with the provided expression, the type of the expression must be the same as the return type of the function.\n\nEx:\n```\nreturn 54;\n```\n\n#### Return void\nReturns from the current function when the function has return type `void`.\n\nEx:\n```\nreturn;\n```\n\n#### Expressions\nAn expression ended with a semi-colon `;` is also a statement.\n\nEx:\n```\ni++;\n```\n\n#### Blocks\nWraps a list of statements creating a new scope.\n\nEx:\n```\n{\n    // Statements\n}\n```\n\n### Expressions\nThere are a number of expressions in the language, in order of priority they are:\n\n#### Assignment\nReassigns a previously declared variable.\n\nEx:\n```\na = 2;\n```\n\n#### Comparison\nCompares two expressions of the same type returning a boolean.\n\nComparisons supporting only boolean expressions:\n    - `||` | 'or' is true if either of the expressions are true.\n    - `\u0026\u0026` | 'and' is true if both of the expressions are true.\n\nComparisons supporting all(?) types:\n    - `==` | `equals` is true if the expressions are the same.\n    - `!=` | `not equals` is true if the expressions are no the same.\n    - `\u003c=` | `Less than or equal to` is true if the first expression is less than or equal to the second expression.\n    - `\u003e=` | `Greater than or equal to` is true if the first expression is greater than or equal to the second expression.\n    - `\u003c` | `Less than` is true if the first expression is strictly less than the second expression.\n    - `\u003e` | `Greater than` is true if the first expression is strictly greater than the second expression.\n\nEx:\n```\n2 \u003c 4\n```\n\n#### Arithmetic operations\nPerforms an arithmetic operation between two expressions of type `int`.\n\nThe currently suppported arithmetic operations are:\n - `+` | plus\n - `-` | minus\n - `*` | times\n - `/` | division\n\nEx:\n```\n2 + 4\n```\n\n#### Unary operations\nOperations on singular expressions.\n\nThe currently supported unary operations are:\n - `!` | not\n - `++` | Increases the value by 1, depending on if put before or after the expression this will be done before or after the value is read.\n - `--` | Decreases the value by 1, depending on if put before or after the expression this will be done before or after the value is read.\n\nEx:\n```\ni++;\n```\n\n#### Function calls\nCalls a function.\n\nEx:\n```\nsome_func(42, \"this function has two args\");\n```\n\n#### List indexing\nRetrieves a value from a list by its index.\n\nEx:\n```\nlet some_list = [1, 5, 9];\nsome_list[1]; // Returns 5\n```\n\n#### Literals\nA literal of any of the available types (except void).\n\nEx:\n```\n54\n```\n\n#### Parenthesised expression\nAny expression wrapped in parenthesis.\n\nEx:\n```\n(1 + 2)\n```\n\n### Types\nThere are currently four types available in the language:\n - `int`, ex: `-54`\n - `bool`, ex: `true`\n - `string`, ex: `\"Hello! This is a string\"`\n - lists, declared as `[TYPE]` where `TYPE` can be any of the above types, ex: `[0, 1, 99, 200]`\n - `void`, never directly used but is used when no other type has been declared for e.g. functions that have no return type.\n\n## Builtin functions\nThere are a few built-in functions available for specific tasks.\n\n### print_number\nPrints the number to standard out.\n\nArgs:\n    - `number: int` | The number to print.\n\nReturns:\n    `Void\n\n### print_string\nPrints the string to standard out.\n\nArgs:\n    - `text: string` | The string to print.\n\nReturns:\n    `Void`\n\n### print_bool\nPrints the boolean to standard out.\n\nArgs:\n    - `val: bool` | The boolean to print.\n\nReturns:\n    `Void`\n\n### read_number\nReads a number from standard in.\n\nArgs:\n    None\n\nReturns:\n    - `number: int` | The number read.\n\n### read_string\nReads a string from standard in.\n\nArgs:\n    None\n\nReturns:\n    - `val: string` | The string read.\n\n### read_bool\nReads a boolean from standard in.\n\nArgs:\n    None\n\nReturns:\n    - `val: bool` | The boolean read.\n\n### read_file\nGiven a path, reads a file to a string.\n\nArgs:\n    - `file_path: string` | The filepath relative to the current directory.\n\nReturns:\n    - `file_content: string` | The content of the file.\n\n### split_string\nGiven a string and a 'splitter', splits the string on each occurance of the 'splitter', returning a list of the parts.\n\nArgs:\n    - `text: string` | The text to be split.\n    - `splitter: string` | The text to split on.\n\nReturns:\n    - `parts: [string]` | A list containing every part of `text` split on each occurance of the `splitter`.\n\n### parse_int\nParses a string to a number.\n\nArgs:\n    - `text: string` | The text to parse.\n\nReturns:\n    - `num: int` | The parsed text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviddem%2Fvm-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviddem%2Fvm-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviddem%2Fvm-lang/lists"}