班级: 学号: 姓名: 1 实验四 LL(1)文法识别程序设计 一、实验目的 通过 LL(1)文法识别程序的设计理解自顶向下的语法分析思想
二、实验重难点 FIRST 集合、FOLLOW 集合元素的求解,预测分析表的构造 三、实验内容与要求 实验内容: 1. 熟悉 Visual C++ 6
0 集成开发环境,掌握 VC 下创建工程的方法和步骤; 2. 阅读参考代码,对源代码进行改造,使之能解决指定的文法识别过程; 3
预测分析表的构造 四、实验学时 4 课时 五、实验设备与环境 C 语言编译环境 六、根据实验过程填写下列内容 1.测试数据及结果分析 班级: 学号: 姓名: 2 2
在原有代码的基础上选择教材中P96 例题1 文法,对该程序进行改造,使之能实现对新文法的识别
(此处写代码) #include "stdio
h" #include "malloc
h" typedef struct Lchar{ char char_ch; struct Lchar *next; }Lchar; Lchar *p,*h,*temp,*top,*base; char curchar; char curtocmp; int right; int table[4][5]={{1,0,0,0,0},{1,1,0,0,0},{1,1,1,1,0}, {1,0,0,1,0,}}; int i,j; void push(char pchar){ temp=(Lchar *)malloc(sizeof(Lchar)); temp->char_ch=pchar; temp->next=top; top=temp; } void pop(void){ curtocmp=top->char_ch; if(top->char_ch
='#') top=top->next; }