{"id":16627089,"url":"https://github.com/ttulka/cppc","last_synced_at":"2025-04-07T07:28:30.885Z","repository":{"id":236913275,"uuid":"793408849","full_name":"ttulka/cppc","owner":"ttulka","description":":..: (colon period period colon) esoteric programming language","archived":false,"fork":false,"pushed_at":"2024-06-13T10:25:32.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T22:46:24.081Z","etag":null,"topics":["colon-period-period-colon","esolang","esoteric-language","esoteric-programming-language","javascript","js","turing-complete"],"latest_commit_sha":null,"homepage":"https://esolangs.org/wiki/Colon_period_period_colon","language":"JavaScript","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/ttulka.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-04-29T07:02:59.000Z","updated_at":"2024-06-13T10:25:35.000Z","dependencies_parsed_at":"2024-04-29T08:25:50.504Z","dependency_job_id":"508a6c4b-25ef-4048-8b8e-bd33a2414741","html_url":"https://github.com/ttulka/cppc","commit_stats":null,"previous_names":["ttulka/cppc"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fcppc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fcppc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fcppc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fcppc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttulka","download_url":"https://codeload.github.com/ttulka/cppc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247610979,"owners_count":20966452,"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":["colon-period-period-colon","esolang","esoteric-language","esoteric-programming-language","javascript","js","turing-complete"],"created_at":"2024-10-12T04:13:19.026Z","updated_at":"2025-04-07T07:28:30.860Z","avatar_url":"https://github.com/ttulka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :..:\n\n:..: (colon period period colon) is an esoteric programming language\n based on the manipulation of four unbounded integer registers.\n\n## Language\n\n### Syntax\n\nA program in :..:\n\n1. Consists only of the symbols `:` (colon) and `.` (period); all other symbols are ignored.\n2. Is a sequence of 4-tuples that form program instructions (the program length % 4 == 0).\n3. Has a length greater than zero (at least one 4-tuple).\n\n### Semantics\n\n#### Registers\n\nEach 4-tuple reads or manipulates one of the four registers *A*, *B*, *C*, *D*.\n\nThe current register is determined by the index of the instruction in the program code.\n For instance, the first instruction works with *A*, fourth with *D*, fifth with *A*, and so on.\n\n#### Instructions\n\nFour possible instructions can be formed based on the position of the colon in a 4-tuple:\n\n| Instruction | Name | Meaning | Code |\n| :---------: | ---- | ------- | ---- |\n|   | Noop | Does nothing | `....` |\n| + | Increment | Increments the current register value | `.:..` |\n| - | Decrement | Decrements the current register value | `..:.` |\n| [ | Loop begin | Jumps to the loop end if the current register value is not zero | `:...` |\n| ] | Loop end | Jumps to the paring [ | `...:` |\n\nInstructions [ and ] are paired, meaning each [ must have a following ] and vice versa.\n\nInstructions can be combined into compact ones. For instance, the 4-tuple \n `::..` contains both instructions [ (loop begin) and + (increment). \n Compact instructions are executed in the order they appear in the 4-tuple.\n\n## Examples\n\n### No-op program\n\nDoes nothing:\n\n```cppc\n....\n```\n\n### Infinite loop\n\nLoops forever:\n\n```cppc\n:..:\n```\n\nAlternativelly:\n\n```cppc\n::::\n```\n\n### Clear\n\nSets register *A* to zero:\n\n```cppc\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. .... \n```\n\nThe program reads as follows: \n\n```\nC[ A[ C+ A+] A-] C-\n```\n\n### Move\n\nMoves register *B* to register *A*:\n\n```cppc\n.... .... :... ....\n.... :... .:.. ....\n.... .:.: .... ....\n.:.. ..:. ...: ....\n..:. ..:. ..:. ....\n```\n\nThe program reads as follows: \n\n```\nC[ B[ C+ B+] A+ B- C] A- B- C-\n```\n\n### Copy\n\nCopies register *A* to register *B*:\n\n```cppc\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:. .:.. .... .:.:\n.... ..:. ..:. ..:.\n.... .... :... :...\n.... .... .:.. .:.:\n.... .... .... ..:.\n.:.: .... .... ....\n..:. .... ..:. ....\n```\n\nThe program reads as follows: \n\n```\nC[ A[ C+ A+] A- B+ D+] B- C- D- \nC[ D[ C+ D+] D- A+] A- C-\n```\n\n### Switch\n\nSwitches register *A* with register *B*:\n\n```cppc\n.... .... :... ....\n::.. .... .:.: .:..\n..:: .... ..:. ..:.\n.... .... :... ....\n.... ::.. .:.: ....\n.:.. ..:: ..:. ....\n..:. .... :... ::..\n.... .... .:.: ..:.\n.... .:.: ..:. ....\n.... ..:. .... ....\n```\n\nThe program reads as follows: \n\n```\nC[ A[ A+ C+] D+ A-] C- D-   move A to D\nC[ B[ B+ C+] A+ B-] C- A-   move B to A\nC[ D[ D+ C+] D- B+] C- B-   move D to B\n```\n\n### Fibonacci sequence\n\nComputes the sequence in register *A*:\n\n```cppc\n.... .:.. :... ....\n.... .... :... ....\n::.. .... .:.: .:..\n..:: .... ..:. ..:.\n.... .... :... ....\n.... ::.. .:.: ....\n.:.. ..:: ..:. ....\n..:. .... :... ::..\n.... .... .:.: ..:.\n.... .:.: ..:. ....\n.... ..:. :... ....\n::.. .... .:.: .:..\n..:. .:.: ..:. ..:.\n.... ..:. :... ::..\n.... .... .:.: ..:.\n.:.: .... ..:. ....\n..:: .... .... ....\n```\n\nThe program reads as follows: \n\n```\nB+                              init 0 1 0 0\nC[                              loop forever\n    C[ A[ A+ C+] D+ A-] C- D-   move A to D\n    C[ B[ B+ C+] A+ B-] C- A-   move B to A\n    C[ D[ D+ C+] D- B+] C- B-   move D to B\n    C[ A[ A+ C+] D+ A- B+] C- D- B- \n    C[ D[ D+ C+] D- A+] C- A-   copy A to B\n]\n```\n\n### Hello World\n\nFor computing \"Hello World\" the numbers in the registers must be interpreted as letters.\n It can achieved by defining a simple alphabet:\n\n| Letter | Value |\n| :----: | :---: |\n| ` `    | 1     |\n| `d`    | 2     |\n| `e`    | 3     |\n| `H`    | 4     |\n| `l`    | 5     |\n| `o`    | 6     |\n| `r`    | 7     |\n| `W`    | 8     |\n\nThe following program sets A progressively to 4, 3, 5, 5, 6, 1, 8, 6, 7, 5, 2 which corresponds to \"Hello World\":\n\n```cppc\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n.:.. .... .... ....\n.:.. .... .... ....\n.... .... :... ....\n:... .... .:.. ....\n.:.: .... .... ....\n..:: .... ..:. ....\n```\n\nThe program reads as follows: \n\n```\nA+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+ A+ A+ A+\nC[ A[ C+ A+] A-] C-     clear A\nA+ A+\nC[ A[ C+ A+] A-] C-     clear A\n```\n\n## Turing completeness\n\nTo demonstrate that :..: is Turing-complete, we can utilize the structured program theorem,\n which asserts that sequence, selection, and repetition are adequate constructs\n to construct any computer program.\n\nThe proof (the folk version) is as follows (pseudocode):\n\n```\npc = 1\nwhile (pc \u003e 0) {\n    if (pc == 1) {\n        perform step \u003c1\u003e\n        pc = next step\n    }    \n    ...\n    if (pc == n) {\n        perform step \u003cn\u003e\n        pc = next step\n    }\n}\n```\n\nFirst, we define new  convenient flow control constructs for selection and repetition:\n\n| Construct | Name | Meaning |\n| --------- | ---- | ------- |\n| r(x)    | Repetition (WHILE) | Repeat *x* while register *r* is not zero |\n| r{x\\|y}  | Selection (IF-ELSE) | Execute *x* if register *r* is zero, *y* otherwise |\n\n```\nr(x) =\n\nr[ C+ r+] r-\nC[ r+ \u003cx\u003e r[ C+ r+] r-]\nC-\n```\n\n```\nr{x|y} =\n\nr[ \u003cx\u003e r+ C+] r-\nC[ r+ \u003cy\u003e C+]\nC-\n```\n\n(Because register *C* is used as auxiliary, *r* can only be *A*, *B*, or *D*.)\n\nHaving the selection and repetition in place, we can translate any program workflow into a :..: program.\n As an example, we will demonstrate a translation of a register machine, as register machines\n with just two registers were proven to be Turing equivalent.\n\nWe will use an instruction set of a *program machine*: INC/+, DEC/-, JZ/0\n (increment, decrement, jump if zero) with program registers *A* and *B*.\n\n(Registers *C* and *D* are auxiliary and must not be used by the simulated program.)\n\nAn example program for clearing register *A* and setting it to 1 reads as follows:\n\n```\nInstr.\n\n1.      (A0)\n       ↗ |  \\0\n       \\ ↓   \\\n2.      (A-)  |\n             /\n            ↙ \n3.      (A+)\n\n```\n\nThe corresponding :..: program is as follows:\n\n```\nD+      init pc (D) to 1\nD(      while pc \u003e 0\n                              found                       not found\n                ..................................    ..................\n    C[ D-       D[ A{ D+ D+ D+ | D+ D+ } C+ C+ D+] D- C[ D+ D+       C+] ] C-\n    C[ D- D-    D[ A- D+                 C+ C+ D+] D- C[ D+ D+ D+    C+] ] C-\n    C[ D- D- D- D[ A+                    C+ C+ D+] D- C[ D+ D+ D+ D+ C+] ] C-\n       ........    .....................    ..              ........\n       match pc    perform \u0026 update pc      break search    reset pc\n\n    C-  reset search\n)\n```\n\nWe use register *D* as the program counter (`pc`). \n In the main loop we search for the n-th instruction by decrementing *D* n times.\n If it matches, we perform the instruction, update the program counter, and\n break the search by setting *C* to one.\n\nThe :..: code reads as follows:\n\n```cppc\n.... .... .... .:..\n.... .... .... :...\n.... .... .:.. .:.:\n.... .... .... ..:.\n.... .... :... .:..\n.... .... :... ....\n.... .... .... ..:.\n.... .... .... :...\n:... .... .... ....\n.... .... .... .:..\n.... .... .... .:..\n.... .... .... .:..\n.:.. .... .:.: ....\n..:. .... :... ....\n.:.. .... .... ....\n.... .... .... .:..\n.... .... .... .:..\n.... .... .:.: ....\n.... .... ..:. ....\n.... .... .:.. ....\n.... .... .:.. ....\n.... .... .:.. ....\n.... .... .... .:.:\n.... .... .... ..:.\n.... .... :... .:..\n.... .... .... .:..\n.... .... .:.: ...:\n.... .... ..:. ....\n.... .... :... ....\n.... .... .... ..:.\n.... .... .... ..:.\n.... .... .... :...\n..:. .... .... .:..\n.... .... .:.. ....\n.... .... .:.. ....\n.... .... .... .:.:\n.... .... .... ..:.\n.... .... :... .:..\n.... .... .... .:..\n.... .... .... .:..\n.... .... .:.: ...:\n.... .... ..:. ....\n.... .... :... ....\n.... .... .... ..:.\n.... .... .... ..:.\n.... .... .... ..:.\n.... .... .... :...\n.:.. .... .... ....\n.... .... .:.. ....\n.... .... .:.. ....\n.... .... .... .:.:\n.... .... .... ..:.\n.... .... :... .:..\n.... .... .... .:..\n.... .... .... .:..\n.... .... .... .:..\n.... .... .:.: ...:\n.... .... ..:. ....\n.... .... ..:. ....\n.... .... .... :...\n.... .... .:.. .:.:\n.... .... .... ..::\n.... .... ..:. ....\n```\n\nSimilarly, we can easily translate any register machine to :..: proving it Turing-complete.\n\n## JavaScript interpreter\n\n```sh\nnpm i cppc\n```\n\n```js\nconst cppc = require('cppc')\n\n// [2, 0, 1, 1]\ncppc(`.:...:...:...:...:....:.`)\n\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fcppc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttulka%2Fcppc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fcppc/lists"}