{"id":31835006,"url":"https://github.com/inblossoms/toyscript","last_synced_at":"2025-10-12T00:50:29.291Z","repository":{"id":205798217,"uuid":"711953205","full_name":"inblossoms/toyscript","owner":"inblossoms","description":"Implement a toy Js based on computer language morphology.","archived":false,"fork":false,"pushed_at":"2023-12-09T12:26:17.000Z","size":173,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-12-09T13:29:21.740Z","etag":null,"topics":["javascript","javascript-library","language-model"],"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/inblossoms.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,"roadmap":null,"authors":null}},"created_at":"2023-10-30T14:02:03.000Z","updated_at":"2023-12-20T16:38:54.534Z","dependencies_parsed_at":"2023-12-20T16:50:31.630Z","dependency_job_id":null,"html_url":"https://github.com/inblossoms/toyscript","commit_stats":null,"previous_names":["inblossoms/toy-js","inblossoms/toy-javascript","inblossoms/toyscript"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/inblossoms/toyscript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inblossoms%2Ftoyscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inblossoms%2Ftoyscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inblossoms%2Ftoyscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inblossoms%2Ftoyscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inblossoms","download_url":"https://codeload.github.com/inblossoms/toyscript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inblossoms%2Ftoyscript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009504,"owners_count":26084609,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":["javascript","javascript-library","language-model"],"created_at":"2025-10-12T00:50:25.311Z","updated_at":"2025-10-12T00:50:29.283Z","avatar_url":"https://github.com/inblossoms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Language learning methodology\r\n\r\n#### In fact, what I want to express is that the logic behind the language is the same, and we can use any language to achieve everything we want to express in this repo.\r\n\r\n**In a computer language, as long as there are three kinds of logic,\r\nsequential execution logic, branch logic and loop logic,\r\nthe language can reach the Turing-complete state.**\r\n\r\n\u003e toy-js will be based on our own custom semantics in the `Language.md`.\r\n\u003e\r\n\u003e You need to understand the lexical definition of computer language before you can understand the program.\r\n\u003e You can also use `Language.md` to help you get a better understanding based on [MDN - lexical grammar](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Lexical_grammar) grammar.\r\n\r\n**Tip:** You should test by adhering to the content of the code block, otherwise unexpected errors will occur.\r\nThese bugs are often features that are not currently implemented.\r\nOf course you can try to achieve it.\r\n\r\n### what toy-js can do?\r\n\r\nyou can write the following code in the textarea \r\nand view the result after execution in the console.\r\n\r\n\r\n1. logic And(\u0026\u0026)、Or(||):\r\n\r\n```js\r\n// and \u0026\u0026\r\nfalse \u0026\u0026 1;\r\nundefined \u0026\u0026 1;\r\n\"\" \u0026\u0026 1;\r\n0 \u0026\u0026 1;\r\n1 \u0026\u0026 0; \r\n\r\n// or ||\r\n3 || 1;\r\nundefined || 1;\r\n// 略...\r\n```\r\n\r\n2. declaration of variables、object and functions:\r\n\r\n- `var a; a = 1; a;`\r\n\r\n3. gets the object property value:\r\n\r\n- `o = { num: 1 }; o.num;`\r\n\r\n4. four operations:\r\n\r\n```js\r\n// +\r\na = 6;\r\na = a + 2;\r\na;\r\n\r\n// -\r\na = 6;\r\na = a - 2;\r\na;\r\n// *\r\na = 6;\r\na = a * 2;\r\na;\r\n\r\n// /\r\na = 6;\r\na = a / 2;\r\na;\r\n```\r\n\r\n5. branch logic\r\nYou can use all the false values supported in Js as a condition for if.\r\n\r\n```js\r\na = 1;\r\nif(a) a = 2;\r\n// or\r\nif(a) {\r\n  a = 2;\r\n}\r\na;\r\n```\r\n6. loop logic\r\nYou can use all the false values supported in Js as a condition for while.\r\n\r\n```js\r\na = 10;\r\nwhile(a)\r\n  a = a - 1;\r\n// or\r\nwhile(a){\r\n  a = a - 1;\r\n}\r\n// or\r\nwhile(a){\r\n  a = a - 1;\r\n  continue; // or break;\r\n  a = a - 100;\r\n}\r\na;\r\n```\r\n7. block scope chain\r\n```js\r\n{\r\n  let a;\r\n  a = 1;\r\n  {\r\n    let b;\r\n    a = a + 1;\r\n    b = 10;\r\n    {\r\n      b =  b / 2;\r\n    }\r\n  }\r\n}\r\n// 此时无法在外部访问 a 和 b\r\n\r\n// or\r\n{\r\n  let a;\r\n  a = 1;\r\n  {\r\n    let a;\r\n    a = 100;\r\n  }\r\n  a; // 1\r\n}\r\n\r\n```\r\n\r\n\r\n8.  function declaration and call\r\n```js\r\n// log(); method is equivalent to console.log();\r\nlet x;\r\nx = 1;\r\nfunction a(){\r\n  log(x);\r\n}\r\n{\r\n  let x;\r\n  x = 2;\r\n  a();\r\n}\r\n\r\n// or\r\n\r\nlog(1, 2, 3);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finblossoms%2Ftoyscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finblossoms%2Ftoyscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finblossoms%2Ftoyscript/lists"}