compiler-temp/read.md

63 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 任务划分
- 两部分任务
1. 词法分析器
2. 语法分析器
## 词法分析器
### 流程
- 关键字的识别 --> 超前搜索
- 构建词法识别的状态转换图
```
1. 构造出关键字与种类编码的对应表
2. 根据对应表 构造状态转换图 --->先根据所做内容画出语法分析器
```
### 输出格式
[待测代码中的单词符号] [TAB] <[单词符号种别],[单词符号内容]>
- 其中单词符号种别为 KW关键字、OP运算符、SE界符、IDN标识符INT整形数
- 单词符号内容第⼀个维度为其种别,第⼆个维度为其属性。
# 代码结构
```
📁2024-compiler-mods
├─ 📄.gitignore
├─ 📄CMakeLists.txt
├─ 📄read.md
├─ 📄README.md
├─ 📁LL1
│ ├─ 📄CMakeLists.txt
│ ├─ 📄grammar.cpp
│ ├─ 📄grammar.h
│ ├─ 📄LL1.cpp
│ └─ 📄LL1.h
├─ 📁main
│ ├─ 📄CMakeLists.txt
│ ├─ 📄grammar.h
│ ├─ 📄LL1.h
│ ├─ 📄main.cpp
│ └─ 📄nfa.h
├─ 📁nfa
│ ├─ 📄CMakeLists.txt
│ ├─ 📄dfa.cpp
│ ├─ 📄nfa.cpp
│ ├─ 📄nfa.h
│ └─ 📄tool.cpp
├─ 📁.git
└─ 📁build
```
# 需做改动
1. 可视化部分做一做改动,原有代码中的比较可以用但最终考虑不提交考虑添加DFA、NFA的画图可视化
2. 拆分词法分析器和语法分析器为两部分,对两部分测试独立进行,保证至少有一部分无误
# 需考虑
1. 错误处理部分
2. 数字 01 情况
3. 标识符一定包含字母、数、下划线三部分
4. 测试部分复合的标识符定义读取