{"id":21683725,"url":"https://github.com/akutchi/cpyc","last_synced_at":"2026-05-10T17:04:39.412Z","repository":{"id":221896487,"uuid":"755595241","full_name":"Akutchi/CPyC","owner":"Akutchi","description":"A Simple C to Python Converter written in Ada","archived":false,"fork":false,"pushed_at":"2024-02-25T10:37:26.000Z","size":424,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-25T11:42:31.638Z","etag":null,"topics":["ada","c","parser","python3"],"latest_commit_sha":null,"homepage":"","language":"Ada","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/Akutchi.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-10T17:30:31.000Z","updated_at":"2024-08-23T11:02:43.000Z","dependencies_parsed_at":"2024-02-23T13:30:08.481Z","dependency_job_id":"e59b067d-6dc7-40ed-9add-808c1bf84127","html_url":"https://github.com/Akutchi/CPyC","commit_stats":null,"previous_names":["akutchi/cpyc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akutchi%2FCPyC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akutchi%2FCPyC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akutchi%2FCPyC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akutchi%2FCPyC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Akutchi","download_url":"https://codeload.github.com/Akutchi/CPyC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244601871,"owners_count":20479516,"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":["ada","c","parser","python3"],"created_at":"2024-11-25T16:13:10.768Z","updated_at":"2026-05-10T17:04:39.366Z","avatar_url":"https://github.com/Akutchi.png","language":"Ada","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPyC\n\nThis is a simple C to Python converter.\n\nThe goals of this project are numerous.\nFirst, this project more or less came from my desire to learn more about Ada.\nAs such, there might be more efficient ways to do things; but - at this point in\ntime - I am not aware of them.\nSecond, the scope of the project will only be - at most - to manage parsing\nfunctions. That is to say, I will try to translate the following elements :\n- Variables Structures\n- Control Flow\n- Loops (for and while only)\n- Functions\n\nI will repeat it just in case, _I do not have the desire to create a full parser,\nnor do I absolutely want my solution to be exhaustive or efficient_. First off,\nI don't really have the time for that. Second, while I try to do things correctly\nby creating a little bit of structure (see UML diagram below), I am well aware\nthat this is something that I code as I think about it mostly. That is to say,\nit is more or less on the fly than anything (well, I do have some notions about\nparsing; but hey.)\n\n# Structure\n\n![Structure of the code](./doc/Structure.png)\n\n# Changelog\n\n## 25/02/24 (fixing bugs):\n\n- Parser I. done. the main call is now only generated if a main function exist\n- Error I. fixed. I just didn't check for string termination and in some cases it just worked.\n- Error II.fixed. I was creating variables by taking the last element of the splited row by whitespace. Obviously doesn't work with multiple args.\n\ne.g :\n| ![C code](./doc/C_Code_25_02_24.png) |\n|:--:|\n| *C code* |\n\n| ![Python code](./doc/Python_Gen_25_02_24.png) |\n|:--:|\n| *Python code Generation* |\n\n## 23/02/24 :\n\nwith T\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: int; \\\nwith Value\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [0-9]+ \\\nwith Variable\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [\\w_]+ \\\nwith Op\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [+-*/]\n\nwith S :\u0026nbsp;\u0026nbsp;\u0026nbsp;Value\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;| \\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Variable | \\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;S Op S\n\nwith E1 : (\\\u003cT\\\u003e) Variable (= S); \\\nwith Ret: return S;\n\nwith Prefix\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: T  (I will add \"if\" etc. later) \\\nwith Struct_Name\u0026nbsp;\u0026nbsp;: \\w+\n\nwith Potential_Args : (\\w+)? | ((\\w+,)+)\\w+ \\\nwith Args\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: ( Potential_Args )\n\nwith Stmt : E1\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;| \\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Ret\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;|\\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Struct \\\nwith Body : Stmt*\\\nWith Struct : Prefix Struct_Name Args { Body }\n\n\nThe Program can now generate structure of the form Struct or E1\n\ne.g :\n| ![C code](./doc/C_Code_23_02_24.png) |\n|:--:|\n| *C code* |\n\n| ![Python code](./doc/Python_Gen_23_02_24.png) |\n|:--:|\n| *Python code Generation* |\n\n### Note :\n\n- The note of 20/02 still holds.\n- Moreover, \"main()\" is automatically generated whether a function of the same name is found. Will need to generate it only if such a function is found. (P.I.)\n- As of now, calls in expressions are not recognized and will crash the parser. (P.II.)\n\n- Error when parsing (i\\*j)+(a*b) (E.I.)\n- Cannot parse f(2, 3) (E.II.)\n  \n## 20/02/24 :\n\nwith T\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: int; \\\nwith Value\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [0-9]+ \\\nwith Variable\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [\\w_]+ \\\nwith Op\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [+-*/]\n\nwith S :\u0026nbsp;\u0026nbsp;\u0026nbsp;Value\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;| \\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Variable | \\\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;S Op S\n\nwith E1 : (T) Variable (= S);\n\nThe Program can now generate variable structure of the form E1\n\ne.g :\n| ![C code](./doc/C_Variables_20_02_24.png) |\n|:--:|\n| *C code* |\n\n| ![Python code](./doc/Python_Gen_20_02_24.png) |\n|:--:|\n| *Python code Generation* |\n\n### Note :\nI am well aware that variable name and values are enclosed in parenthesis as of\nright now and I am currently hesitating as to what to do about it. Do I leave it\nfor the post-processing or do I want to tackle it during the printing process.\nPart of me is slightly curving towards post-proc' as it is \"another\" task that\nthe printer should not worry about.\n\n## 18/02/24 :\n\nwith T\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: int; \\\nwith Value\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [0-9]+ \\\nwith Variable\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;: [\\w_]+\n\nwith E : (T) Variable (= Value);\n\nThe Program can now generate variable structure of the form of E\n\ngeneration table :\n\n| C           | Python |\n|-------------|--------|\n| int i = 23; | i = 23 |\n| int j;      | j = 0  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakutchi%2Fcpyc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakutchi%2Fcpyc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakutchi%2Fcpyc/lists"}