{"id":16556699,"url":"https://github.com/xxrjun/compiler-fall23","last_synced_at":"2025-03-04T23:23:47.664Z","repository":{"id":213498550,"uuid":"698530093","full_name":"xxrjun/compiler-fall23","owner":"xxrjun","description":"NCU CSIE Compiler, 2023 Fall","archived":false,"fork":false,"pushed_at":"2023-12-21T07:58:40.000Z","size":12192,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T08:25:20.891Z","etag":null,"topics":["compiler","lex","ncu","parser","scanner","yacc"],"latest_commit_sha":null,"homepage":"","language":"C","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/xxrjun.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":"2023-09-30T07:24:54.000Z","updated_at":"2024-11-20T14:03:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a955b9d-aa4f-4908-b404-934442adf4fc","html_url":"https://github.com/xxrjun/compiler-fall23","commit_stats":null,"previous_names":["xxrjun/compiler-fall23"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxrjun%2Fcompiler-fall23","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxrjun%2Fcompiler-fall23/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxrjun%2Fcompiler-fall23/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xxrjun%2Fcompiler-fall23/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xxrjun","download_url":"https://codeload.github.com/xxrjun/compiler-fall23/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241936502,"owners_count":20045082,"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":["compiler","lex","ncu","parser","scanner","yacc"],"created_at":"2024-10-11T20:05:30.704Z","updated_at":"2025-03-04T23:23:47.656Z","avatar_url":"https://github.com/xxrjun.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NCU Compilers Fall 2023\n\n- [Run Tests Scripts Template](#run-tests-scripts-template)\n  - [Usage](#usage)\n  - [Sample output](#sample-output)\n  - [其他腳本](#其他腳本)\n- [C/C++ 指定版本指令](#cc-指定版本指令)\n- [Lex 指令](#lex-指令)\n- [Yacc \\\u0026 Lex 指令](#yacc--lex-指令)\n- [AC Screenshot](#ac-screenshot)\n\n## Run Tests Scripts Template\n\n此腳本會自動偵測作業系統，包含 Mac, Linux, Windows。此腳本會\n\n1. 編譯與執行程式\n2. 將程式輸出與測資輸出做比對\n3. 顯示測資結果\n4. 清空編譯產生的檔案\n\n檔案 [run_tests_template.sh](./run_tests_template.sh)\n\n### Usage\n\n更新腳本權限\n\n```bash\nchmod +x ./run_tests_template.sh\n```\n\n更新執行程式名稱以及測資資料夾名稱\n\n以以下檔案結構為例\n\n```bash\n|   matrix_calculator.l\n|   matrix_calculator.y\n|   run_tests.sh        # 測試腳本，包含編譯與執行測試，會清空編譯產生的檔案\n|   compile.sh          # 編譯腳本，僅編譯\n|\n\\---testcases           # 檔名是對應的，一個 .in 對一個 .out\n        1.in\n        1.out\n        3.in\n        3.out\n        5.in\n        5.out\n        7.in\n        7.out\n```\n\n```bash\nTEST_DIR=\"./testcases\" # TODO: Change this to your test directory\nPROGRAM_NAME=\"program\" # TODO: Change this to your program name\n```\n\n執行腳本\n\n```bash\n./run_tests_template.sh \n```\n\n### Sample output\n\nSample output 1\n\n\u003cdiv \u003e\n    \u003cimg src=\"./assets/run_test_script_console_all_passed.png\" width=\"80%\"\u003e\n\u003c/div\u003e\n\nSample output 2\n\n\u003cdiv\u003e\n    \u003cimg src=\"./assets/run_test_script_console_has_failed.png\" width=\"80%\"\u003e\n\u003c/div\u003e\n\n### 其他腳本\n\n- [compile_template.sh](./compile_template.sh) 編譯腳本，修改檔名即可使用。會依據系統使用不同編譯指令。此腳本僅進行編譯，不會清空編譯產生的檔案。此腳本可以彈性修改編譯指令。\n\n- [raw_compile_template.sh](./raw_compile_template.sh) 寫死編譯指令的腳本，方便複製貼上使用。\n\n## C/C++ 指定版本指令\n\nOn Mac\n\n```bash\ng++ --std=c++11\n```\n\nOn Windows\n\n```bash\ng++ --std=gnu++11\n```\n\n## Lex 指令\n\nOn M2 Mac (arm64)\n\n```bash\nlex -o lex.yy.c lex.l\ngcc -o lex lex.yy.c -ll\n```\n\nOn Windows\n\n```bash\nflex myLexProgram.l\nbison -d myYaccProgram.y\ngcc -o indent lex.yy.c\n```\n\n## Yacc \u0026 Lex 指令\n\nOn Mac\n\n```bash\nbison -d -o y.tab.c matrix_calculator.y\ngcc -c -g -I.. y.tab.c\nlex -o lex.yy.c matrix_calculator.l\ngcc -c -g -I.. lex.yy.c\ngcc -o matrix_calculator y.tab.o lex.yy.o -ll\n```\n\nOn Windows\n\n```bash\nbison -d -o y.tab.c matrix_calculator.y\ngcc -c -g -I.. y.tab.c\nflex -o lex.yy.c matrix_calculator.l\ngcc -c -g -I.. lex.yy.c\ngcc -o matrix_calculator y.tab.o lex.yy.o -ll\n```\n\nHow to deal with shift/reduce conflict? Use verbose mode to find out the problem.\n\n```bash\nbison -v matrix_calculator.y\n```\n\nIt will generate a file called `matrix_calculator.output` which contains the verbose information.\n\n\n\n\n## AC Screenshot\n\n\u003e 有些忘記截圖\n\n**2023 BA2**\n\n- BA2 Second Question\n- BA2 Book Information\n\n\u003cdiv\u003e\n    \u003cimg src=\"./assets/ac-screenshots/2023-ba2.png\" width=\"30%\"\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\n**2023 HW3**\n\n- HW3-1 Stack Base Machine \n- HW3-2 Matrix Calculator\n\n\u003cdiv\u003e\n    \u003cimg src=\"./assets/ac-screenshots/2023-hw3.png\" width=\"30%\"\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\n\n**2023 BA3**\n\n- BA1 Simple Calculator\n- BA2 Stack Machine\n\n\u003cdiv\u003e\n    \u003cimg src=\"./assets/ac-screenshots/2023-ba3.png\" width=\"30%\"\u003e\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxrjun%2Fcompiler-fall23","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxxrjun%2Fcompiler-fall23","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxrjun%2Fcompiler-fall23/lists"}