⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ll1.h

📁 这是一个LL(1)方法
💻 H
字号:
#include "stdlib.h"

#define UNCERTAIN 2
#define YES		  1
#define NO		  0
#define OK		  1
#define CreateNewIDNode (IDNode*)malloc(sizeof(IDNode))

typedef int Status;

typedef struct Vn_stru{
	unsigned int ID;
	char Nch;
	unsigned int ifgetnull;		/*mark whether the Vn can get NULL*/
}Vn_type;
Vn_type Vn[100];		/*store Vn flags*/
int Vn_ID_next;			/*store the next ID of Vn,with 100 starts*/

typedef struct Vt_stru{
	unsigned int ID;
	char Tch;
}Vt_type;
Vt_type Vt[100];		/*store Vt flags*/	
int Vt_ID_next;			/*store the next ID of Vt,with 200 starts*/

typedef struct IDNode{
	unsigned int ID;
	struct IDNode *next;
}IDNode;				/*uesd in Single Link*/

typedef struct pa_table{
	IDNode **ptb;
	int *row_info,*col_info;	/*store the ID of V*/
	int row_num,col_num;
}pa_table;			/*used in the construction of analyzation table*/

IDNode *ppro[100];		/*store the transformed information of entered program*/
IDNode *FirstVn[100];   /*store the first set of Vn*/
IDNode *FirstRight[100];/*store the first set of the right part of every expression*/
IDNode *Follow[100];
IDNode *Select[100];

int Line_Num ; /*the number of lines user enters*/
int ifLL1;	/*0: NOT LL(1);1:LL(1)*/

char stack[100];/*first in,last out*/


void initstack(){
	stack[0] = 1;
}
void push(char ch){
	char i = stack[0];
	if(i>=100) {
		printf("Overflow!");
	}
	else{
		stack[i++] = ch;
		stack[0] = i;
	}
}

char pop(){
	char i = stack[0];
	if (i<=1) {
		printf("Overflow!");
	}
	else {
		stack[0] = --i;
		return stack[i];
	}
}
void printStack(){
	char i = stack[0],j,ch;
	for(j=1;j<i;j++){
		printf("%c",stack[j]);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -