globals.h

来自「本程序是 《编译原理与实践》一书中2.35 习题的解答。主要用到了 yyless」· C头文件 代码 · 共 62 行

H
62
字号
/* 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 + =
减小字号Ctrl + -
显示快捷键?