{"id":21092142,"url":"https://github.com/n4ze3m/sloth","last_synced_at":"2025-06-16T10:41:11.234Z","repository":{"id":43739506,"uuid":"411178653","full_name":"n4ze3m/sloth","owner":"n4ze3m","description":"Sloth is a simple interpeter written in Golang.","archived":false,"fork":false,"pushed_at":"2022-02-20T17:35:39.000Z","size":50,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T01:15:22.409Z","etag":null,"topics":["golang","interpeter","programming-language","sloth"],"latest_commit_sha":null,"homepage":"https://sloth.n4ze3m.com/","language":"Go","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/n4ze3m.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":"2021-09-28T07:24:57.000Z","updated_at":"2024-02-05T08:07:10.000Z","dependencies_parsed_at":"2022-08-22T13:31:58.573Z","dependency_job_id":null,"html_url":"https://github.com/n4ze3m/sloth","commit_stats":null,"previous_names":["nazeemnato/sloth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fsloth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fsloth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fsloth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fsloth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n4ze3m","download_url":"https://codeload.github.com/n4ze3m/sloth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243533735,"owners_count":20306407,"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":["golang","interpeter","programming-language","sloth"],"created_at":"2024-11-19T21:52:05.816Z","updated_at":"2025-03-14T06:24:26.668Z","avatar_url":"https://github.com/n4ze3m.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sloth\n\nSloth is a simple interpeter written in Golang. This is hoby project for learning golang. I converted this to WebAssembly :) program, now i can run it on browser.\n\n## Syntax\n\nThis is a simple syntax for sloth. currently, sloth works with following syntax in repl.\n\nVariable declaration in sloth is like this:\n\n    var name = value\n\n1. Addition of two numbers\n\n```shell\n\u003e\u003e\u003e var a = 10\n\u003e\u003e\u003e var b = 20\n\u003e\u003e\u003e a + b\n30\n```\n\nNote: Sloth support all basic arithmetic operations except `\u003e=` and `\u003c=`.\n\n2. Function\n\n```shell\n\u003e\u003e\u003e var add = fun(a,b) { return a + b};\n\u003e\u003e\u003e add(1,2)\n3\n```\n\n3. If else statement\n\n```shell\n\u003e\u003e\u003e var isten = fun(a) { if(a == 10) { return \"yes\" } else { return \"no\"} }\n\u003e\u003e\u003e isten(10)\nyes\n\u003e\u003e\u003e isten(11)\nno\n```\n\n4. String concatenation\n\n```shell\n\u003e\u003e\u003e var say = \"hello\" + \" \" + \"world\"\n\u003e\u003e\u003e say\nhello world\n\u003e\u003e\u003e var say = concat(\"hello\", \"world\")\n\u003e\u003e\u003e say\nhello world\n```\n5. Built-in functions\n\n- `len(a)`: returns length of array\n- `concat(a,b)`: concatenates two strings\n\n6. Array\n\n```shell\n\u003e\u003e\u003e var a = [1,2 + 2,3]\n\u003e\u003e\u003e a[0]\n1\n\u003e\u003e\u003e a[1]\n4\n```\n\n## Build\n\n1. WASM build\n\n```shell\n$ cd wasm\n$ $ENV:GOOS=\"js\"\n$ $ENV:GOARCH=\"wasm\" \n$ go build -o ../build/sloth.wasm\n```\n\n# Btw\n\nI wrote this project based on Thorsten Ball's [Writing an Interpreter in Go](https://interpreterbook.com/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn4ze3m%2Fsloth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn4ze3m%2Fsloth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn4ze3m%2Fsloth/lists"}