{"id":16799415,"url":"https://github.com/georgesittas/ipl-interpreter","last_synced_at":"2025-04-11T00:21:06.662Z","repository":{"id":50578843,"uuid":"387016951","full_name":"georgesittas/ipl-interpreter","owner":"georgesittas","description":"Interpreter for a simple imperative language called IPL","archived":false,"fork":false,"pushed_at":"2023-03-15T17:14:00.000Z","size":219,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-24T21:05:11.004Z","etag":null,"topics":["c","crafting-interpreters","imperative","interpreter","language"],"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/georgesittas.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":"2021-07-17T18:55:27.000Z","updated_at":"2024-03-01T10:35:54.000Z","dependencies_parsed_at":"2025-02-18T08:32:32.942Z","dependency_job_id":"3ae4dc18-c986-41cf-8a2b-5006ddb0108c","html_url":"https://github.com/georgesittas/ipl-interpreter","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/georgesittas%2Fipl-interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fipl-interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fipl-interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fipl-interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgesittas","download_url":"https://codeload.github.com/georgesittas/ipl-interpreter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248318903,"owners_count":21083745,"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":["c","crafting-interpreters","imperative","interpreter","language"],"created_at":"2024-10-13T09:28:46.058Z","updated_at":"2025-04-11T00:21:06.642Z","avatar_url":"https://github.com/georgesittas.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IPL Interpreter\n\nIPL is a simple imperative language created for educational purposes in the [Introduction to Programming course](http://cgi.di.uoa.gr/~ip/). This\nimplementation uses some of the techniques described in the (amazing!) book [Crafting Interpreters](https://craftinginterpreters.com/).\n\n## Usage\n\n```Bash\n# Compile the project\nmake\n\n# Cleanup\nmake clean\n```\n\n## Specification\n\n### Types\n\nThe language only supports integers and arrays of integers.\n\n### Variables\n\nVariables don't need to be declared before their use and they are implicitly initialized to `0` on their first use. Variable names\ncan contain at most 100 characters and they must start with a letter, followed by any number of letters, numbers or underscores.\n\n### Constants\n\nOnly non-negative constants are allowed; one can produce negative values by subtracting from 0.\n\n### Input\n\nThe built-in command `read \u003clvalue\u003e` reads an integer value into `\u003clvalue\u003e`, which can be either a variable or an array element.\n\n### Output\n\nThe built-in commands `write \u003cexpr\u003e` and `writeln \u003cexpr\u003e` output the integer value `\u003cexpr\u003e`: a constant, variable or array element.\nThe former outputs a trailing space, while the latter a newline. In case these are used without an argument, a single space or newline\ncharacter will be printed.\n\n### Arithmetic Expressions\n\nAn arithmetic expression can contain at most two operands that can be either constants, variables or array elements.\nThe supported operators are `+`, `-`, `/`, `*` and `%`, having the same semantics as in C.\n\n### Assignment\n\nInteger values can be assigned to a variable or to an array element using the assignment statement: `\u003clvalue\u003e = \u003cexpr\u003e`.\nHere, `\u003cexpr`\u003e can be either a constant, a variable, an array element or an arithmetic expression.\n\n### Conditions\n\nConditions follow the same format as the arithmetic expressions, but they can only be used in control-flow constructs like\nif-else and while statements. The supported operators are `==`, `!=`, `\u003c=`, `\u003c`, `\u003e=` and `\u003e`, having the same semantics as in C.\n\n### While loop\n\nThis is the only statement that can be used for creating loops in IPL:\n\n```c\nwhile \u003ccondition\u003e\n\u003ctab\u003e \u003cstatement1\u003e\n\u003ctab\u003e \u003cstatement2\u003e\n....\n```\n\nThe language is indentation-sensitive, so tabs define blocks.\n\n### Branching\n\nSimilar to the while loop statement, IPL provides an if-else statement (else clause is optional):\n\n```c\nif \u003ccondition\u003e\n\u003ctab\u003e \u003cif_statement1\u003e\n\u003ctab\u003e \u003cif_statement2\u003e\n....\nelse\n\u003ctab\u003e \u003celse_statement1\u003e\n\u003ctab\u003e \u003celse_statement2\u003e\n....\n```\n\n### Random Numbers\n\nThe built-in command `random \u003clvalue\u003e` generates a random integer and stores it in `\u003clvalue\u003e`.\n\n### Comments\n\nA comment in IPL starts with the # character and ends when a newline character is found.\n\n### Command Line Arguments\n\nThe built-in command `argument size \u003clvalue\u003e` stores the number of command line arguments in `\u003clvalue\u003e`. The input\nfile is not counted as an argument. The built-in command `argument \u003cexpr\u003e \u003clvalue\u003e` stores an integer argument in\n`\u003clvalue\u003e`, where `\u003cexpr\u003e` is either a constant, a variable or an array element and represents the argument index.\nIf the index is out-of-bounds, a runtime error is raised.\n\n### Break and Continue\n\nThe built-in commands `break \u003cn\u003e` and `continue \u003cn\u003e` have the same semantics as break and continue in C when `\u003cn\u003e = 1`.\nIn all other cases, they jump `\u003cn\u003e` loops, where `\u003cn\u003e` is a positive integer. Below is an example:\n\n```c\nwhile a \u003c 5\n  a = a + 1\n  write a\n  if a == 3\n    break\n  while b \u003c 20\n    b = b + 1\n    write b\n    c = b % 5\n    if c == 0\n      continue 2\nwriteln\n```\n\n`Output: 1 1 2 3 4 5 2 6 7 8 9 10 3`\n\n### Arrays\n\nInteger arrays can be created as `new \u003cname\u003e[\u003cexpr\u003e]`, where `\u003cexpr\u003e` is a non zero constant, variable or array\nelement representing the new array's dimension. Arrays and variables must have different names. All uninitialized\narray elements are implicitly initialized to 0. The array's memory can be collected with the free statement, using\n`free \u003cname\u003e`. An array element reference works just like in C: `\u003cname\u003e[\u003cexpr\u003e]`, where `\u003cexpr\u003e` can be either a\nconstant, a variable or an array element and an out-of-bounds index raises a runtime error. The built-in command\n`size \u003cname\u003e \u003clvalue\u003e` stores the size of the array referred to by `\u003cname\u003e` in `\u003clvalue\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesittas%2Fipl-interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgesittas%2Fipl-interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesittas%2Fipl-interpreter/lists"}