{"id":20881574,"url":"https://github.com/boenfu/tsmonkey","last_synced_at":"2025-05-12T17:30:39.168Z","repository":{"id":252025071,"uuid":"824649549","full_name":"boenfu/tsmonkey","owner":"boenfu","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-12T01:10:05.000Z","size":134,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T05:28:45.569Z","etag":null,"topics":["monkey-language","type-challenges","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/boenfu.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}},"created_at":"2024-07-05T15:41:54.000Z","updated_at":"2024-09-29T17:43:22.000Z","dependencies_parsed_at":"2024-08-07T08:45:36.419Z","dependency_job_id":"6599ea3d-c503-44d1-9153-c06a80f48bc7","html_url":"https://github.com/boenfu/tsmonkey","commit_stats":null,"previous_names":["boenfu/tsmonkey"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Ftsmonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Ftsmonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Ftsmonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Ftsmonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boenfu","download_url":"https://codeload.github.com/boenfu/tsmonkey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224859678,"owners_count":17381682,"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":["monkey-language","type-challenges","typescript"],"created_at":"2024-11-18T07:25:22.805Z","updated_at":"2024-11-18T07:25:23.187Z","avatar_url":"https://github.com/boenfu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 🐒 TSMonkey\n\n```bash\nnpm install @boenfu/tsmonkey\n```\n\n### Eval\n```typescript\nimport type { Eval } from '@boenfu/tsmonkey'\n\nEval\u003c'4 + 8'\u003e // 12\nEval\u003c'2 * (4 + 8)'\u003e // 24\nEval\u003c'!99'\u003e // false\n\nEval\u003c'(3 + 2) * 5 == 25'\u003e // true\nEval\u003c'(3 \u003e 2) != (2 \u003e 3)'\u003e // true\n\nEval\u003c'7 \u0026\u0026 9'\u003e // 9\nEval\u003c'false || 0'\u003e // 0\n```\n\nvariable declaration\n```typescript\nEval\u003c`\nlet a = 2\nlet b = 3\nlet c = a * b\nc * c\n`\u003e // 36\n```\n\nif else\n```typescript\nEval\u003c`\nlet a = 2\nlet b = 3\n\nif(a \u003e= b) {\n  return \"a is greater than b\"\n} else {\n  return \"a is less than b\"\n}\n`\u003e // \"a is less than b\"\n```\n\nfunction\n```typescript\nEval\u003c`\nlet a = 5\nlet b = 10\n\nfunction foo(a, b) {\n  return a - b\n}\n\nfoo(b, a)\n`\u003e // 5\n```\n\nfibonacci\n```typescript\nEval\u003c`\nfunction fibonacci(n) {\n  if (n \u003c 2) { return 0 }\n  if (n == 2) { return 1 }\n\n  return fibonacci(n - 1) + fibonacci(n - 2)\n}\n\nfibonacci(6)\n`\u003e // 5\n```\n### Parser\n```typescript\nimport type { Parser } from '@boenfu/tsmonkey'\nParser\u003c'let a = \"如果你要写年\"'\u003e\n// Program\u003c[LetStatement\u003cIdentifier\u003c\"a\"\u003e, StringLiteral\u003c\"如果你要写年\"\u003e\u003e]\u003e\n```\n\n### Lexer\n```typescript\nimport type { Lexer } from '@boenfu/tsmonkey'\nLexer\u003c'let a = \"如果你要写年\"'\u003e\n// [\n//   Token\u003cTokenType.LET, \"let\"\u003e,\n//   Token\u003cTokenType.IDENT, \"a\"\u003e,\n//   Token\u003cTokenType.ASSIGN, \"=\"\u003e,\n//   Token\u003cTokenType.STRING, \"如果你要写年\"\u003e,\n//   Token\u003cTokenType.EOF, \"\"\u003e\n// ]\n```\n\n\u003ca href=\"https://weread.qq.com/web/bookDetail/74d32120813ab6de0g019b0e\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.weread.qq.com/web/wrweb-next/_nuxt/img_logo.Egsq9YBR.png\" height=\"18\" /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboenfu%2Ftsmonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboenfu%2Ftsmonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboenfu%2Ftsmonkey/lists"}