{"id":13670919,"url":"https://github.com/vczh/tinymoe","last_synced_at":"2025-04-04T08:05:34.803Z","repository":{"id":12746955,"uuid":"15420094","full_name":"vczh/tinymoe","owner":"vczh","description":"English-like dynamic typing programming language","archived":false,"fork":false,"pushed_at":"2019-10-16T00:12:06.000Z","size":4394,"stargazers_count":925,"open_issues_count":0,"forks_count":195,"subscribers_count":142,"default_branch":"master","last_synced_at":"2025-03-28T07:04:22.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/vczh.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}},"created_at":"2013-12-24T14:41:18.000Z","updated_at":"2025-03-15T06:53:25.000Z","dependencies_parsed_at":"2022-09-05T20:10:17.269Z","dependency_job_id":null,"html_url":"https://github.com/vczh/tinymoe","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/vczh%2Ftinymoe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vczh%2Ftinymoe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vczh%2Ftinymoe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vczh%2Ftinymoe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vczh","download_url":"https://codeload.github.com/vczh/tinymoe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247141297,"owners_count":20890626,"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":[],"created_at":"2024-08-02T09:00:53.311Z","updated_at":"2025-04-04T08:05:34.757Z","avatar_url":"https://github.com/vczh.png","language":"C++","readme":"tinymoe\n=======\n### English-like programming language\n###### For DSL (Domain Specific Language) building and embedding, with dynamic typing, multiple dispatching and build-in continuation.\n\nHere are several samples to introduce this language:\n\n#### Hello world\n\n\tmodule hello world\n\tusing standard library\n\n\tsentence print (message)\n\t\tredirect to \"printf\"\n\tend\n\t\n\tphrase sum from (start) to (end)\n\t\tset the result to 0\n\t\trepeat with the current number from start to end\n\t\t\tadd the current number to the result\n\t\tend\n\tend\n\t\n\tphrase main\n\t\tprint \"1+ ... +100 = \" \u0026 sum from 1 to 100\n\tend\n\n#### Geometry (Multiple dispatching)\n\n\tmodule geometry\n\tusing standard library\n\n\tphrase square root of (number)\n\t\tredirect to \"Sqrt\"\n\tend\n\n\tsentence print (message)\n\t\tredirect to \"Print\"\n\tend\n\n\ttype rectangle\n\t\twidth\n\t\theight\n\tend\n\n\ttype triangle\n\t\ta\n\t\tb\n\t\tc\n\tend\n\n\ttype circle\n\t\tradius\n\tend\n\n\tphrase area of (shape)\n\t\traise \"This is not a shape.\"\n\tend\n\n\tphrase area of (shape : rectangle)\n\t\tset the result to field width of shape * field height of shape\n\tend\n\n\tphrase area of (shape : triangle)\n\t\tset a to field a of shape\n\t\tset b to field b of shape\n\t\tset c to field c of shape\n\t\tset p to (a + b + c) / 2\n\t\tset the result to square root of (p * (p - a) * (p - b) * (p - c))\n\tend\n\n\tphrase area of (shape : circle)\n\t\tset r to field radius of shape\n\t\tset the result to r * r * 22/7\n\tend\n\n\tphrase (a) and (b) are the same shape\n\t\tset the result to false\n\tend\n\n\tphrase (a : rectangle) and (b : rectangle) are the same shape\n\t\tset the result to true\n\tend\n\n\tphrase (a : triangle) and (b : triangle) are the same shape\n\t\tset the result to true\n\tend\n\n\tphrase (a : circle) and (b : circle) are the same shape\n\t\tset the result to true\n\tend\n\n\tphrase main\n\t\tset shape one to new triangle of (2, 3, 4)\n\t\tset shape two to new rectangle of (1, 2)\n\t\tif shape one and shape two are the same shape\n\t\t\tprint \"This world is mad!\"\n\t\telse\n\t\t\tprint \"Triangle and rectangle are not the same shape!\"\n\t\tend\n\tend\n\n#### Make your own \"yield return\" (coroutine)\n\n\tmodule enumerable\n\tusing standard library\n\n\tsymbol yielding return\n\tsymbol yielding break\n \n\ttype enumerable collection\n\t\tbody\n\tend\n \n\ttype collection enumerator\n\t\tvalue\n\t\tcoroutine\n\tend\n \n\tcps (state) (continuation)\n\tcategory\n\t\tinside ENUMERATING\n\tsentence yield return (value)\n\t\tpause coroutine to yielding return with continuation and value\n\tend\n\n\tcps (state) (continuation)\n\tcategory\n\t\tinside ENUMERATING\n\tsentence yield break\n\t\tpause coroutine to yielding break with continuation and null\n\tend\n \n\tphrase new enumerator from (enumerable)\n\t\tset coroutine to new coroutine from (field body of enumerable)\n\t\tset the result to new collection enumerator of (null, coroutine)\n\tend\n\n\tcps (state) (continuation)\n\tsentence move (enumerator) to the next\n\t\tset coroutine to field coroutine of enumerator\n\t\tif not (coroutine coroutine stopped)\n\t\t\trun coroutine coroutine\n\n\t\t\tselect field flag of state\n\t\t\t\tcase yielding return\n\t\t\t\t\tset field value of enumerator to field argument of state\n\t\t\t\t\tcontinue coroutine coroutine\n\t\t\t\tcase yielding break\n\t\t\t\t\tset field value of enumerator to null\n\t\t\t\t\tstop coroutine coroutine\n\t\t\t\tcase null\n\t\t\t\t\tset field value of enumerator to null\n\t\t\t\t\tstop coroutine coroutine\n\t\t\t\tcase else\n\t\t\t\t\tfall into the previous trap\n\t\t\tend\n\t\tend\n\tend\n \n\tphrase (enumerator) reaches the end\n\t\tset the result to coroutine field coroutine of enumerator stopped\n\tend\n\n\tphrase current value of (enumerator)\n\t\tset the result to field value of (field value of enumerator)\n\tend\n \n\tcps (state)\n\tcategory\n\t\tstart ENUMERATING\n\t\tclosable\n\tblock (body) create enumerable to (assignable receiver)\n\t\tset receiver to new enumerable collection of ()\n\t\tset field body of receiver to body\n\tend\n\n\tblock (sentence deal with (item)) repeat with (argument item) in (items : enumerable collection)\n\t\tset enumerator to new enumerator from items\n\t\trepeat while not (enumerator reaches the end)\n\t\t\tmove enumerator to the next\n\t\t\tdeal with current value of enumerator\n\t\tend\n\tend\n\n\tsentence print (message)\n\t\tredirect to \"Print\"\n\tend\n \n\tphrase main\n\t\tcreate enumerable to numbers\n\t\t\trepeat with i from 1 to 10\n\t\t\t\tprint \"Enumerating \" \u0026 i\n\t\t\t\tyield return i\n\t\t\tend\n\t\tend\n    \n\t\trepeat with number in numbers\n\t\t\tif number \u003e= 5\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tprint \"Printing \" \u0026 number\n\t\tend\n\tend\n\n#### Make your tinymoe-unit (Unit test and assertion)\n\n\tmodule unit test\n\tusing standard library\n\n\tsentence print (message)\n\t\tredirect to \"Print\"\n\tend\n\n\tblock (sentence run the test case) test case (name)\n\t\ttry\n\t\t\trun the test case\n\t\t\tprint \"PASS: \" \u0026 name\n\t\tcatch exception\n\t\t\tselect exception\n\t\t\t\tcase \"AssertionFailure\"\n\t\t\t\t\tprint \"FAIL: \" \u0026 name\n\t\t\t\tcase else\n\t\t\t\t\tprint \"HALT: \" \u0026 name\n\t\t\tend\n\t\tend\n\tend\n\n\tsentence assert (actual value) should be (expected value)\n\t\tif actual value \u003c\u003e expected value\n\t\t\tassert fail\n\t\tend\n\tend\n\n\tsentence assert fail\n\t\traise \"AssertionFailure\"\n\tend\n\n\tphrase main\n\t\ttest case \"1+1=2\"\n\t\t\tassert (1 + 1) should be 2\n\t\tend\n\tend\n","funding_links":[],"categories":["C++","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvczh%2Ftinymoe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvczh%2Ftinymoe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvczh%2Ftinymoe/lists"}