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

📄 world.h

📁 自己开发的c0文法编译器
💻 H
字号:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
//关键字
#define MAIN 0
#define CONST 1
#define VOID 2
#define INT 3
#define IF 4
#define ELSE 5
#define WHILE 6
#define SCANF 7
#define PRINTF 8
#define RETURN 9
#define plus 11 // "+"
#define minus 12 //"-"
#define multiply 13 //"*"
#define divide 14 //"\"
#define LT 15 //"<"
#define LEQ 16 //"<="
#define GT 17 //">"
#define GEQ 18 //">="
#define NEQ 19//"!="
#define IS_EQ 20//"=="
#define EQ 21 //'='
#define LK 22 //'('
#define RK 23 //')'
#define LB 24 //'{'
#define RB 25//'}'
#define fenghao 26//';'
#define douhao 27//','
#define maohao	28 //"



#define NONE -1 
#define keyWordNum 10 //关键字的个数
#define MAXPARA 10 //最多参数个数
#define BSIZE 256 //缓冲区大小
#define NUM 30
#define MAREL 20
#define keyWordMaxLen 15//关键字的最大长度
#define MAXOP 50
#define TABLEMAX 200//局部符号表的大小
#define MAXFUN   50
#define ID 10
#define CON 1//常量
#define VAR 2//变量
#define FUN 3//函数
#define OVER 50

int tableTop[]; //符号表栈顶指针,指向symTable中的每一行(即每一层函数名)
int have_error;





struct table //符号表
{
	int kind;//种类 常量 变量 函数
	char name[BSIZE];//名字
	int value;//常量的值
};


struct table symTable[][TABLEMAX]; //符号表

int funNum;
int lineno ;
int seehead;
enum boolean {true,false};
enum boolean returntag ;


struct midcode  //四元式
{
	char  op[MAXOP]; 
	char  reg1[MAREL];
	char  reg2[MAREL];
	char  res[MAREL];
	struct midcode * next;
};
struct midcode * mid, * r ;//存放里中间代码


FILE *midfile;

int pflag;//程序标号
char buffer[];// 缓冲区,接收一个词法
char keyword[keyWordNum][keyWordMaxLen];



struct funcRegist//函数记录表
{
	char fname[BSIZE];
	int paranum;
	char paraname[MAXPARA][BSIZE];
	int returnKind;

};



struct funcRegist funTable[];//函数record



char print_buf[100][1000];
int print_num;
int sign;
int div_num;
char temp[BSIZE];
char tempres[BSIZE],tempstr[BSIZE];

⌨️ 快捷键说明

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