{"id":19152285,"url":"https://github.com/kane50613/kcalculator","last_synced_at":"2025-04-19T16:32:29.404Z","repository":{"id":104840137,"uuid":"369930224","full_name":"kane50613/kCalculator","owner":"kane50613","description":"練習Lexer跟Parser還有Binary Tree的專案","archived":true,"fork":false,"pushed_at":"2021-05-27T07:01:19.000Z","size":16,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T21:14:41.667Z","etag":null,"topics":["calculator","javascript","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kane50613.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-05-23T00:20:19.000Z","updated_at":"2024-10-16T06:47:17.000Z","dependencies_parsed_at":"2023-07-19T22:16:27.573Z","dependency_job_id":null,"html_url":"https://github.com/kane50613/kCalculator","commit_stats":null,"previous_names":["kane50613/kcalculator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kane50613%2FkCalculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kane50613%2FkCalculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kane50613%2FkCalculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kane50613%2FkCalculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kane50613","download_url":"https://codeload.github.com/kane50613/kCalculator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249738800,"owners_count":21318504,"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":["calculator","javascript","lexer","parser"],"created_at":"2024-11-09T08:17:21.161Z","updated_at":"2025-04-19T16:32:29.108Z","avatar_url":"https://github.com/kane50613.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kCalculator\r\n練習Lexer跟Parser還有Binary Tree的專案\r\n\r\n***\r\n\r\n## 為什麼會想要做\r\n看到一堆人在 [Discord](https://discord.gg/ct2ufag) 上面炫耀自己做的語言真的有點獸不了，所以想說也來嘗試一下\r\n\r\n## 執行流程\r\n輸入 \u003e `Lexer` \u003e `Parser` \u003e `Executor`\r\n\r\n### 輸入資料\r\n可以支援加減乘除和括號優先順序的算式\r\n\r\n### Lexer\r\n第一次聽到這個名詞感覺蠻陌生的，\r\n不過他負責的工作是把你輸入的文字給拆分成一個一個的 `Token`，這裡有個簡單的範例\r\n\r\n```\r\nkCalculator \u003e 1 + 1\r\n上面的就可以拆分成\r\n1 =\u003e [整數, 1]\r\n+ =\u003e [加號]\r\n1 =\u003e [整數, 1]\r\n```\r\n\r\n### Parser\r\n他的工作是負責把拆分好的 tokens 變成可以運算的算式，這東西花上了我一整天\u003e\u003c\r\n\r\n我的思路是把一個算式變成一顆Binary Tree\r\n\r\n像是 `1 + 1` 可以變成\r\n\r\n```\r\n    __+__\r\n   /     \\\r\n  1       1\r\n```\r\n\r\n### Executor\r\n\r\n就負責執行上面的Binary Tree，看中間的operator是什麼來進行操作","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkane50613%2Fkcalculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkane50613%2Fkcalculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkane50613%2Fkcalculator/lists"}