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

📄 globals.h

📁 本程序是 《编译原理与实践》一书中2.35 习题的解答。主要用到了 yyless()和 start condition 来解决。 作者:xiangyazi24@163.com NJU
💻 H
字号:
/* File: globals.h
   Global type and vars for TINY compiler
   must come before other include files
*/

#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 8

typedef enum
{
        /* book-keeping tokens*/
        ENDFILE,ERROR,
        /* reserved words */
        IF,THEN,ELSE,END,REPEAT,UNTIL,READ,WRITE,
        /* multicharacter tokens */
        ID,NUM,
        /* special symbols */
        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 simulater */

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 imformation to be printed to the 
   listing file as each token is recognized by the scanner
*/
extern int TraceScan;

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

#endif

⌨️ 快捷键说明

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