📄 define.h
字号:
#ifndef DEFINE_H_
#define DEFINE_H_
// #define NDEBUG // 这个宏是控制是否解析assert的所以在正式发布时这个宏需要定义,
// 开发的时候需要屏蔽这个宏的定义
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
// 在这个地方定义全局使用的变量和常量
extern void exit(int);
// 在这个地方定义内存分配使用的变量和常量
#define NEW(p,a) ((p) = allocate(sizeof *(p), (1)))
#define NEW0(p,a) memset(NEW((p),(a)), 0, sizeof *(p))
extern void *allocate(unsigned long n, unsigned long a);
// 在这个地方定义在输入缓冲中要使用的变量或者产量.
#define MAXLINE 1024
#define BUFSIZE 4096
// 在这个地方定义要在词法分析中要使用的变量或者常量
// 在这个地方定义要在错误处理模块当中使用的变量和常量
#define ERR_LIMIT 1
extern void error (char message[]);
// 在这个地方定义要在符号表模块当中使用的变量和常量
#define SYM_HASH_SIZE 256 // 定义了一个散列表的大小
typedef struct symbol *Symbol;
enum { CONSTANTS=1, GLOBAL, PARAM, LOCAL}; //这个枚举定义了域
typedef struct cord{
char *filename;
unsigned int x, y;
} Cordinate; // 这个结构体用于定位一个符号在文件中的位置
struct symbol{ // 在此处定义的symbol结构体就是符号结构体由它构成符号表
char* name;
int scope;
Cordinate src;
Symbol up;
};
typedef struct entry *Entry;
struct entry{
struct symbol sym;
struct entry *link;
};
typedef struct table *Table;
struct table {
int level;
Table previous;
Entry slot[ SYM_HASH_SIZE ];
Symbol all;
};
// 在这个地方定义要在此法分析模块当中使用的变量和常量
//
//#include "micro.h"
//#include "global.h"
//#include "scan.h"
#endif /*DEFINE_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -