{"id":32519639,"url":"https://github.com/drjayvee/goldylox","last_synced_at":"2026-07-11T11:32:24.655Z","repository":{"id":319072249,"uuid":"1076169566","full_name":"drjayvee/GoldyLox","owner":"drjayvee","description":"Lox interpreter","archived":false,"fork":false,"pushed_at":"2026-05-03T18:36:23.000Z","size":133,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-03T20:33:06.722Z","etag":null,"topics":["interpreter","lox","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"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/drjayvee.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":"2025-10-14T13:50:34.000Z","updated_at":"2026-05-03T18:36:28.000Z","dependencies_parsed_at":"2025-10-18T01:38:43.963Z","dependency_job_id":null,"html_url":"https://github.com/drjayvee/GoldyLox","commit_stats":null,"previous_names":["drjayvee/goldylox"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/drjayvee/GoldyLox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drjayvee%2FGoldyLox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drjayvee%2FGoldyLox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drjayvee%2FGoldyLox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drjayvee%2FGoldyLox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drjayvee","download_url":"https://codeload.github.com/drjayvee/GoldyLox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drjayvee%2FGoldyLox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35361644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"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":["interpreter","lox","ruby"],"created_at":"2025-10-28T04:38:24.248Z","updated_at":"2026-07-11T11:32:24.650Z","avatar_url":"https://github.com/drjayvee.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoldyLox: an interpreter for Lox, written in Ruby\n\nI'm following along with [Robert Nystrom's Crafting Interpreters](https://craftinginterpreters.com) to learn how to\nwrite an interpreter (which still seems magical to me), as well as to learn (more) Ruby and RBS.\n\n# Showcase\n\nBelow are a couple of examples to where the Ruby code is just so much more elegant and beautiful than Java.\n\nThese put a smile on my face when I wrote them. 😍\n\n### Scanning until the end of the line or file\n```java\nwhile (peek() != '\\n' \u0026\u0026 !isAtEnd()) advance();\n```\n\n```ruby\nadvance until peek == \"\\n\" || eof?\n```\n\nThe Ruby code reads just almost like plain English. Swapping `while` with `until` to flip the condition makes it\ncrystal clear.\n\n### Resolving a variable's depth\n```java\nprivate void resolveLocal(Expr expr, Token name) {\n  for (int i = scopes.size() - 1; i \u003e= 0; i--) {\n    if (scopes.get(i).containsKey(name.lexeme)) {\n      interpreter.resolve(expr, scopes.size() - 1 - i);\n      return;\n    }\n  }\n}\n```\n\n```ruby\ndef resolve_local(expr, name)\n  @scopes.reverse_each.with_index do |scope, i|\n    if scope.key? name.lexeme\n      @interpreter.resolve(expr, i)\n      return\n    end\n  end\nend\n```\n\nUsing `reverse_each` makes the intent immediately clear. There's also no need for `scopes.get(i)`.\n\nReplacing `scopes.size() - 1 - i` with just `i` avoids any chance for off-by-one errors.\n\n### Interpreting a call expressions\n```java\n@Override\npublic Void visitCallExpr(Expr.Call expr) {\n  resolve(expr.callee);\n  \n  for (Expr argument : expr.arguments) {\n    resolve(argument);\n  }\n  \n  return null;\n}\n```\n\n```ruby\ndef visit_call(expr)\n  resolve expr.callee\n  expr.arguments.each { resolve it }\nend\n```\n\nI rest my case. ☺️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrjayvee%2Fgoldylox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrjayvee%2Fgoldylox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrjayvee%2Fgoldylox/lists"}