{"id":21432987,"url":"https://github.com/robjsliwa/rlox","last_synced_at":"2025-03-16T22:42:01.632Z","repository":{"id":54130927,"uuid":"290637282","full_name":"robjsliwa/rlox","owner":"robjsliwa","description":"rlox language","archived":false,"fork":false,"pushed_at":"2021-03-08T19:13:55.000Z","size":169,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T08:44:07.678Z","etag":null,"topics":["compiler","interpreter","rust","tree-walk-interpreter"],"latest_commit_sha":null,"homepage":"","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/robjsliwa.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}},"created_at":"2020-08-27T00:47:15.000Z","updated_at":"2023-09-13T18:51:13.000Z","dependencies_parsed_at":"2022-08-13T07:10:25.315Z","dependency_job_id":null,"html_url":"https://github.com/robjsliwa/rlox","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/robjsliwa%2Frlox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Frlox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Frlox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Frlox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robjsliwa","download_url":"https://codeload.github.com/robjsliwa/rlox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945543,"owners_count":20372893,"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":["compiler","interpreter","rust","tree-walk-interpreter"],"created_at":"2024-11-22T23:23:56.282Z","updated_at":"2025-03-16T22:42:01.589Z","avatar_url":"https://github.com/robjsliwa.png","language":"Rust","readme":"# Rlox\n\nRlox is simple language designed purely to learn how build interpreters.\n\nRlox is a clone of lox langauge from https://craftinginterpreters.com/ book. Lox was written in Java and C and Rlox is a clone written in Rust just for fun.\n\n*NOTE* - This is work in progress.  Branch `tree-walk` contains tree walking interpreter.\n\n# Running REPL\n\nCurrently REPL it is very basic but you can execute all of the commands from it.  To run REPL just `cargo run`\n\n# Running Rlox code from file\n\n`cargo run -- -i path/filename.rl`\n\n# Run tests\n\n`cargo t`\n\n# Some example code\n\n## Compute Fibonacci \n\n```\nfun fib(n) {\n  if (n \u003c= 1) return n;\n  return fib(n - 2) + fib(n - 1);\n}\n\nfor (var i = 0; i \u003c 20; i = i + 1) {\n  print fib(i);\n}\n```\n\n## Closures\n\n```\nvar a = \"global\";\n{\n  fun showA() {\n    print a;\n  }\n\n  showA();\n  var a = \"block\";\n  showA();\n}\n\nfun test() {\n  print a;\n  a=a+\"!\";\n  return a;\n}\n\nprint test();\n```\n\n## Classes and Inheritance\n\n```\nclass Doughnut {\n  cook() {\n    return \"Fry until golden brown.\";\n  }\n\n  cookAnother() {\n    return \"Fry until golden.\";\n  }\n}\n\nclass BostonCream \u003c Doughnut {\n  cookAnother() {\n    var orig = super.cookAnother();\n    return orig + \" Then pipe full of custard and coat with chocolate.\";\n  }\n}\n\nvar first = BostonCream().cook();\nprint first;\n\nvar second = BostonCream().cookAnother();\nprint second;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobjsliwa%2Frlox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobjsliwa%2Frlox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobjsliwa%2Frlox/lists"}