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

📄 globals.h.bak

📁 小型编译系统的源代码
💻 BAK
字号:
#ifndef GLOBALS_H
#define GLOBALS_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CM_parse.h"

#define FALSE 0
#define TRUE  1

typedef int TokenType; 

extern FILE* source;	/* source code text file */
extern FILE* listing;	/* listing output text file */
extern FILE* code;		/* P-code text file */

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

enum NodeKind {StmtK,ExpK,DeclK};
enum StmtKind {IfK,WhileK,ForK,ReturnK,CompoundK};
enum ExpKind  {TypeK,OpK,NotK,ArrayK,ConstK,IdK,CallK};
enum DeclKind {VarDeclK,ArrayDeclK,FuncDeclK,FuncDefK,ParamK};

/* ExpType is used for type checking */
enum ExpType {Void,Integer,Boolean,Char,Float};
enum VarKind {Func,Array,Norm};

#define MAXCHILDREN 4

struct TreeNode
{
  struct TreeNode * child[MAXCHILDREN];
  struct TreeNode * sibling;
  int lineno;
  NodeKind nodekind;
  union
  {
		StmtKind stmt; 
		ExpKind exp;
		DeclKind decl;
  } kind;
  union
  { 
    TokenType op;
    int vali;
		float valf;
		char valch;
    char * name;
		ExpType vartype;
  } attr;
  ExpType type; /* for type checking of exps */
};

extern int lineno;	/* source line number for listing */

/**************************************************/
/***********   Flags for tracing       ************/
/**************************************************/

/* EchoSource = TRUE causes the source program to
 * be echoed to the listing file with line numbers
 * during parsing
 */
extern int EchoSource;

/* TraceScan = TRUE causes token information to be
 * printed to the listing file as each token is
 * recognized by the scanner
 */
extern int TraceScan;

/* TraceParse = TRUE causes the syntax tree to be
 * printed to the listing file in linearized form
 * (using indents for children)
 */
extern int TraceParse;

/* TraceAnalyze = TRUE causes symbol table inserts
 * and lookups to be reported to the listing file
 */
extern int TraceAnalyze;

/* TraceCode = TRUE causes comments to be written
 * to the TM code file as code is generated
 */
extern int TraceCode;

/* Error = TRUE prevents further passes if an error occurs */
extern int Error; 

#endif //GLOBAL_H

⌨️ 快捷键说明

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