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

📄 globals.h

📁 tiny 编译器程序的设计 修改了原作者的程序 现在能生成中间代码
💻 H
字号:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif


/* MAXRESERVED = the number of reserved words */
#define MAXRESERVED 8

typedef enum
{ENDFILE,ERROR,
IF,THEN,ELSE,END,REPEAT,UNTIL,READ,WRITE,
ID,NUM,
ASSIGN,EQ,LT,PLUS,MINUS,TIMES,OVER,LPAREN,RPAREN,SEMI}TokenType;

extern FILE* source; /* source code text file */
extern FILE* listing; /* listing output text file */
extern FILE* code; /* code text file for TM simulator */
extern int lineno; /* source line number for listing */
extern int Error; 

/**************************************************/
/***********   Syntax tree for parsing ************/
/**************************************************/


typedef enum {StmtK,ExpK} NodeKind;
typedef enum {IfK,WriteK,RepeatK,ReadK,AssignK} StmtKind;
typedef enum {OpK,ConstK,IdK} ExpKind;

/* Type is used for type checking */
typedef enum {Void,Integer,Boolean} ExpType;


#define MAXCHILDREN 3

typedef struct treeNode
{struct treeNode *child[MAXCHILDREN];
struct treeNode *sibling;
int lineno;
NodeKind nodekind;
union{StmtKind stmt;ExpKind exp;}kind;
union{ TokenType op;
int val;
char *name;}attr;
ExpType type;
}TreeNode;


⌨️ 快捷键说明

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