https://github.com/winstonliyt/c-basedcompilerwithqt
C-based Compiler With Qt for Course 10031202 Project
https://github.com/winstonliyt/c-basedcompilerwithqt
compiler-design cpp grammar-parser lr1-parser syntax-analyzer
Last synced: 9 months ago
JSON representation
C-based Compiler With Qt for Course 10031202 Project
- Host: GitHub
- URL: https://github.com/winstonliyt/c-basedcompilerwithqt
- Owner: WinstonLiyt
- License: mit
- Created: 2024-03-17T09:41:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T04:07:44.000Z (over 1 year ago)
- Last Synced: 2025-06-04T23:49:53.149Z (9 months ago)
- Topics: compiler-design, cpp, grammar-parser, lr1-parser, syntax-analyzer
- Language: C++
- Homepage:
- Size: 44.7 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## C-basedCompilerWithQt :wink:
### Project Description

Using a high-level programming language, implement a **one-pass compiler** that resembles C. The specific requirements are as follows:
1. **Construct a lexical analysis DFA** to recognize character types in the code and form basic tokens to be sent to the syntax analyzer.
2. Based on the **LR(1) analysis method**, write a syntax analysis program that, given an input grammar, **automatically generates the ACTION and GOTO tables** and performs reduction and judgment.
3. The **syntax analysis program** should be able to call the lexical analysis program and take into account the subsequent semantic analysis module.
4. For a given grammar and a segment of code, the program should **correctly determine whether the code string is a sentence of the grammar** and output the analysis process and syntax tree.
5. Generate corresponding **quadruples for each syntax structure** (e.g., assignment statements, conditional statements, loop statements, function jumps).
6. Handle the **backpatching of quadruples** (e.g., jump targets in conditional jump statements).
7. Perform simple **optimizations**, such as eliminating redundant temporary variables.
8. **Output the generated quadruples to a file**.
9. Based on the result of the intermediate code generation, use **live variable information and register allocation algorithms** to generate assembly target code. If successful, **generate MIPS assembly code**.
10. **Run the assembly code through Mars** and verify that the results of the assembly code match the results of the C++ code.