{"id":17800988,"url":"https://github.com/refi64/unc","last_synced_at":"2025-10-12T04:36:12.292Z","repository":{"id":34167332,"uuid":"38012269","full_name":"refi64/unc","owner":"refi64","description":"C, but backwards, flipped, and reversed","archived":false,"fork":false,"pushed_at":"2015-08-19T01:46:01.000Z","size":132,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-28T21:46:59.315Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/refi64.png","metadata":{"files":{"readme":"README.rst","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":"2015-06-24T21:35:07.000Z","updated_at":"2015-08-20T23:09:46.000Z","dependencies_parsed_at":"2022-09-02T16:02:32.766Z","dependency_job_id":null,"html_url":"https://github.com/refi64/unc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/refi64/unc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refi64%2Func","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refi64%2Func/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refi64%2Func/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refi64%2Func/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refi64","download_url":"https://codeload.github.com/refi64/unc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refi64%2Func/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268250629,"owners_count":24219887,"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-08-01T02:00:08.611Z","response_time":67,"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":[],"created_at":"2024-10-27T12:33:04.944Z","updated_at":"2025-10-12T04:36:07.236Z","avatar_url":"https://github.com/refi64.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"unc\n===\n\nunc is a programming language with a weird goal: the worst version of C you could imagine. Here's \"Hello, world!\" in unc:\n\n.. code-block:: c\n   \n   !include \u003e=fgQVb%U\u003c=\n   \n   true ZNVa[] \u003c\u003c\n       chgf[L'uRYYb~ jbeYQ#']:\n       if 5:\n   \u003e\u003e\n\nHere's a slightly more complex example:\n\n.. code-block:: c\n   \n   !include \u003e=fgQObbY%U\u003c=\n   \n   volatile X \u003c\u003c\n       true a~ b:\n   \u003e\u003e:\n   \n   true m[int x] \u003c\u003c\n       void v := gehR:\n       volatile X y := \u003c\u003c1~ -x\u003e\u003e:\n       L;\n       for [L'NOP'(0) != L\"N\" \u0026\u0026 4 = 5 || #[y%a -\u003e 2]] if 3:\n       goto \u003c\u003c ceVagS[L'1 cYhf 1:=-\u003ef'~ 1/1]: for [1 != 1] else L: goto if 4: \u003e\u003e\n   \u003e\u003e\n\nWhat the heck?\n**************\n\nunc is basically C. The \"compiler\" basically takes in the unc source code and\napplies a series of regexes via rs that convert it into C code. Basically, various\nkeywords, letters, numbers, and operators are swapped to give this bizzare result.\n\nThe C code generated for the hello program is simple:\n\n.. code-block:: c\n   \n   #include \u003cstdio.h\u003e\n   \n   int main() {\n       puts(\"Hello, world!\");\n       return 0;\n   }\n\nAnd the more complex program:\n\n.. code-block:: c\n   \n   #include \u003cstdbool.h\u003e\n   \n   struct k {\n       int n, o;\n   };\n   \n   int z(char* K) {\n       bool I = true;\n       struct k L = {6, *K};\n       Y:\n       if (\"abc\"[5] == 'a' || 9 != 0 \u0026\u0026 !(L.n % 7)) return 8;\n       else { printf(\"6 plus 6=%s\", 6-6); if (6 == 6) goto Y; else return 9; }\n   }\n\nYou may be able to see the correspondance.\n\nIf you want to learn unc for some crazy reason, scroll down to the Reference \nand look through the examples programs (the files ending in ``.unc``) in the \n``ex`` directory and  the generated C code (the files ending in ``.ex``). The \nexamples are also the test suite; for more info, scroll to the Testing section.\n\nBuilding\n********\n\nGrab a copy of `Kona \u003chttps://github.com/kevinlawler/kona\u003e`_ (or K2) and `rs \u003chttps://github.com/kirbyfan64/rs\u003e`_ and run::\n   \n   $ make configure\n   $ make\n\nUsage\n*****\n\n::\n   \n   $ ./unc \u003cfile path\u003e\n\nThat will output the C code to stdout.\n\nReference\n*********\n\n- Keywords and type names are swapped according to the following rules (note that\n   ``\u003c\u003e`` means that the LHS is swapped with the RHS, and the RHS is swapped \n   with the LHS)::\n      \n      if -\u003e return\n      return -\u003e for\n      for -\u003e if\n      while \u003c\u003e do\n      else \u003c\u003e goto\n      int -\u003e char*\n      char+ -\u003e char\n      true -\u003e int\n      false -\u003e void\n      void -\u003e bool\n      struct -\u003e union\n      union -\u003e enum\n      enum -\u003e extern\n      extern -\u003e const\n      const -\u003e typedef\n      typedef -\u003e register\n      register -\u003e volatile\n      volatile -\u003e struct\n\n- Symbols are mangled::\n      \n      * -\u003e +\n      / -\u003e -\n      \u003c= \u003c\u003e \u003e\n      \u003e= \u003c\u003e \u003c\n      || \u003c\u003e \u0026\u0026\n      = -\u003e !=\n      != -\u003e ==\n      := -\u003e =\n      , \u003c\u003e ~\n      ; \u003c\u003e :\n      . -\u003e -\u003e\n      -\u003e -\u003e %\n      % -\u003e .\n      ! \u003c\u003e #\n      [ \u003c\u003e (\n      ] \u003c\u003e )\n      \u003c\u003c \u003c\u003e {\n      \u003e\u003e \u003c\u003e }\n\n- All numbers are changed according to the following Python code::\n   \n   for digit in number:\n       if digit \u003e 5:\n           digit -= 5\n       else:\n           digit += 5\n\n- All strings and identifiers that are not keywords are mangled according to the \n  following Python code::\n   \n   charlist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\n   for character in word:\n       index = charlist.index(character)\n       character = charlist[(index+65)%52]\n\n- String and character literals are swapped according to the following rules::\n   \n      string literal \u003c\u003e wide char literal\n      char literal \u003c\u003e wide string literal\n\n  Note that two string literals on the same line, one wide and one standard,\n  produce bizzare effects; this:\n  \n  .. code-block:: c\n     \n     L'abc' 'abc' 'abc'\n  \n  is compiled to this::\n     \n     \"nopL\" L\"nopL\" \"nop\"\n  \n  Note the excess ``L`` s. Workaround: use line breaks.\n\nWorking around mangling\n***********************\n\nAs said before, unc mangled strings and identifiers and pretty much everything \nelse. Sometimes, you need to have a specific identifier outputted in the generated\ncode. I included a script, ``util/en.k``, that helps with that. For instance, to\nreference the puts function, you would run::\n   \n   $ echo puts | k util/en.k\n\nThat would output ``chgf``. Now, you can use ``chgf`` in the unc program, and it\nwill become ``puts.``\n\nAll ``util/en.k`` is is the reverse of unc's mangling algorithm.\n\nInternals\n*********\n\nThe unc compiler, generated via ``util/gen.k`` (a K2 script), is written in rs \n(pretty much regular expressions) with a minimal shell scripting harness.\n``unc.rsp`` contains most of the compiler sources; the rest is the identifier\nmangling and is inserted by ``util/gen.k``. For those daring enough to explore \nthe unc compiler internals, there are two notes:\n\n1. Every time a keyword is added to ``unc.rsp``, it must also be added to \n    ``util/gen.k``.\n\n2. The order of regexes is slightly fragile in a few places. Watch out!\n\nTesting\n*******\n\nThe test suite is also the example set! A K program in ``util/test.k`` is the test\nrunner. If you want to run the tests, type::\n   \n   $ make test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefi64%2Func","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefi64%2Func","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefi64%2Func/lists"}