跪求:递归下降分析程序的实现的源代码

来源:百度知道 编辑:UC知道 时间:2024/07/07 22:58:13
设计内容及要求:
对文法 G: E→E+T|T 构造出G的递归下降分析程序。程序显示输出
T→T*F|F 匹配过程(即自上而下生成语法分析树的步骤,
F→(E)|i输出各匹配产生式序号即可)。

这个可以解决你的难题
#include <stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<string.h>

char a[50] ,b[50],d[200],e[10];
char ch;
int n1,i1=0,flag=1,n=5;
int total=0;/*步骤计数器*/

int E();
int E1();
int T();
int G();/*E’*/
int S();/*T’*/
int F();

void input();
void input1();
void output();

void main() /*递归分析*/
{
int f,p,j=0;
char x;
d[0]='E';
d[1]='=';
d[2]='>';
d[3]='T';
d[4]='G';
d[5]='#';
printf("请输入字符串(长度<50,以#号结束)\n");
do{
scanf("%c",&ch);
a[j]=ch;
j++;
}while(ch!='#');
n1=j;
ch=b[0]=a[0];
printf("步骤\t文法\t分析串\t\t分析字符\t剩余串