{"id":24353868,"url":"https://github.com/pickledchair/rustymonkey","last_synced_at":"2026-04-18T05:03:25.090Z","repository":{"id":152404847,"uuid":"347615907","full_name":"PickledChair/RustyMonkey","owner":"PickledChair","description":"The implementation of Monkey programming language (https://interpreterbook.com/) in Rust.","archived":false,"fork":false,"pushed_at":"2021-04-23T11:18:55.000Z","size":195,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T14:10:47.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/PickledChair.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-14T11:19:07.000Z","updated_at":"2021-04-23T11:18:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"396dfedf-99a4-4769-a256-cb41575a6170","html_url":"https://github.com/PickledChair/RustyMonkey","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PickledChair/RustyMonkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickledChair%2FRustyMonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickledChair%2FRustyMonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickledChair%2FRustyMonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickledChair%2FRustyMonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PickledChair","download_url":"https://codeload.github.com/PickledChair/RustyMonkey/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PickledChair%2FRustyMonkey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-01-18T16:22:08.828Z","updated_at":"2026-04-18T05:03:25.085Z","avatar_url":"https://github.com/PickledChair.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RustyMonkey\n\nThorsten Ball 氏の著書 [Writing An Interpreter In Go](https://interpreterbook.com/)（設樂 洋爾 氏による邦訳：[Go言語でつくるインタプリタ](https://www.oreilly.co.jp/books/9784873118222/)）にある Monkey 言語の Rust 実装です。\n\n\n\n## インストール\n\nビルドには Rust の開発環境（2018 edition）が必要です。\n\n```\n$ git clone https://github.com/PickledChair/RustyMonkey.git\n$ cd RustyMonkey\n$ cargo build\n```\n\n\n\n## 使い方\n\n### REPL\n\n```\n$ cargo run\nHello \u003cyour name\u003e! This is the Monkey programming language!\nFeel free to type in commands\n\u003e\u003e\n```\n\n終了時は `exit` または `quit` を入力してください。\n\n\n\n### ソースファイルの実行\n\n```\n# test.txt\nputs(\"hello!\");\n```\n\n\n\n```\n$ cargo run -- test.txt\nhello!\n```\n\n\n\n## 独自拡張\n\n### いくつかのエスケープ文字への対応\n\n```\n\u003e\u003e \"h\\te\\tl\\tl\\to\\t!\"\n=\u003e h\te\tl\tl\to\t!\n\u003e\u003e \"h\\ne\\nl\\nl\\no\\n!\"\n=\u003e h\ne\nl\nl\no\n!\n\u003e\u003e \"\\\"hello!\\\"\"\n=\u003e \"hello!\"\n```\n\n\n\n### マルチバイト文字への対応\n\n```\n\u003e\u003e let japanese = \"こんにちは\";\n\u003e\u003e japanese\n=\u003e こんにちは\n```\n\n\n\n### 行コメント\n\n```\n\u003e\u003e # これはコメントです\n\u003e\u003e # `#` 記号から改行文字までが無視されます\n\u003e\u003e let hello = \"hello\"; # 式や文の後ろに書くこともできます\n\u003e\u003e hello\n=\u003e hello\n```\n\n\n\n### 配列向けの組み込み関数や添字演算子の文字列への対応\n\n```\n\u003e\u003e let hello = \"hello\";\n\u003e\u003e # 以下、戻り値はいずれも文字列です\n\u003e\u003e first(hello)\n=\u003e h\n\u003e\u003e rest(hello)\n=\u003e ello\n\u003e\u003e last(hello)\n=\u003e o\n\u003e\u003e hello[0]\n=\u003e h\n\u003e\u003e hello[1]\n=\u003e e\n```\n\n\n\n### 整数に関する `\u003c=`, `\u003e=` 演算子の追加\n\n```\n\u003e\u003e 1 \u003c= 1\n=\u003e true\n\u003e\u003e 2 \u003c= 1\n=\u003e false\n\u003e\u003e 1 \u003e= 2\n=\u003e false\n\u003e\u003e 2 \u003e= 1\n=\u003e true\n\u003e\u003e 1 \u003e= 1\n=\u003e true\n```\n\n\n\n### 追加の組み込み関数\n\n```\n\u003e\u003e # init 関数：rest 関数の逆です。引数が配列の場合、末尾の要素を除いた配列を返します。\n\u003e\u003e # 引数が文字列の場合は、末尾の文字を除いた文字列を返します。\n\u003e\u003e init([1,2,3,4,5])\n=\u003e [1, 2, 3, 4]\n\u003e\u003e init(\"hello\")\n=\u003e hell\n\u003e\u003e\n\u003e\u003e # int 関数：文字列を１つ引数にとり、整数値に変換します。\n\u003e\u003e # 変換できなかった場合、エラーを返します。\n\u003e\u003e int(\"42\")\n=\u003e 42\n\u003e\u003e int(\"hello\")\n=\u003e ERROR: could not convert the given STRING `hello` into INTEGER\n\u003e\u003e\n\u003e\u003e # str 関数：引数を一つ取り、オブジェクトの文字列表現を返します。\n\u003e\u003e str(42)\n=\u003e 42\n\u003e\u003e str([1,2,3,4])\n=\u003e [1, 2, 3, 4]\n\u003e\u003e\n\u003e\u003e # print 関数：文字列を１つ引数にとり、改行なしで表示します。戻り値は null です。\n\u003e\u003e print(\"hello\")\nhello=\u003e null\n\u003e\u003e\n\u003e\u003e # readline 関数：引数なし。入力待ちになるので、文字列を入力後 Enter で確定してください。\n\u003e\u003e # 戻り値は文字列です。\n\u003e\u003e let input = readline();\nmy input\n\u003e\u003e input\n=\u003e my input\n\u003e\u003e\n\u003e\u003e # writefile 関数：ファイルパスと書き込む内容の文字列を引数にとります。\n\u003e\u003e # 指定されたファイルをテキストモードで開き、内容を書き込みます。\n\u003e\u003e # 戻り値は成功時に null, 失敗時にエラーを返します。\n\u003e\u003e writefile(\"test.txt\", \"ok\")\n=\u003e null\n\u003e\u003e\n\u003e\u003e # readfile 関数：ファイルパスを引数にとります。\n\u003e\u003e # 指定されたファイルをテキストモードで開き、ファイルの内容を文字列で返します。\n\u003e\u003e readfile(\"test.txt\")\n=\u003e ok\n\u003e\u003e # ファイルが見つからない場合は null を返します。\n\u003e\u003e readfile(\"hoge.txt\")\n=\u003e null\n```\n\n\n\n### import 文\n\n指定されたソースファイルをパース・評価して、得られたオブジェクトを現在の環境に追加します。\n\n```\n\u003e\u003e writefile(\"mylibrary.txt\", \"let myFunc = fn() { return \\\"This is my function!\\\"; };\\n\");\n=\u003e null\n\u003e\u003e import \"mylibrary.txt\";\n\u003e\u003e myFunc()\n=\u003e This is my function!\n```\n\n**備考**：原始的な import 文なので、互いに import し合うソースコードを評価すると無限ループに陥ります。\n\n\n\n## License\n\nMIT License で公開しています。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpickledchair%2Frustymonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpickledchair%2Frustymonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpickledchair%2Frustymonkey/lists"}