資源簡介
C語言實現的LL1文法判別,及first、follow、select集合計算,編譯原理實驗要求,自己實現的,可能會有不完善的地方,歡迎討論~~~
代碼片段和文件信息
#include?
#include?
#define?MAXLINE?50
//輸入的表達式
typedef?struct?node
{
char?left;
char?right[20];
char?firsts[20];
char?select[20];
int?rflag;//表達式右邊的符號串能否推出空的標記
}Production;
Production?p[MAXLINE];
int?pLength=0;
//非終結符
typedef?struct?nodee
{
char?value;
int?flag;//-1不能推出空?1能推出空
char?first[20];
char?follow[20];
}NTC;
NTC n[MAXLINE];
int?nLength=0;
int?nflag[MAXLINE];//非終結符能否推出空的臨時數組對表達式而言
int?isUpper(char?c)
{
if(c>=‘A‘&&c<=‘Z‘)
return?1;
return?0;
}
int?isLower(char?c)
{
if(c>=‘a‘&&c<=‘z‘)
return?1;
return?0;
}
void?input()
{
char?ktemp1temp2;
int?i=0;
while((k=getchar())!=‘#‘){
p[i].left=k;
scanf(“%c%c“&temp1&temp2);
scanf(“%s“p[i].right);
i++;
getchar();
}
pLength=i;
}
/
評論
共有 條評論