编译原理词法语法语义分析器设计(11)
时间:2025-04-29
时间:2025-04-29
3
主流程图 (4) 较高要求
i. 扩充上述小语言的单词;
ii. 增加语法分析器的功能,能识别条件语句和循环语句等;
iii. 增加中间代码生成器的功能,能产生条件语句和循环语句等的中
间代码(四元式序列) iv. 增加报错功能;
v. 将中间代码翻译成汇编语言。 其中1,4功能完成;
四.实验程序
#include "stdafx.h" #include <iostream> #include<string> using namespace std; #include<stdio.h> #include<stdlib.h> #include<sstream>
int i,j,k,flag,number,status;
/*status which is use to judge the string is keywords or not!*/ char ch;
char words[10] = {" "}; char program[500];
int flags[500]; //存储输入句子