{"id":18736080,"url":"https://github.com/wangziqi2013/cfront","last_synced_at":"2025-04-12T19:21:36.879Z","repository":{"id":107077743,"uuid":"65691885","full_name":"wangziqi2013/CFront","owner":"wangziqi2013","description":"A C language parser built from the scratch, without using compiler generator.","archived":false,"fork":false,"pushed_at":"2022-12-31T01:51:35.000Z","size":1432,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T13:38:25.760Z","etag":null,"topics":["c","compiler-frontend","lr-parser","operator-precedence-parser"],"latest_commit_sha":null,"homepage":"","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/wangziqi2013.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":"2016-08-14T23:58:09.000Z","updated_at":"2024-12-17T23:16:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0399c9f-3a25-4590-8c07-232d14e79bd2","html_url":"https://github.com/wangziqi2013/CFront","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/wangziqi2013%2FCFront","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangziqi2013%2FCFront/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangziqi2013%2FCFront/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangziqi2013%2FCFront/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangziqi2013","download_url":"https://codeload.github.com/wangziqi2013/CFront/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618699,"owners_count":21134284,"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":["c","compiler-frontend","lr-parser","operator-precedence-parser"],"created_at":"2024-11-07T15:19:14.593Z","updated_at":"2025-04-12T19:21:36.844Z","avatar_url":"https://github.com/wangziqi2013.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CFront    \nThe goal of this project is to build a C compiler from the scratch without using any third-party code except standard C library.   \n            \n# Directory Structure\n[./src](https://github.com/wangziqi2013/CFront/tree/master/src) - Main source directory   \n          \n[./src/test](https://github.com/wangziqi2013/CFront/tree/master/src/test) - Unit tests and functional tests\n      \n[./src/old](https://github.com/wangziqi2013/CFront/tree/master/src/old) - Deprecated code. Only for demonstration purposes.\n \n[./src/python](https://github.com/wangziqi2013/CFront/tree/master/src/python) - A LL(1)/LR(1)/LALR(1) compiler generator implemented in Python  \n\n# Source File Description\n\n## Main Files\n\n./src/token.c: Implements lexical analysis and the token stream interface\n\n./src/parse_exp.c: Implements parsing interface and expression parsing. The entire parser is based on expression parsing, which uses a hand-coded shift-reduce parser with operator precedence.\n\n./src/parse_decl.c: Implements declaration parsing. It uses expression parsing to build declaration tree (in C language, declaration has exactly the same format as an expression).\n\n./src/parse_comp.c: Implements composite type declaration parsing, including struct, union and enum.\n\n./src/parse_stmt.c: Implements statement parsing.\n\n./src/parse.c: Implements top-level (global declaration, definition and function definition) parsing.\n\n./src/type.c: Implements the type system.\n\n./src/eval.c: Implements compile-time evaluation support, including constant evaluation, atoi, string to binary, etc.\n\n./src/cgen.c: Implements top-level code generation.\n   \n## Data Structure Files  \n \n./src/ast.c: Implements abstract syntax tree. We use left-child right-sibling organization for trees.\n\n./src/str.c: Implements vector and string.\n\n./src/hashtable.c: Implements hash table. We use hash table as symbol tables for scopes.\n\n./src/bintree.c: Implements a simple binary search tree. We use binary search trees as indices for composite types.\n\n./src/list.c: Implements singly linked list.\n\n./src/stack.c: Implements a stack. We use stack to maintain scopes and to perform shift-reduce parsing.\n \n# Compile and Test\nTo compile, enter ./src directory, and type `make all` or just `make`. This will build object files for each source file, and link them with the tests.\n\nTo test, directly run binary under ./bin directory. Test source files are independent from each other (i.e. there is no mutral dependency), and should be rather straightforward to understand.\n\n# Contribution\nI only contribute to this project in my part-time. If you are interested in becoming a contributor feel free to drop me a message on Github.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangziqi2013%2Fcfront","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangziqi2013%2Fcfront","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangziqi2013%2Fcfront/lists"}