{"id":18729546,"url":"https://github.com/gabryon99/imp","last_synced_at":"2025-08-07T16:29:40.656Z","repository":{"id":135462461,"uuid":"487119021","full_name":"gabryon99/imp","owner":"gabryon99","description":"IMP is a small imperative programming language.","archived":false,"fork":false,"pushed_at":"2022-05-01T15:44:57.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-28T14:36:56.263Z","etag":null,"topics":["imperative","menhir","ocaml","ocamllex","programming-language","semantics"],"latest_commit_sha":null,"homepage":"","language":"OCaml","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/gabryon99.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":"2022-04-29T21:51:03.000Z","updated_at":"2024-11-26T04:44:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e6fb48b-3e18-401d-ba1d-0013511d5ff9","html_url":"https://github.com/gabryon99/imp","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/gabryon99%2Fimp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabryon99%2Fimp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabryon99%2Fimp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabryon99%2Fimp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabryon99","download_url":"https://codeload.github.com/gabryon99/imp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599040,"owners_count":19665911,"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":["imperative","menhir","ocaml","ocamllex","programming-language","semantics"],"created_at":"2024-11-07T14:27:32.504Z","updated_at":"2025-02-19T04:53:42.122Z","avatar_url":"https://github.com/gabryon99.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"## IMP - a simple imperative language\n\n\u003e **IMP** is a small language of while programs. IMP is called an \"imperative\" language because program execution involeves carrying out a series of explicit commands to change state.\n\u003e \n\u003e *The formal semantics of programming languages* - *Glynn Winskel*\n\nThis OCaml project implements a simple interpreter of the IMP programming language described by Winskell. The language is extended with some tweaks which are not present in the book, such as the `print` and `read` functions. The interpreter makes use of `ocamllex`, `menhir` and `ppx` as dependencies. To build the executable run `dune run` and to execute type `dune exec imp`.\n\nBe aware that this implementation is a toy, it surely has some not checked errors 🙂\n\n### Grammar\n\nThe grammar is expressed using the BNF.\n\n```\nArithmetic Expressions\na ::= n | X | a0 + a1 | a0 - a1 | a0 * a1 | read | ( a )\n\nBoolean Expressions\nb ::= true | false | a0 = a1 | a0 \u003c= a1 | a0 \u003c a1 | a0 \u003e= a1 | a0 \u003e a1 | !b | b0 || b1 | b0 \u0026\u0026 b1 | ( b )\n\nCommands\nc ::= skip | print a | c0; c1 | if b then c0 else c1 end | while b do c end\n```\n\n### A simple program\n\nThe program shown below implement the factorial function.\n\n```\nn := read;\nf := 1;\nwhile n \u003e 0 do\n    f := f * n;\n    n := n - 1;\nend\nprint f;\n```\n\nAll the examples can be found inside the `playground` directory.\n\n### Added Features\n\nThe features added to the language are a few:\n* the `end` keyword has been introduced to mark the end of while/if block;\n* the `read` expression is useful to read a number from the *standard input* (⚠️ No check is performed onto the typed input); \n* the `print` command is the most complex one: it prints a number onto the screen.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabryon99%2Fimp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabryon99%2Fimp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabryon99%2Fimp/lists"}