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

📄 global.h

📁 在linux下实行的简单的c语言编译器
💻 H
字号:
/*File: Global.h *Global Types and Vars for BenC *It must be included in every files of this project; */#ifndef _GLOBAL_H#define _GLOBAL_H#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>/*define the boolean FALSE*/#ifndef FALSE#define FALSE 0#endif /*FALSE*//*define the boolean FALSE*/#ifndef TRUE#define TRUE 1#endif /*TRUE*//*define the max file name number*/#ifndef MAX_PATH#define MAX_PATH 255#endif /*MAX_PATH*//*define the max token length*/#ifndef MAXTOKENLEN #define MAXTOKENLEN 40#endif /*MAXTOKENLEN*//*Length of Label*/#define LABEL_SIZE 10#define EXP_VARIABLE_LENGTH 1/*Max children number of a syntax tree node*/#define MAXCHILDREN 3typedef int TokenType;		/*used in lex*/extern FILE *g_src_file;	/*source c code file*/extern FILE *g_lst_file;	/*list file,list syntax tree*/extern FILE *g_asm_file;	/*asm code file*/extern FILE *g_data_file;	/*data section file*/extern FILE *g_bss_file;	/*bss section file*/	extern int g_lineno;		/*source line number*/extern int g_error;		/*indicate error*//*****************************************************		Syntax Tree******************************************************//*Three kinds of syntax tree nodes*/typedef enum {Dec, Stmt, Exp} NodeKind;typedef enum {IfK, WhileK, CallK, ReturnK, ReturnK, BreakK, ContinueK, AssignK} StmtKind;typedef enum {OpK, FNumK, NumK, EnumK, CharK, IdK, NotK} ExpKind;typedef enum {FunDecK, FunDefK, VarK, CompK, ParamK} DecKind;/*Type*/typedef enum {Void, Int, Float, Bool, Char} Type;/*size of symbol table*/#define SIZE 15/*record in variable table*/typedef struct valEntry{	char *name;	Type type;	int offset;	struct valEntry *next;} ValEntry;/*record in function table*/typedef struct funEntry{	char *name;	Type type;	int ret_val;	ValEntry *para;	struct funEntry *next;} FunEntry;/*symbol table*/typedef struct symtab{	struct symtab *parent;	int level;	int memloc;	ValEntry *valTable[SIZE];	FunEntry *funEntry;	char lab1[LABEL_SIZE];	char lab2[LABEL_SIZE];} Symtab;/*Syntax tree node*/typedef struct treeNode{	struct treeNode *child[MAXCHILDREN];	struct treeNode *sibling;	int lineno;	NodeKind nodeKind;	union	{		ExpKind exp;		DecKind dec;		StmtKind stmt;	} kind;		union		{		TokenType op;		union		{			char c;			int i;			float f;		} val;		char *name;		Symtab *table;	} attr;	int call_stmt;	Type type;} TreeNode;#endif /*_GLOBAL_H*/

⌨️ 快捷键说明

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