{"id":24702267,"url":"https://github.com/brainiac2677/cse310-compiler","last_synced_at":"2025-10-09T05:40:17.531Z","repository":{"id":182712138,"uuid":"572514733","full_name":"BRAINIAC2677/CSE310-Compiler","owner":"BRAINIAC2677","description":"A compiler for limited syntax of c. Part of course works of CSE310.","archived":false,"fork":false,"pushed_at":"2023-07-21T03:32:08.000Z","size":6857,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T04:26:29.213Z","etag":null,"topics":["bison","c","compiler","context-free-grammar","flex"],"latest_commit_sha":null,"homepage":"","language":"Yacc","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/BRAINIAC2677.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":"2022-11-30T12:48:05.000Z","updated_at":"2024-04-02T17:40:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e8aed67-2b27-4ec6-a36b-e91dd828a820","html_url":"https://github.com/BRAINIAC2677/CSE310-Compiler","commit_stats":null,"previous_names":["brainiac2677/cse310-compiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BRAINIAC2677/CSE310-Compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BRAINIAC2677%2FCSE310-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BRAINIAC2677%2FCSE310-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BRAINIAC2677%2FCSE310-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BRAINIAC2677%2FCSE310-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BRAINIAC2677","download_url":"https://codeload.github.com/BRAINIAC2677/CSE310-Compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BRAINIAC2677%2FCSE310-Compiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269814001,"owners_count":24479342,"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-10T02:00:08.965Z","response_time":71,"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":["bison","c","compiler","context-free-grammar","flex"],"created_at":"2025-01-27T05:39:45.391Z","updated_at":"2025-10-09T05:40:12.502Z","avatar_url":"https://github.com/BRAINIAC2677.png","language":"Yacc","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSE310 | Compiler\n\n## Assignment Specifications\n- [x] [Assignment 1](/assignment_specs/offline-1.pdf)\n- [x] [Assignment 2](/assignment_specs/offline-2.pdf)\n- [x] [Assignment 3](/assignment_specs/offline-3.pdf)\n\n_*But I have broken the assignments into 5 stages and done some extensions in the last stage. You can run the generated assembly of stage 5 and 6 in a 8086 assembly emulator.*_\n\n## Stages \n- [x] [Lexical Analysis](/01-lexical_analyzer/)\n- [x] [Adding Grammar Rules](/02-adding_grammar_rules/)\n- [x] [Syntaxt Analysis](/03-symboltable_and_parsetree/) | Symbol Table and Parse Tree\n- [x] [Semantic Analysis](/04-semantic_analysis/) \n- [x] [Code Generation](/05-code_generation/) | Generating Assembly Code\n- [x] [Extension](/06-extension/) | Covering more syntax\n\n## How to run on Linux\n- Install `flex` and `bison` using \n\u003e sudo apt install flex bison\n- Install `gcc` using\n\u003e sudo apt install gcc\n- Clone the repo using git clone or download the zip file.\n- Go to the directory of the stage you want to run.\n- Run the following commands\n\u003e make run  \n- After compilation you will be prompted to enter the input file name. Check out the [example input files](/example_ios/). \n- The input file should be \n    - In the same directory as the stage directory\n    - Have the syntax supported by this [context free grammar](/assets/cfg.pdf)\n- The output will be generated in the same directory as the stage directory.\n- To clean the directory run\n\u003e make clean\n\n## Example Input/Output \n- Lexical Analysis\n    - [input](/example_ios/stage01/input.c)\n    - [output](/example_ios/stage01/output.txt) | tokens\n- Adding Grammar Rules\n    - [input](/example_ios/stage02/input.c)\n- Syntax Analysis\n    - [input](/example_ios/stage03/input.c)\n    - [output](/example_ios/stage03/parsetree.txt) | parse tree\n- Semantic Analysis\n    - [input](/example_ios/stage04/input.c)\n    - [output 1](/example_ios/stage04/errors.txt) | semantic errors\n    - [output 2](/example_ios/stage04/parsetree.txt) | parse tree \n- Code Generation\n    - [input](/example_ios/stage05/input.c)\n    - [output 1](/example_ios/stage05/assembly_code.asm) | assembly code\n    - [output 2](/example_ios/stage05/optimized_assembly_code.txt) | optimized assembly code\n- Extension\n    - [input](/example_ios/stage06/input.c)\n    - [output 1](/example_ios/stage06/assembly_code.asm) | assembly code\n    - [output 2](/example_ios/stage06/optimized_assembly_code.txt) | optimized assembly code\n\n\n## Resources: \n- [github repo | c-compiler](https://github.com/AnjaneyaTripathi/c-compiler)\n- [compiler-explorer](https://godbolt.org/)\n- [Tutorial on LEX and internal working of lex](https://rjtjdm.medium.com/tutorial-on-lex-and-internal-working-of-lex-5537c063ee#:~:text=Alternatively%20we%20can%20use%20%25option,define%20yywrap%20internally%20by%20lex.\u0026text=There%20are%20majorly%20three%20type%20of%20variables%20in%20lex.\u0026text=yyin%20is%20a%20variable%20of,character%20stream%20from%20that%20file.)\n\n## Relevant QnA\n- [Why separate class definition and implementation in different files?](http://www.math.uaa.alaska.edu/~afkjm/csce211/handouts/SeparateCompilation.pdf)\n- [Declaring variables in header files c++](https://stackoverflow.com/a/38942057/13148347)\n- [munmap_chunk(): invalid pointer](https://stackoverflow.com/questions/32118545/munmap-chunk-invalid-pointer)\n\n- [%option noinput nounput: what are they for?](https://stackoverflow.com/a/39083223/13148347)\n- [Circular dependency](https://stackoverflow.com/questions/64085054/error-class-name-does-not-name-a-type-in-c)\n\n## Tools\n- [regexr](https://regexr.com/) | regex tester","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainiac2677%2Fcse310-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainiac2677%2Fcse310-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainiac2677%2Fcse310-compiler/lists"}