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

📄 globals.h

📁 根据tiny实现的C-词法语法分析器 编译原理课程
💻 H
字号:
/****************************************************/
/* File: globals.h                                  */
/* Global types and vars for TINY compiler          */
/* must come before other include files             */
/* Compiler Construction: Principles and Practice   */
/* Kenneth C. Louden                                */
/****************************************************/

#ifndef _GLOBALS_H_
#define _GLOBALS_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 6


/* set NO_PARSE to TRUE to get a scanner-only compiler */
#define NO_PARSE FALSE//TRUE
/* set NO_ANALYZE to TRUE to get a parsetree-only compiler */
#define parsetree FALSE//TRUE


typedef enum 
    /* book-keeping tokens */
   {ENDFILE,ERROR,
    /* reserved words */
    IF,ELSE,INT,RETURN,VOID,WHILE,
    /* multicharacter tokens */
    ID,NUM,
    /* special symbols */
    ASSIGN,EQ,EQQ,RT,COMMA,LPARENZ,RPARENZ,CON,CON1,LPAREND,RPAREND,RTT,LT,LTT,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 EchoSource;
extern int TraceScan;
extern int Error; 

typedef struct treenode
{
	struct treenode *child[6];
	char *str;
	int lineno;
	int n;

}tnode;
FILE *fp;//fp=fopen("a.txt","wb+")
extern tnode *td;
extern int sp;
extern int error;
#endif

⌨️ 快捷键说明

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