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

📄 nepc.h

📁 一个小计算器的实现(编译原理),用Lex和bison
💻 H
字号:
#ifndef _NEPC_H_#define _NEPC_H_#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdarg.h>#include <math.h>#define MAX_STRLEN 5120#define MAX_SYMLEN 512#define MAX_SYMNUM 1024#define SYM_NOTFOUND -1#define SYMTAB_OVFLW -3#define MEM_MALLOCERR -10#define WAITINPUT printf("\n--> ")#define SIZEOF_NODETYPE(p) ((char *)&p->intCon - (char *)p)#define SIZEOF_SYMTYPE(p) ((char *)&p->ival - (char *)p)#define PRINTINT(p) printf( "%d\n" ,(INT)p )#define PRINTFLT(p)  printf( "%lf\n" ,(FLT)p )#define PRINTSTR(p) printf("%s\n",p)#define STR_TO_INT(str)  atol(str)#define STR_TO_FLT(str)  atof(str)#define MAM_NAME_LEN  1024 typedef  int INT;typedef double FLT; /////////////////////////////////////////////////////////////////////////////////////typedef enum { 	typeInt,typeFloat,typeString,typeVar, typeOpr,typeStruct } nodeEnum;typedef  struct  {   char* name ;/* The current name   */   int nameSize;   struct nameNode *next;/* The next nameNode, it is to make a chain   */	}nameNode;typedef struct {    nodeEnum type;/* The   type of node */    char*  name;    int nameSize;    int level;    int lineNum;/* The  line number when the node is first decared */    int iValue;/* If the type is int, this is its value   */    float fValue;/* If the type is float, this is its value   */    char* strValue;/* If the type is string, this is its value   */    int strValueSize;}commonType;	typedef struct  {     commonType *sysCommon;    int useFlag;     struct sysType *nextNode;/* The  next symbol , to make a symbol chain */    int childNum;/* If the type is struct, this is its field's number   */    struct sysType *Child[1];/* If the type is struct, this is its field's list   */  } sysType;typedef struct  {	sysType* sysHead;	sysType* sysTail;	int G_sys_number;      int first;  }sysInfoType ;sysInfoType sysInfo;typedef struct  {     commonType *nodeCommon;	    int oprCurName;/* The current operate name  */    int oprChildNum;/* The  child operate number */    struct nodeType *oprChild[100];/* The  child operate list */    struct nodeType *nextNode;/* The  next node, it is for the sentenceArray */    int structNameNum;/* If this node is for a struct , this is its name number,                                for example,  a.b.c   ,  its  structNameNum is 3 */     nameNode *structNameList;/* If this node is for a struct , this is its name number,                                for example,  a.b.c   ,  its  name list is  a  b  c */     sysType *sysPoint;/* Point  to the sysType,                                     for example,  a.b.c   ,  it will piont  to  c */} nodeType;nodeType * sentenceArray[1024];int  sentenceArrayLen;int G_line;int G_level;////////////////////////////////////////////////////////////////////////////////////////extern void yyerror(char *);extern int yyparse();extern nodeType * interpret(nodeType *p) ;#endif

⌨️ 快捷键说明

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