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

📄 global.h

📁 这个是编译原理的词法分析的实验报告!很不错
💻 H
字号:
#ifndef GLOBAL_H
#define GLOBAL_H


#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>



const int BSIZE=128;			//buffer size
const char EOS='\0';			//end of string
const int DONE=258;				//end of file

//token type
const int NUM=256;				//number
const int ID=257;				//identifier
const int OPERATOR=265;
const int DELIMITER=266;
const int NONE=-1;				//no token value

//reserved words
const int INT=259;
const int REAL=260;
const int IF=261;
const int THEN=262;
const int ELSE=263;
const int WHILE=264;



extern long tokenval;			//extern 可以在这里定义,另一个文件中初始化
								//因为最大的 整数为2^31,所以要用long,4byte,2^32
extern int lineno;
extern int position;


//符号表中的纪录结构体
struct entry
{
	char *lexptr;				//token 属性
	int token;					//token
};



const int STRMAX=999;			//lexeme array size
const int SYMMAX=100;			//symbol table 纪录数目

struct entry symtable[SYMMAX];	//symbol table
char lexemes[STRMAX];			//lexeme array


union attribute
{
	long long_attr;		//for int
	double dou_attr;	//for double
	char char_attr;		//for delimiters and operators
	char *str_attr;		//for id and some operators
};


struct to_parser
{
	int token;
	attribute attr;

	int line_no;
	int position;

};









#endif

⌨️ 快捷键说明

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